From 219e00134ca35eb999b52b3bed9b2f6bbbfd4caf Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 23 Jul 2016 05:36:44 -0400 Subject: [PATCH] pimd: Add code to handle the inheritance for (s,g) Add code to handle the inheritance and to send the join upstream as appropriate. Signed-off-by: Donald Sharp --- pimd/pim_register.c | 20 ++++++++--------- pimd/pim_upstream.c | 52 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/pimd/pim_register.c b/pimd/pim_register.c index 93483b8973..87a8ca935f 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -317,11 +317,20 @@ pim_register_recv (struct interface *ifp, { upstream = pim_upstream_add (&sg, ifp); pim_upstream_switch (upstream, PIM_UPSTREAM_PRUNE); + } if ((upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) || ((SwitchToSptDesired(&sg)) && pim_upstream_inherited_olist (upstream) == 0)) { + pim_rp_set_upstream_addr (&upstream->upstream_addr, sg.u.sg.src); + pim_nexthop_lookup (&upstream->rpf.source_nexthop, + upstream->upstream_addr, NULL); + upstream->rpf.source_nexthop.interface = ifp; + upstream->sg.u.sg.src = sg.u.sg.src; + upstream->rpf.rpf_addr = upstream->rpf.source_nexthop.mrib_nexthop_addr; + upstream->channel_oil->oil.mfcc_origin = sg.u.sg.src; + pim_scan_individual_oil (upstream->channel_oil); pim_register_stop_send (ifp, &sg, src_addr); sentRegisterStop = 1; } @@ -338,17 +347,6 @@ pim_register_recv (struct interface *ifp, if (!(upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) && !(*bits & PIM_REGISTER_NR_BIT)) { -#if 0 - pim_rp_set_upstream_addr (&upstream->upstream_addr, sg.u.sg.src); - pim_nexthop_lookup (&upstream->rpf.source_nexthop, - upstream->upstream_addr, NULL); - upstream->rpf.source_nexthop.interface = ifp; - upstream->sg.u.sg.src = sg.u.sg.src; - upstream->rpf.rpf_addr = upstream->rpf.source_nexthop.mrib_nexthop_addr; - upstream->channel_oil->oil.mfcc_origin = sg.u.sg.src; - pim_scan_individual_oil (upstream->channel_oil); - pim_upstream_send_join (upstream); -#endif //decapsulate and forward the iner packet to //inherited_olist(S,G,rpt) } diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 8fb51e2e82..fc83acf7ea 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -852,11 +852,61 @@ pim_upstream_start_register_stop_timer (struct pim_upstream *up, int null_regist /* * For a given upstream, determine the inherited_olist * and apply it. + * + * inherited_olist(S,G,rpt) = + * ( joins(*,*,RP(G)) (+) joins(*,G) (-) prunes(S,G,rpt) ) + * (+) ( pim_include(*,G) (-) pim_exclude(S,G)) + * (-) ( lost_assert(*,G) (+) lost_assert(S,G,rpt) ) + * + * inherited_olist(S,G) = + * inherited_olist(S,G,rpt) (+) + * joins(S,G) (+) pim_include(S,G) (-) lost_assert(S,G) + * * return 1 if there are any output interfaces * return 0 if there are not any output interfaces */ int pim_upstream_inherited_olist (struct pim_upstream *up) { - return 0; + struct pim_upstream *anysrc_up; + struct pim_interface *pim_ifp; + struct listnode *ifnextnode; + struct listnode *chnextnode; + struct pim_ifchannel *ch; + struct listnode *chnode; + struct listnode *ifnode; + struct interface *ifp; + struct prefix anysrc; + int output_intf = 0; + + anysrc = up->sg; + anysrc.u.sg.src.s_addr = INADDR_ANY; + + anysrc_up = pim_upstream_find (&anysrc); + if (anysrc_up) + { + for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), ifnode, ifnextnode, ifp)) + { + pim_ifp = ifp->info; + if (!pim_ifp) + continue; + + for (ALL_LIST_ELEMENTS (pim_ifp->pim_ifchannel_list, chnode, chnextnode, ch)) + { + if (ch->upstream != anysrc_up) + continue; + + if (ch->ifjoin_state == PIM_IFJOIN_JOIN) + { + pim_ifchannel_add (ifp, &up->sg); + output_intf++; + } + } + } + } + + if (output_intf) + pim_upstream_send_join (up); + + return output_intf; } -- 2.39.5