]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ripd: implement the "ip rip v2-broadcast" CLI command
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 10 Nov 2016 14:55:09 +0000 (12:55 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 25 Nov 2016 13:34:39 +0000 (11:34 -0200)
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 <renato@opensourcerouting.org>
ripd/rip_interface.c
ripd/ripd.c
ripd/ripd.h

index 359549ed80c04fb9fb993043701777e5e0060eaa..0d412ee9971cb14b6fea9d076ed46f6e0fcc78e8 100644 (file)
@@ -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);
index d84f863de2e938d23163c04364f5e6ff8a726f6c..97e80ed43b94e0e538bc9a6417d8ebf487294057 100644 (file)
@@ -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);
         }
index 3de23ec33443bfb2303b1c276c9c57caf3b568fa..1c212a081b59eee446541ce2da379cee29b4a50e 100644 (file)
@@ -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;