From: Renato Westphal Date: Thu, 10 Nov 2016 14:55:09 +0000 (-0200) Subject: ripd: implement the "ip rip v2-broadcast" CLI command X-Git-Tag: frr-2.0-rc1~33^2~10 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=f90310cfe8a5d17357a0e31cb7e55eb7d6024092;p=matthieu%2Ffrr.git ripd: implement the "ip rip v2-broadcast" CLI command This command allows ripd to send v2 updates as broadcast packets instead of multicast packets. Useful as a technique to help with RIPv1/v2 interop issues. Fixes IxANVL RIP test 16.2 Signed-off-by: Renato Westphal --- diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 359549ed80..0d412ee997 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -536,7 +536,9 @@ rip_interface_reset (struct rip_interface *ri) ri->ri_send = RI_RIP_UNSPEC; ri->ri_receive = RI_RIP_UNSPEC; - + + ri->v2_broadcast = 0; + if (ri->auth_str) { free (ri->auth_str); @@ -1518,6 +1520,41 @@ ALIAS (no_ip_rip_send_version, "Version 1\n" "Version 2\n") +DEFUN (ip_rip_v2_broadcast, + ip_rip_v2_broadcast_cmd, + "ip rip v2-broadcast", + IP_STR + "Routing Information Protocol\n" + "Send ip broadcast v2 update\n") +{ + struct interface *ifp; + struct rip_interface *ri; + + ifp = (struct interface *)vty->index; + ri = ifp->info; + + ri->v2_broadcast = 1; + return CMD_SUCCESS; +} + +DEFUN (no_ip_rip_v2_broadcast, + no_ip_rip_v2_broadcast_cmd, + "no ip rip v2-broadcast", + NO_STR + IP_STR + "Routing Information Protocol\n" + "Send ip broadcast v2 update\n") +{ + struct interface *ifp; + struct rip_interface *ri; + + ifp = (struct interface *)vty->index; + ri = ifp->info; + + ri->v2_broadcast = 0; + return CMD_SUCCESS; +} + DEFUN (ip_rip_authentication_mode, ip_rip_authentication_mode_cmd, "ip rip authentication mode (md5|text)", @@ -1918,6 +1955,7 @@ rip_interface_config_write (struct vty *vty) (ri->ri_send == RI_RIP_UNSPEC) && (ri->ri_receive == RI_RIP_UNSPEC) && (ri->auth_type != RIP_AUTH_MD5) && + (!ri->v2_broadcast) && (ri->md5_auth_len != RIP_AUTH_MD5_SIZE) && (!ri->auth_str) && (!ri->key_chain) ) @@ -1959,6 +1997,9 @@ rip_interface_config_write (struct vty *vty) lookup (ri_version_msg, ri->ri_receive), VTY_NEWLINE); + if (ri->v2_broadcast) + vty_out (vty, " ip rip v2-broadcast%s", VTY_NEWLINE); + /* RIP authentication. */ if (ri->auth_type == RIP_AUTH_SIMPLE_PASSWORD) vty_out (vty, " ip rip authentication mode text%s", VTY_NEWLINE); @@ -2099,6 +2140,9 @@ rip_if_init (void) install_element (INTERFACE_NODE, &no_ip_rip_receive_version_cmd); install_element (INTERFACE_NODE, &no_ip_rip_receive_version_num_cmd); + install_element (INTERFACE_NODE, &ip_rip_v2_broadcast_cmd); + install_element (INTERFACE_NODE, &no_ip_rip_v2_broadcast_cmd); + install_element (INTERFACE_NODE, &ip_rip_authentication_mode_cmd); install_element (INTERFACE_NODE, &ip_rip_authentication_mode_authlen_cmd); install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_cmd); diff --git a/ripd/ripd.c b/ripd/ripd.c index d84f863de2..97e80ed43b 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -2443,20 +2443,22 @@ rip_output_process (struct connected *ifc, struct sockaddr_in *to, static void rip_update_interface (struct connected *ifc, u_char version, int route_type) { + struct interface *ifp = ifc->ifp; + struct rip_interface *ri = ifp->info; struct sockaddr_in to; /* When RIP version is 2 and multicast enable interface. */ - if (version == RIPv2 && if_is_multicast (ifc->ifp)) + if (version == RIPv2 && !ri->v2_broadcast && if_is_multicast (ifp)) { if (IS_RIP_DEBUG_EVENT) - zlog_debug ("multicast announce on %s ", ifc->ifp->name); + zlog_debug ("multicast announce on %s ", ifp->name); rip_output_process (ifc, NULL, route_type, version); return; } /* If we can't send multicast packet, send it with unicast. */ - if (if_is_broadcast (ifc->ifp) || if_is_pointopoint (ifc->ifp)) + if (if_is_broadcast (ifp) || if_is_pointopoint (ifp)) { if (ifc->address->family == AF_INET) { @@ -2478,7 +2480,7 @@ rip_update_interface (struct connected *ifc, u_char version, int route_type) if (IS_RIP_DEBUG_EVENT) zlog_debug("%s announce to %s on %s", CONNECTED_PEER(ifc) ? "unicast" : "broadcast", - inet_ntoa (to.sin_addr), ifc->ifp->name); + inet_ntoa (to.sin_addr), ifp->name); rip_output_process (ifc, &to, route_type, version); } diff --git a/ripd/ripd.h b/ripd/ripd.h index 3de23ec334..1c212a081b 100644 --- a/ripd/ripd.h +++ b/ripd/ripd.h @@ -258,6 +258,9 @@ struct rip_interface int ri_send; int ri_receive; + /* RIPv2 broadcast mode */ + int v2_broadcast; + /* RIPv2 authentication type. */ int auth_type;