From dc0665f1509725bab4c0c20031a06ff80cfc36f8 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 21 Jan 2017 04:54:10 -0500 Subject: [PATCH] pimd: Handle assignment of vif index better 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 --- pimd/pim_cmd.c | 3 --- pimd/pim_iface.c | 57 ++++++++++++++---------------------------------- pimd/pimd.c | 2 -- pimd/pimd.h | 1 - 4 files changed, 16 insertions(+), 47 deletions(-) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 8f3e2cb3e0..7e85253f9a 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -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); diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index cc4f4f3dce..e1cc3a97cf 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -44,12 +44,18 @@ 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; } diff --git a/pimd/pimd.c b/pimd/pimd.c index c000a2364d..e0788772cb 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -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; diff --git a/pimd/pimd.h b/pimd/pimd.h index d43b64b0c3..2fca09ab6a 100644 --- a/pimd/pimd.h +++ b/pimd/pimd.h @@ -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; -- 2.39.5