]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Handle assignment of vif index better
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 21 Jan 2017 09:54:10 +0000 (04:54 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 30 Jan 2017 17:51:20 +0000 (12:51 -0500)
PIM was handling vif creation deletion poorly
for interface down and up events.  Fix this
issue by keeping track of which vif index'es
we have issued and allow the wholes to be
filled in.

Ticket: CM-14556
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_cmd.c
pimd/pim_iface.c
pimd/pimd.c
pimd/pimd.h

index 8f3e2cb3e0e42f19d5e2972d218c1c1ee84bb183..7e85253f9a38dd60601c0d495b939cd3b8e31678 100644 (file)
@@ -2838,9 +2838,6 @@ DEFUN (show_ip_multicast,
   pim_zlookup_show_ip_multicast (vty);
 
   vty_out(vty, "%s", VTY_NEWLINE);
-  vty_out(vty, "Current highest VifIndex: %d%s",
-         qpim_mroute_oif_highest_vif_index,
-         VTY_NEWLINE);
   vty_out(vty, "Maximum highest VifIndex: %d%s",
          PIM_MAX_USABLE_VIFS,
          VTY_NEWLINE);
index cc4f4f3dce9f8b2e4ac7fde58d45e7caaf7fe722..e1cc3a97cfc0ff3b385ab95f1d9cf40a7b687f35 100644 (file)
 
 struct interface *pim_regiface = NULL;
 struct list *pim_ifchannel_list = NULL;
+static int pim_iface_vif_index[MAXVIFS];
 
 static void pim_if_igmp_join_del_all(struct interface *ifp);
 
 void
 pim_if_init (void)
 {
+  int i;
+
+  for (i = 0; i < MAXVIFS; i++)
+    pim_iface_vif_index[i] = 0;
+
   vrf_iflist_create(VRF_DEFAULT);
   pim_ifchannel_list = list_new();
   pim_ifchannel_list->cmp = (int (*)(void *, void *))pim_ifchannel_compare;
@@ -848,11 +854,10 @@ pim_find_primary_addr (struct interface *ifp)
   return addr;
 }
 
-static int pim_iface_vif_index = 0;
-
 static int
 pim_iface_next_vif_index (struct interface *ifp)
 {
+  int i;
   /*
    * The pimreg vif is always going to be in index 0
    * of the table.
@@ -860,8 +865,12 @@ pim_iface_next_vif_index (struct interface *ifp)
   if (ifp->ifindex == PIM_OIF_PIM_REGISTER_VIF)
     return 0;
 
-  pim_iface_vif_index++;
-  return pim_iface_vif_index;
+  for (i = 1 ; i < MAXVIFS; i++)
+    {
+      if (pim_iface_vif_index[i] == 0)
+        return i;
+    }
+  return MAXVIFS;
 }
 
 /*
@@ -921,41 +930,13 @@ int pim_if_add_vif(struct interface *ifp)
     return -5;
   }
 
-  /*
-    Update highest vif_index
-   */
-  if (pim_ifp->mroute_vif_index != PIM_OIF_PIM_REGISTER_VIF &&
-      pim_ifp->mroute_vif_index > qpim_mroute_oif_highest_vif_index) {
-    qpim_mroute_oif_highest_vif_index = pim_ifp->mroute_vif_index;
-  }
-
+  pim_iface_vif_index[pim_ifp->mroute_vif_index] = 1;
   return 0;
 }
 
-static int iflist_find_highest_vif_index()
-{
-  struct listnode      *ifnode;
-  struct interface     *ifp;
-  struct pim_interface *pim_ifp;
-  int                   highest_vif_index = -1;
-
-  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
-    pim_ifp = ifp->info;
-    if (!pim_ifp)
-      continue;
-
-    if (pim_ifp->mroute_vif_index > highest_vif_index) {
-      highest_vif_index = pim_ifp->mroute_vif_index;
-    }
-  }
-
-  return highest_vif_index;
-}
-
 int pim_if_del_vif(struct interface *ifp)
 {
   struct pim_interface *pim_ifp = ifp->info;
-  int old_vif_index;
 
   if (pim_ifp->mroute_vif_index < 1) {
     zlog_warn("%s: vif_index=%d < 1 on interface %s ifindex=%d",
@@ -970,18 +951,12 @@ int pim_if_del_vif(struct interface *ifp)
   }
 
   /*
-    Update highest vif_index
+    Update vif_index
    */
-
-  /* save old vif_index in order to compare with highest below */
-  old_vif_index = pim_ifp->mroute_vif_index;
+  pim_iface_vif_index[pim_ifp->mroute_vif_index] = 0;
 
   pim_ifp->mroute_vif_index = -1;
 
-  if (old_vif_index == qpim_mroute_oif_highest_vif_index) {
-    qpim_mroute_oif_highest_vif_index = iflist_find_highest_vif_index();
-  }
-
   return 0;
 }
 
index c000a2364dc249fb650bd044cbc1fee703a0545b..e0788772cba9bcf03fb20f1ca80b71e215f2b932 100644 (file)
@@ -49,7 +49,6 @@ struct thread_master     *master = NULL;
 uint32_t                  qpim_debugs = 0;
 int                       qpim_mroute_socket_fd = -1;
 int64_t                   qpim_mroute_socket_creation = 0; /* timestamp of creation */
-int                       qpim_mroute_oif_highest_vif_index = -1;
 int                       qpim_t_periodic = PIM_DEFAULT_T_PERIODIC; /* Period between Join/Prune Messages */
 struct pim_assert_metric  qpim_infinite_assert_metric;
 long                      qpim_rpf_cache_refresh_delay_msec = 50;
@@ -122,7 +121,6 @@ void pim_init()
   qpim_static_route_list->del = (void (*)(void *)) pim_static_route_free;
 
   qpim_mroute_socket_fd = -1; /* mark mroute as disabled */
-  qpim_mroute_oif_highest_vif_index = -1;
 
   qpim_inaddr_any.s_addr = PIM_NET_INADDR_ANY;
 
index d43b64b0c34474e9075355428072f61be81f660e..2fca09ab6a3a426f27dc7c80da018f187a3f14b0 100644 (file)
@@ -99,7 +99,6 @@ extern struct thread_master     *master;
 uint32_t                  qpim_debugs;
 int                       qpim_mroute_socket_fd;
 int64_t                   qpim_mroute_socket_creation; /* timestamp of creation */
-int                       qpim_mroute_oif_highest_vif_index;
 struct in_addr            qpim_all_pim_routers_addr;
 int                       qpim_t_periodic; /* Period between Join/Prune Messages */
 struct pim_assert_metric  qpim_infinite_assert_metric;