From b5e6281b6551736f381bae4d4f8072f5255ca51c Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 20 Apr 2017 10:12:41 -0400 Subject: [PATCH] pimd: Convert pim_ifchannel_list to use up->ifchannels We have a bunch of places where we iterate over the pim_ifchannel_list to find those ifchannels that match a certain upstream. Since we already know in the upstream the list of ifchannels associated with it, just look at those instead. Functions changed: forward_on forward_off pim_upstream_rpf_interface_changed pim_upstream_update_could_assert pim_upstream_update_my_assert_metric pim_upstream_update_assert_tracking_desired pim_upstream_is_sg_rpt Ticket: CM-15629 Signed-off-by: Donald Sharp --- pimd/pim_upstream.c | 64 +++++++-------------------------------------- 1 file changed, 10 insertions(+), 54 deletions(-) diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 5f98348c3e..9f645cace3 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -441,18 +441,10 @@ static void forward_on(struct pim_upstream *up) { struct listnode *chnode; struct listnode *chnextnode; - struct pim_interface *pim_ifp; - struct pim_ifchannel *ch; + struct pim_ifchannel *ch = NULL; /* scan (S,G) state */ - for (ALL_LIST_ELEMENTS(pim_ifchannel_list, chnode, chnextnode, ch)) { - pim_ifp = ch->interface->info; - if (!pim_ifp) - continue; - - if (ch->upstream != up) - continue; - + for (ALL_LIST_ELEMENTS(up->ifchannels, chnode, chnextnode, ch)) { if (pim_macro_chisin_oiflist(ch)) pim_forward_start(ch); @@ -463,17 +455,10 @@ static void forward_off(struct pim_upstream *up) { struct listnode *chnode; struct listnode *chnextnode; - struct pim_interface *pim_ifp; struct pim_ifchannel *ch; /* scan per-interface (S,G) state */ - for (ALL_LIST_ELEMENTS(pim_ifchannel_list, chnode, chnextnode, ch)) { - pim_ifp = ch->interface->info; - if (!pim_ifp) - continue; - - if (ch->upstream != up) - continue; + for (ALL_LIST_ELEMENTS(up->ifchannels, chnode, chnextnode, ch)) { pim_forward_stop(ch); @@ -965,18 +950,9 @@ void pim_upstream_rpf_interface_changed(struct pim_upstream *up, struct listnode *chnode; struct listnode *chnextnode; struct pim_ifchannel *ch; - struct pim_interface *pim_ifp; /* search all ifchannels */ - for (ALL_LIST_ELEMENTS(pim_ifchannel_list, chnode, chnextnode, ch)) { - - pim_ifp = ch->interface->info; - if (!pim_ifp) - continue; - - if (ch->upstream != up) - continue; - + for (ALL_LIST_ELEMENTS(up->ifchannels, chnode, chnextnode, ch)) { if (ch->ifassert_state == PIM_IFASSERT_I_AM_LOSER) { if ( /* RPF_interface(S) was NOT I */ @@ -997,18 +973,10 @@ void pim_upstream_update_could_assert(struct pim_upstream *up) { struct listnode *chnode; struct listnode *chnextnode; - struct pim_interface *pim_ifp; struct pim_ifchannel *ch; /* scan per-interface (S,G) state */ - for (ALL_LIST_ELEMENTS(pim_ifchannel_list, chnode, chnextnode, ch)) { - pim_ifp = ch->interface->info; - if (!pim_ifp) - continue; - - if (ch->upstream != up) - continue; - + for (ALL_LIST_ELEMENTS(up->ifchannels, chnode, chnextnode, ch)) { pim_ifchannel_update_could_assert(ch); } /* scan iface channel list */ } @@ -1017,18 +985,10 @@ void pim_upstream_update_my_assert_metric(struct pim_upstream *up) { struct listnode *chnode; struct listnode *chnextnode; - struct pim_interface *pim_ifp; struct pim_ifchannel *ch; /* scan per-interface (S,G) state */ - for (ALL_LIST_ELEMENTS(pim_ifchannel_list, chnode, chnextnode, ch)) { - pim_ifp = ch->interface->info; - if (!pim_ifp) - continue; - - if (ch->upstream != up) - continue; - + for (ALL_LIST_ELEMENTS(up->ifchannels, chnode, chnextnode, ch)) { pim_ifchannel_update_my_assert_metric(ch); } /* scan iface channel list */ @@ -1042,14 +1002,11 @@ static void pim_upstream_update_assert_tracking_desired(struct pim_upstream *up) struct pim_ifchannel *ch; /* scan per-interface (S,G) state */ - for (ALL_LIST_ELEMENTS(pim_ifchannel_list, chnode, chnextnode, ch)) { + for (ALL_LIST_ELEMENTS(up->ifchannels, chnode, chnextnode, ch)) { pim_ifp = ch->interface->info; if (!pim_ifp) continue; - if (ch->upstream != up) - continue; - pim_ifchannel_update_assert_tracking_desired(ch); } /* scan iface channel list */ @@ -1219,11 +1176,10 @@ pim_upstream_is_sg_rpt (struct pim_upstream *up) struct listnode *chnode; struct pim_ifchannel *ch; - for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, chnode, ch)) + for (ALL_LIST_ELEMENTS_RO(up->ifchannels, chnode, ch)) { - if ((ch->upstream == up) && - (PIM_IF_FLAG_TEST_S_G_RPT(ch->flags))) - return 1; + if (PIM_IF_FLAG_TEST_S_G_RPT(ch->flags)) + return 1; } return 0; -- 2.39.5