From fb5174a27e4122edf849c524861dfcd92d8b19f5 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Tue, 27 Dec 2011 10:18:47 +0400 Subject: zebra: fix IPv6 RA wrt interface removal (BZ#480) --- zebra/rtadv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zebra/rtadv.c') diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 8cc3c4cb..3e8750aa 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -368,7 +368,7 @@ rtadv_timer (struct thread *thread) for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp)) { - if (if_is_loopback (ifp)) + if (if_is_loopback (ifp) || ! if_is_operative (ifp)) continue; zif = ifp->info; -- cgit v1.2.1 From 6ae93c058725991df5a9ae35cefec368919b5fea Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Tue, 27 Dec 2011 10:45:36 +0400 Subject: zebra: include MTU option in RA on request (BZ#665) This implements a new "ipv6 nd mtu <1-65535>" interface-level command. * doc/ipv6.texi: add description * zebra/rtadv.c * rtadv_send_packet(): send option type 5, when configured * ipv6_nd_mtu(): new VTY helper * no_ipv6_nd_mtu(): ditto * rtadv_config_write(): add new option * rtadv_init(): list new helpers --- zebra/rtadv.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'zebra/rtadv.c') diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 3e8750aa..e0941357 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -319,6 +319,17 @@ rtadv_send_packet (int sock, struct interface *ifp) } #endif /* HAVE_STRUCT_SOCKADDR_DL */ + /* MTU */ + if (zif->rtadv.AdvLinkMTU) + { + struct nd_opt_mtu * opt = (struct nd_opt_mtu *) (buf + len); + opt->nd_opt_mtu_type = ND_OPT_MTU; + opt->nd_opt_mtu_len = 1; + opt->nd_opt_mtu_reserved = 0; + opt->nd_opt_mtu_mtu = htonl (zif->rtadv.AdvLinkMTU); + len += sizeof (struct nd_opt_mtu); + } + msg.msg_name = (void *) &addr; msg.msg_namelen = sizeof (struct sockaddr_in6); msg.msg_iov = &iov; @@ -1430,6 +1441,43 @@ DEFUN (no_ipv6_nd_router_preference, return CMD_SUCCESS; } +DEFUN (ipv6_nd_mtu, + ipv6_nd_mtu_cmd, + "ipv6 nd mtu <1-65535>", + "Interface IPv6 config commands\n" + "Neighbor discovery\n" + "Advertised MTU\n" + "MTU in bytes\n") +{ + struct interface *ifp = (struct interface *) vty->index; + struct zebra_if *zif = ifp->info; + VTY_GET_INTEGER_RANGE ("MTU", zif->rtadv.AdvLinkMTU, argv[0], 1, 65535); + return CMD_SUCCESS; +} + +DEFUN (no_ipv6_nd_mtu, + no_ipv6_nd_mtu_cmd, + "no ipv6 nd mtu", + NO_STR + "Interface IPv6 config commands\n" + "Neighbor discovery\n" + "Advertised MTU\n") +{ + struct interface *ifp = (struct interface *) vty->index; + struct zebra_if *zif = ifp->info; + zif->rtadv.AdvLinkMTU = 0; + return CMD_SUCCESS; +} + +ALIAS (no_ipv6_nd_mtu, + no_ipv6_nd_mtu_val_cmd, + "no ipv6 nd mtu <1-65535>", + NO_STR + "Interface IPv6 config commands\n" + "Neighbor discovery\n" + "Advertised MTU\n" + "MTU in bytes\n") + /* Write configuration about router advertisement. */ void rtadv_config_write (struct vty *vty, struct interface *ifp) @@ -1482,6 +1530,9 @@ rtadv_config_write (struct vty *vty, struct interface *ifp) rtadv_pref_strs[zif->rtadv.DefaultPreference], VTY_NEWLINE); + if (zif->rtadv.AdvLinkMTU) + vty_out (vty, " ipv6 nd mtu %d%s", zif->rtadv.AdvLinkMTU, VTY_NEWLINE); + for (ALL_LIST_ELEMENTS_RO (zif->rtadv.AdvPrefixList, node, rprefix)) { vty_out (vty, " ipv6 nd prefix %s/%d", @@ -1605,6 +1656,9 @@ rtadv_init (void) install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_cmd); install_element (INTERFACE_NODE, &ipv6_nd_router_preference_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_router_preference_cmd); + install_element (INTERFACE_NODE, &ipv6_nd_mtu_cmd); + install_element (INTERFACE_NODE, &no_ipv6_nd_mtu_cmd); + install_element (INTERFACE_NODE, &no_ipv6_nd_mtu_val_cmd); } static int -- cgit v1.2.1 From 6134b875f39986564aced5e2d7329fcd852f17f4 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Tue, 27 Dec 2011 18:49:15 +0400 Subject: zebra: fix output of IPv6 ND RA options The following options could be configured for an interface, but were never visible in the config text: ipv6 nd adv-interval-option ipv6 nd home-agent-preference ipv6 nd home-agent-lifetime ipv6 nd home-agent-config-flag --- zebra/rtadv.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'zebra/rtadv.c') diff --git a/zebra/rtadv.c b/zebra/rtadv.c index e0941357..bc1abcaf 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -1511,10 +1511,24 @@ rtadv_config_write (struct vty *vty, struct interface *ifp) vty_out (vty, " ipv6 nd ra-interval %d%s", interval / 1000, VTY_NEWLINE); + if (zif->rtadv.AdvIntervalOption) + vty_out (vty, " ipv6 nd adv-interval-option%s", VTY_NEWLINE); + if (zif->rtadv.AdvDefaultLifetime != RTADV_ADV_DEFAULT_LIFETIME) vty_out (vty, " ipv6 nd ra-lifetime %d%s", zif->rtadv.AdvDefaultLifetime, VTY_NEWLINE); + if (zif->rtadv.HomeAgentPreference) + vty_out (vty, " ipv6 nd home-agent-preference %u%s", + zif->rtadv.HomeAgentPreference, VTY_NEWLINE); + + if (zif->rtadv.HomeAgentLifetime) + vty_out (vty, " ipv6 nd home-agent-lifetime %u%s", + zif->rtadv.HomeAgentLifetime, VTY_NEWLINE); + + if (zif->rtadv.AdvHomeAgentFlag) + vty_out (vty, " ipv6 nd home-agent-config-flag%s", VTY_NEWLINE); + if (zif->rtadv.AdvReachableTime) vty_out (vty, " ipv6 nd reachable-time %d%s", zif->rtadv.AdvReachableTime, VTY_NEWLINE); -- cgit v1.2.1 From d660f698427277ce695a5b756f3143c8304274ea Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Fri, 30 Dec 2011 21:55:49 +0400 Subject: zebra: justify some IPv6 ND RA timers wrt RFC There was a regression introduced with the previous commit: "ipv6 nd home-agent-lifetime 1800000" appeared by default in every interface section of running-config, although this command is invalid in this context. Troubleshooting and bugfixing of the issue tracked out several bugs in router advertisement procedures, some of which are fixed in this commit. * zebra/interface.c * if_zebra_new_hook(): update to treat -1 as "uninitialized" * nd_dump_vty(): idem * zebra/rtadv.c * rtadv_send_packet(): update processing of "router lifetime" field, "home agent" option and "home agent lifetime" field to conform to RFC6275 better * ipv6_nd_ra_interval_msec(): update MaxRtrAdvInterval range check, make sure it never exceeds (initialized) AdvDefaultLifetime * ipv6_nd_ra_interval(): idem * ipv6_nd_ra_lifetime(): update AdvDefaultLifetime range check, make sure it never falls below MaxRtrAdvInterval * ipv6_nd_homeagent_lifetime(): update HomeAgentLifetime range check * no_ipv6_nd_ra_lifetime(): update to treat -1 as "uninitialized" * no_ipv6_nd_homeagent_lifetime(): idem * rtadv_config_write(): idem --- zebra/rtadv.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 11 deletions(-) (limited to 'zebra/rtadv.c') diff --git a/zebra/rtadv.c b/zebra/rtadv.c index bc1abcaf..01f88336 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -163,6 +163,7 @@ rtadv_send_packet (int sock, struct interface *ifp) struct rtadv_prefix *rprefix; u_char all_nodes_addr[] = {0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; struct listnode *node; + u_int16_t pkt_RouterLifetime; /* * Allocate control message bufffer. This is dynamic because @@ -215,13 +216,32 @@ rtadv_send_packet (int sock, struct interface *ifp) rtadv->nd_ra_flags_reserved |= ND_RA_FLAG_OTHER; if (zif->rtadv.AdvHomeAgentFlag) rtadv->nd_ra_flags_reserved |= ND_RA_FLAG_HOME_AGENT; - rtadv->nd_ra_router_lifetime = htons (zif->rtadv.AdvDefaultLifetime); + /* Note that according to Neighbor Discovery (RFC 4861 [18]), + * AdvDefaultLifetime is by default based on the value of + * MaxRtrAdvInterval. AdvDefaultLifetime is used in the Router Lifetime + * field of Router Advertisements. Given that this field is expressed + * in seconds, a small MaxRtrAdvInterval value can result in a zero + * value for this field. To prevent this, routers SHOULD keep + * AdvDefaultLifetime in at least one second, even if the use of + * MaxRtrAdvInterval would result in a smaller value. -- RFC6275, 7.5 */ + pkt_RouterLifetime = zif->rtadv.AdvDefaultLifetime != -1 ? + zif->rtadv.AdvDefaultLifetime : + MAX (1, 0.003 * zif->rtadv.MaxRtrAdvInterval); + rtadv->nd_ra_router_lifetime = htons (pkt_RouterLifetime); rtadv->nd_ra_reachable = htonl (zif->rtadv.AdvReachableTime); rtadv->nd_ra_retransmit = htonl (0); len = sizeof (struct nd_router_advert); - if (zif->rtadv.AdvHomeAgentFlag) + /* If both the Home Agent Preference and Home Agent Lifetime are set to + * their default values specified above, this option SHOULD NOT be + * included in the Router Advertisement messages sent by this home + * agent. -- RFC6275, 7.4 */ + if + ( + zif->rtadv.AdvHomeAgentFlag && + (zif->rtadv.HomeAgentPreference || zif->rtadv.HomeAgentLifetime != -1) + ) { struct nd_opt_homeagent_info *ndopt_hai = (struct nd_opt_homeagent_info *)(buf + len); @@ -229,7 +249,17 @@ rtadv_send_packet (int sock, struct interface *ifp) ndopt_hai->nd_opt_hai_len = 1; ndopt_hai->nd_opt_hai_reserved = 0; ndopt_hai->nd_opt_hai_preference = htons(zif->rtadv.HomeAgentPreference); - ndopt_hai->nd_opt_hai_lifetime = htons(zif->rtadv.HomeAgentLifetime); + /* 16-bit unsigned integer. The lifetime associated with the home + * agent in units of seconds. The default value is the same as the + * Router Lifetime, as specified in the main body of the Router + * Advertisement. The maximum value corresponds to 18.2 hours. A + * value of 0 MUST NOT be used. -- RFC6275, 7.5 */ + ndopt_hai->nd_opt_hai_lifetime = htons + ( + zif->rtadv.HomeAgentLifetime != -1 ? + zif->rtadv.HomeAgentLifetime : + MAX (1, pkt_RouterLifetime) /* 0 is OK for RL, but not for HAL*/ + ); len += sizeof(struct nd_opt_homeagent_info); } @@ -389,6 +419,8 @@ rtadv_timer (struct thread *thread) zif->rtadv.AdvIntervalTimer -= period; if (zif->rtadv.AdvIntervalTimer <= 0) { + /* FIXME: using MaxRtrAdvInterval each time isn't what section + 6.2.4 of RFC4861 tells to do. */ zif->rtadv.AdvIntervalTimer = zif->rtadv.MaxRtrAdvInterval; rtadv_send_packet (rtadv->sock, ifp); } @@ -707,7 +739,11 @@ DEFUN (ipv6_nd_ra_interval_msec, interval = atoi (argv[0]); - if (interval <= 0) + if + ( + interval < 70 || interval > 1800000 || + (zif->rtadv.AdvDefaultLifetime != -1 && interval > zif->rtadv.AdvDefaultLifetime * 1000) + ) { vty_out (vty, "Invalid Router Advertisement Interval%s", VTY_NEWLINE); return CMD_WARNING; @@ -743,7 +779,11 @@ DEFUN (ipv6_nd_ra_interval, interval = atoi (argv[0]); - if (interval <= 0) + if + ( + interval < 1 || interval > 1800 || + (zif->rtadv.AdvDefaultLifetime != -1 && interval > zif->rtadv.AdvDefaultLifetime) + ) { vty_out (vty, "Invalid Router Advertisement Interval%s", VTY_NEWLINE); return CMD_WARNING; @@ -803,7 +843,15 @@ DEFUN (ipv6_nd_ra_lifetime, lifetime = atoi (argv[0]); - if (lifetime < 0 || lifetime > 0xffff) + /* The value to be placed in the Router Lifetime field + * of Router Advertisements sent from the interface, + * in seconds. MUST be either zero or between + * MaxRtrAdvInterval and 9000 seconds. -- RFC4861, 6.2.1 */ + if + ( + lifetime > RTADV_MAX_RTRLIFETIME || + (lifetime != 0 && lifetime * 1000 < zif->rtadv.MaxRtrAdvInterval) + ) { vty_out (vty, "Invalid Router Lifetime%s", VTY_NEWLINE); return CMD_WARNING; @@ -828,7 +876,7 @@ DEFUN (no_ipv6_nd_ra_lifetime, ifp = (struct interface *) vty->index; zif = ifp->info; - zif->rtadv.AdvDefaultLifetime = RTADV_ADV_DEFAULT_LIFETIME; + zif->rtadv.AdvDefaultLifetime = -1; return CMD_SUCCESS; } @@ -944,7 +992,7 @@ DEFUN (ipv6_nd_homeagent_lifetime, ha_ltime = (u_int32_t) atol (argv[0]); - if (ha_ltime > RTADV_MAX_HALIFETIME) + if (ha_ltime < 1 || ha_ltime > RTADV_MAX_HALIFETIME) { vty_out (vty, "Invalid Home Agent Lifetime time%s", VTY_NEWLINE); return CMD_WARNING; @@ -969,7 +1017,7 @@ DEFUN (no_ipv6_nd_homeagent_lifetime, ifp = (struct interface *) vty->index; zif = ifp->info; - zif->rtadv.HomeAgentLifetime = 0; + zif->rtadv.HomeAgentLifetime = -1; return CMD_SUCCESS; } @@ -1514,7 +1562,7 @@ rtadv_config_write (struct vty *vty, struct interface *ifp) if (zif->rtadv.AdvIntervalOption) vty_out (vty, " ipv6 nd adv-interval-option%s", VTY_NEWLINE); - if (zif->rtadv.AdvDefaultLifetime != RTADV_ADV_DEFAULT_LIFETIME) + if (zif->rtadv.AdvDefaultLifetime != -1) vty_out (vty, " ipv6 nd ra-lifetime %d%s", zif->rtadv.AdvDefaultLifetime, VTY_NEWLINE); @@ -1522,7 +1570,7 @@ rtadv_config_write (struct vty *vty, struct interface *ifp) vty_out (vty, " ipv6 nd home-agent-preference %u%s", zif->rtadv.HomeAgentPreference, VTY_NEWLINE); - if (zif->rtadv.HomeAgentLifetime) + if (zif->rtadv.HomeAgentLifetime != -1) vty_out (vty, " ipv6 nd home-agent-lifetime %u%s", zif->rtadv.HomeAgentLifetime, VTY_NEWLINE); -- cgit v1.2.1 From 6bb1273e83c29b3aeff9584bc8f6272e773294ad Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Sun, 8 Jan 2012 17:46:34 +0400 Subject: zebra: clear host bits of ND RA prefix option RFC4861 4.6.2. Prefix Information Prefix An IP address or a prefix of an IP address. The Prefix Length field contains the number of valid leading bits in the prefix. The bits in the prefix after the prefix length are reserved and MUST be initialized to zero by the sender and ignored by the receiver. * rtadv.c * ipv6_nd_prefix(): add missing call to apply_mask_ipv6() * no_ipv6_nd_prefix(): idem --- zebra/rtadv.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'zebra/rtadv.c') diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 01f88336..c6771bbc 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -1202,6 +1202,7 @@ DEFUN (ipv6_nd_prefix, vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); return CMD_WARNING; } + apply_mask_ipv6 (&rp.prefix); /* RFC4861 4.6.2 */ rp.AdvOnLinkFlag = 1; rp.AdvAutonomousFlag = 1; rp.AdvRouterAddressFlag = 0; @@ -1429,6 +1430,7 @@ DEFUN (no_ipv6_nd_prefix, vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); return CMD_WARNING; } + apply_mask_ipv6 (&rp.prefix); /* RFC4861 4.6.2 */ ret = rtadv_prefix_reset (zebra_if, &rp); if (!ret) -- cgit v1.2.1 From aca43b656623f38dfa6ea835dacbdfec51d03a67 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Sun, 8 Jan 2012 18:27:12 +0400 Subject: zebra: use prefix_ipv6 in rtadv_prefix rtadv_prefix.prefix was casted to "struct prefix_ipv6" and had the same size, make it exactly this type to make the code a bit cleaner. --- zebra/rtadv.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'zebra/rtadv.c') diff --git a/zebra/rtadv.c b/zebra/rtadv.c index c6771bbc..c6c3b030 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -191,7 +191,7 @@ rtadv_send_packet (int sock, struct interface *ifp) addr.sin6_len = sizeof (struct sockaddr_in6); #endif /* SIN6_LEN */ addr.sin6_port = htons (IPPROTO_ICMPV6); - memcpy (&addr.sin6_addr, all_nodes_addr, sizeof (struct in6_addr)); + IPV6_ADDR_COPY (&addr.sin6_addr, all_nodes_addr); /* Fetch interface information. */ zif = ifp->info; @@ -297,8 +297,7 @@ rtadv_send_packet (int sock, struct interface *ifp) pinfo->nd_opt_pi_preferred_time = htonl (rprefix->AdvPreferredLifetime); pinfo->nd_opt_pi_reserved2 = 0; - memcpy (&pinfo->nd_opt_pi_prefix, &rprefix->prefix.u.prefix6, - sizeof (struct in6_addr)); + IPV6_ADDR_COPY (&pinfo->nd_opt_pi_prefix, &rprefix->prefix.prefix); #ifdef DEBUG { @@ -595,19 +594,19 @@ rtadv_prefix_free (struct rtadv_prefix *rtadv_prefix) } static struct rtadv_prefix * -rtadv_prefix_lookup (struct list *rplist, struct prefix *p) +rtadv_prefix_lookup (struct list *rplist, struct prefix_ipv6 *p) { struct listnode *node; struct rtadv_prefix *rprefix; for (ALL_LIST_ELEMENTS_RO (rplist, node, rprefix)) - if (prefix_same (&rprefix->prefix, p)) + if (prefix_same ((struct prefix *) &rprefix->prefix, (struct prefix *) p)) return rprefix; return NULL; } static struct rtadv_prefix * -rtadv_prefix_get (struct list *rplist, struct prefix *p) +rtadv_prefix_get (struct list *rplist, struct prefix_ipv6 *p) { struct rtadv_prefix *rprefix; @@ -616,7 +615,7 @@ rtadv_prefix_get (struct list *rplist, struct prefix *p) return rprefix; rprefix = rtadv_prefix_new (); - memcpy (&rprefix->prefix, p, sizeof (struct prefix)); + memcpy (&rprefix->prefix, p, sizeof (struct prefix_ipv6)); listnode_add (rplist, rprefix); return rprefix; @@ -1196,7 +1195,7 @@ DEFUN (ipv6_nd_prefix, ifp = (struct interface *) vty->index; zebra_if = ifp->info; - ret = str2prefix_ipv6 (argv[0], (struct prefix_ipv6 *) &rp.prefix); + ret = str2prefix_ipv6 (argv[0], &rp.prefix); if (!ret) { vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); @@ -1424,7 +1423,7 @@ DEFUN (no_ipv6_nd_prefix, ifp = (struct interface *) vty->index; zebra_if = ifp->info; - ret = str2prefix_ipv6 (argv[0], (struct prefix_ipv6 *) &rp.prefix); + ret = str2prefix_ipv6 (argv[0], &rp.prefix); if (!ret) { vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); @@ -1600,7 +1599,7 @@ rtadv_config_write (struct vty *vty, struct interface *ifp) for (ALL_LIST_ELEMENTS_RO (zif->rtadv.AdvPrefixList, node, rprefix)) { vty_out (vty, " ipv6 nd prefix %s/%d", - inet_ntop (AF_INET6, &rprefix->prefix.u.prefix6, + inet_ntop (AF_INET6, &rprefix->prefix.prefix, (char *) buf, INET6_ADDRSTRLEN), rprefix->prefix.prefixlen); if ((rprefix->AdvValidLifetime != RTADV_VALID_LIFETIME) || -- cgit v1.2.1 From 4afa50b393ff1fb34dd577888a05b81dfdced5af Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Tue, 24 Jan 2012 12:39:58 +0400 Subject: zebra: justify rtadv VTY commands with arguments ipv6 nd ra-interval ipv6 nd ra-lifetime ipv6 nd reachable-time ipv6 nd home-agent-preference ipv6 nd home-agent-lifetime ipv6 nd router-preference Calls to atoi() and atol() are replaced with VTY_GET_INTEGER_RANGE() macro, command patterns are clarified and aliases of some commands are added for consistency. Other changes are listed below. * zebra/rtadv.c * ipv6_nd_ra_interval_msec(): resolve -Wsign-compare * ipv6_nd_ra_interval(): idem * rtadv_init(): update to list new aliases * doc/ipv6.texi: update to match current implementation --- zebra/rtadv.c | 211 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 110 insertions(+), 101 deletions(-) (limited to 'zebra/rtadv.c') diff --git a/zebra/rtadv.c b/zebra/rtadv.c index c6c3b030..ae5c5a1c 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -723,30 +723,22 @@ DEFUN (no_ipv6_nd_suppress_ra, DEFUN (ipv6_nd_ra_interval_msec, ipv6_nd_ra_interval_msec_cmd, - "ipv6 nd ra-interval msec MILLISECONDS", + "ipv6 nd ra-interval msec <70-1800000>", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Router Advertisement interval\n" "Router Advertisement interval in milliseconds\n") { - int interval; - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; - - interval = atoi (argv[0]); + unsigned interval; + struct interface *ifp = (struct interface *) vty->index; + struct zebra_if *zif = ifp->info; - if - ( - interval < 70 || interval > 1800000 || - (zif->rtadv.AdvDefaultLifetime != -1 && interval > zif->rtadv.AdvDefaultLifetime * 1000) - ) - { - vty_out (vty, "Invalid Router Advertisement Interval%s", VTY_NEWLINE); - return CMD_WARNING; - } + VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[0], 70, 1800000); + if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime * 1000)) + { + vty_out (vty, "This ra-interval would conflict with configured ra-lifetime!%s", VTY_NEWLINE); + return CMD_WARNING; + } if (zif->rtadv.MaxRtrAdvInterval % 1000) rtadv->adv_msec_if_count--; @@ -763,30 +755,22 @@ DEFUN (ipv6_nd_ra_interval_msec, DEFUN (ipv6_nd_ra_interval, ipv6_nd_ra_interval_cmd, - "ipv6 nd ra-interval SECONDS", + "ipv6 nd ra-interval <1-1800>", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Router Advertisement interval\n" "Router Advertisement interval in seconds\n") { - int interval; - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; - - interval = atoi (argv[0]); + unsigned interval; + struct interface *ifp = (struct interface *) vty->index; + struct zebra_if *zif = ifp->info; - if - ( - interval < 1 || interval > 1800 || - (zif->rtadv.AdvDefaultLifetime != -1 && interval > zif->rtadv.AdvDefaultLifetime) - ) - { - vty_out (vty, "Invalid Router Advertisement Interval%s", VTY_NEWLINE); - return CMD_WARNING; - } + VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[0], 1, 1800); + if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime)) + { + vty_out (vty, "This ra-interval would conflict with configured ra-lifetime!%s", VTY_NEWLINE); + return CMD_WARNING; + } if (zif->rtadv.MaxRtrAdvInterval % 1000) rtadv->adv_msec_if_count--; @@ -825,13 +809,30 @@ DEFUN (no_ipv6_nd_ra_interval, return CMD_SUCCESS; } +ALIAS (no_ipv6_nd_ra_interval, + no_ipv6_nd_ra_interval_val_cmd, + "no ipv6 nd ra-interval <1-1800>", + NO_STR + "Interface IPv6 config commands\n" + "Neighbor discovery\n" + "Router Advertisement interval\n") + +ALIAS (no_ipv6_nd_ra_interval, + no_ipv6_nd_ra_interval_msec_val_cmd, + "no ipv6 nd ra-interval msec <1-1800000>", + NO_STR + "Interface IPv6 config commands\n" + "Neighbor discovery\n" + "Router Advertisement interval\n" + "Router Advertisement interval in milliseconds\n") + DEFUN (ipv6_nd_ra_lifetime, ipv6_nd_ra_lifetime_cmd, - "ipv6 nd ra-lifetime SECONDS", + "ipv6 nd ra-lifetime <0-9000>", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Router lifetime\n" - "Router lifetime in seconds\n") + "Router lifetime in seconds (0 stands for a non-default gw)\n") { int lifetime; struct interface *ifp; @@ -840,19 +841,15 @@ DEFUN (ipv6_nd_ra_lifetime, ifp = (struct interface *) vty->index; zif = ifp->info; - lifetime = atoi (argv[0]); + VTY_GET_INTEGER_RANGE ("router lifetime", lifetime, argv[0], 0, 9000); /* The value to be placed in the Router Lifetime field * of Router Advertisements sent from the interface, * in seconds. MUST be either zero or between * MaxRtrAdvInterval and 9000 seconds. -- RFC4861, 6.2.1 */ - if - ( - lifetime > RTADV_MAX_RTRLIFETIME || - (lifetime != 0 && lifetime * 1000 < zif->rtadv.MaxRtrAdvInterval) - ) + if ((lifetime != 0 && lifetime * 1000 < zif->rtadv.MaxRtrAdvInterval)) { - vty_out (vty, "Invalid Router Lifetime%s", VTY_NEWLINE); + vty_out (vty, "This ra-lifetime would conflict with configured ra-interval%s", VTY_NEWLINE); return CMD_WARNING; } @@ -880,31 +877,26 @@ DEFUN (no_ipv6_nd_ra_lifetime, return CMD_SUCCESS; } +ALIAS (no_ipv6_nd_ra_lifetime, + no_ipv6_nd_ra_lifetime_val_cmd, + "no ipv6 nd ra-lifetime <0-9000>", + NO_STR + "Interface IPv6 config commands\n" + "Neighbor discovery\n" + "Router lifetime\n" + "Router lifetime in seconds (0 stands for a non-default gw)\n") + DEFUN (ipv6_nd_reachable_time, ipv6_nd_reachable_time_cmd, - "ipv6 nd reachable-time MILLISECONDS", + "ipv6 nd reachable-time <1-3600000>", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Reachable time\n" "Reachable time in milliseconds\n") { - u_int32_t rtime; - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; - - rtime = (u_int32_t) atol (argv[0]); - - if (rtime > RTADV_MAX_REACHABLE_TIME) - { - vty_out (vty, "Invalid Reachable time%s", VTY_NEWLINE); - return CMD_WARNING; - } - - zif->rtadv.AdvReachableTime = rtime; - + struct interface *ifp = (struct interface *) vty->index; + struct zebra_if *zif = ifp->info; + VTY_GET_INTEGER_RANGE ("reachable time", zif->rtadv.AdvReachableTime, argv[0], 1, RTADV_MAX_REACHABLE_TIME); return CMD_SUCCESS; } @@ -927,31 +919,26 @@ DEFUN (no_ipv6_nd_reachable_time, return CMD_SUCCESS; } +ALIAS (no_ipv6_nd_reachable_time, + no_ipv6_nd_reachable_time_val_cmd, + "no ipv6 nd reachable-time <1-3600000>", + NO_STR + "Interface IPv6 config commands\n" + "Neighbor discovery\n" + "Reachable time\n" + "Reachable time in milliseconds\n") + DEFUN (ipv6_nd_homeagent_preference, ipv6_nd_homeagent_preference_cmd, - "ipv6 nd home-agent-preference PREFERENCE", + "ipv6 nd home-agent-preference <0-65535>", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Home Agent preference\n" - "Home Agent preference value 0..65535\n") + "preference value (default is 0, least preferred)\n") { - u_int32_t hapref; - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; - - hapref = (u_int32_t) atol (argv[0]); - - if (hapref > 65535) - { - vty_out (vty, "Invalid Home Agent preference%s", VTY_NEWLINE); - return CMD_WARNING; - } - - zif->rtadv.HomeAgentPreference = hapref; - + struct interface *ifp = (struct interface *) vty->index; + struct zebra_if *zif = ifp->info; + VTY_GET_INTEGER_RANGE ("home agent preference", zif->rtadv.HomeAgentPreference, argv[0], 0, 65535); return CMD_SUCCESS; } @@ -974,31 +961,26 @@ DEFUN (no_ipv6_nd_homeagent_preference, return CMD_SUCCESS; } +ALIAS (no_ipv6_nd_homeagent_preference, + no_ipv6_nd_homeagent_preference_val_cmd, + "no ipv6 nd home-agent-preference <0-65535>", + NO_STR + "Interface IPv6 config commands\n" + "Neighbor discovery\n" + "Home Agent preference\n" + "preference value (default is 0, least preferred)\n") + DEFUN (ipv6_nd_homeagent_lifetime, ipv6_nd_homeagent_lifetime_cmd, - "ipv6 nd home-agent-lifetime SECONDS", + "ipv6 nd home-agent-lifetime <0-65520>", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Home Agent lifetime\n" - "Home Agent lifetime in seconds\n") + "Home Agent lifetime in seconds (0 to track ra-lifetime)\n") { - u_int32_t ha_ltime; - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; - - ha_ltime = (u_int32_t) atol (argv[0]); - - if (ha_ltime < 1 || ha_ltime > RTADV_MAX_HALIFETIME) - { - vty_out (vty, "Invalid Home Agent Lifetime time%s", VTY_NEWLINE); - return CMD_WARNING; - } - - zif->rtadv.HomeAgentLifetime = ha_ltime; - + struct interface *ifp = (struct interface *) vty->index; + struct zebra_if *zif = ifp->info; + VTY_GET_INTEGER_RANGE ("home agent lifetime", zif->rtadv.HomeAgentLifetime, argv[0], 0, RTADV_MAX_HALIFETIME); return CMD_SUCCESS; } @@ -1021,6 +1003,15 @@ DEFUN (no_ipv6_nd_homeagent_lifetime, return CMD_SUCCESS; } +ALIAS (no_ipv6_nd_homeagent_lifetime, + no_ipv6_nd_homeagent_lifetime_val_cmd, + "no ipv6 nd home-agent-lifetime <0-65520>", + NO_STR + "Interface IPv6 config commands\n" + "Neighbor discovery\n" + "Home Agent lifetime\n" + "Home Agent lifetime in seconds (0 to track ra-lifetime)\n") + DEFUN (ipv6_nd_managed_config_flag, ipv6_nd_managed_config_flag_cmd, "ipv6 nd managed-config-flag", @@ -1490,6 +1481,17 @@ DEFUN (no_ipv6_nd_router_preference, return CMD_SUCCESS; } +ALIAS (no_ipv6_nd_router_preference, + no_ipv6_nd_router_preference_val_cmd, + "no ipv6 nd router-preference (high|medium|low", + NO_STR + "Interface IPv6 config commands\n" + "Neighbor discovery\n" + "Default router preference\n" + "High default router preference\n" + "Low default router preference\n" + "Medium default router preference (default)\n") + DEFUN (ipv6_nd_mtu, ipv6_nd_mtu_cmd, "ipv6 nd mtu <1-65535>", @@ -1686,10 +1688,14 @@ rtadv_init (void) install_element (INTERFACE_NODE, &ipv6_nd_ra_interval_cmd); install_element (INTERFACE_NODE, &ipv6_nd_ra_interval_msec_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_ra_interval_cmd); + install_element (INTERFACE_NODE, &no_ipv6_nd_ra_interval_val_cmd); + install_element (INTERFACE_NODE, &no_ipv6_nd_ra_interval_msec_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_ra_lifetime_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_ra_lifetime_cmd); + install_element (INTERFACE_NODE, &no_ipv6_nd_ra_lifetime_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_reachable_time_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_reachable_time_cmd); + install_element (INTERFACE_NODE, &no_ipv6_nd_reachable_time_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_managed_config_flag_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_managed_config_flag_cmd); install_element (INTERFACE_NODE, &ipv6_nd_other_config_flag_cmd); @@ -1698,8 +1704,10 @@ rtadv_init (void) install_element (INTERFACE_NODE, &no_ipv6_nd_homeagent_config_flag_cmd); install_element (INTERFACE_NODE, &ipv6_nd_homeagent_preference_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_homeagent_preference_cmd); + install_element (INTERFACE_NODE, &no_ipv6_nd_homeagent_preference_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_homeagent_lifetime_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_homeagent_lifetime_cmd); + install_element (INTERFACE_NODE, &no_ipv6_nd_homeagent_lifetime_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_adv_interval_config_option_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_adv_interval_config_option_cmd); install_element (INTERFACE_NODE, &ipv6_nd_prefix_cmd); @@ -1719,6 +1727,7 @@ rtadv_init (void) install_element (INTERFACE_NODE, &no_ipv6_nd_prefix_cmd); install_element (INTERFACE_NODE, &ipv6_nd_router_preference_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_router_preference_cmd); + install_element (INTERFACE_NODE, &no_ipv6_nd_router_preference_val_cmd); install_element (INTERFACE_NODE, &ipv6_nd_mtu_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_mtu_cmd); install_element (INTERFACE_NODE, &no_ipv6_nd_mtu_val_cmd); -- cgit v1.2.1