From 94e3f3e56b3af03b15d23cca60293dbfc713517b Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Fri, 15 Nov 2019 11:47:39 -0800 Subject: [PATCH] pimd: OIF add with PROTO_PIM is not happening if join rxed in PP state Dumps while in problem state - ============================ [from "show ip pim state"] Active Source Group RPT IIF OIL 1 6.0.0.31 239.1.1.111 n swp1 swp4( J * ) [from "show ip pim join"] Interface Address Source Group State Uptime Expire Prune swp3 6.0.0.22 6.0.0.31 239.1.1.111 JOIN --:--:-- 03:11 --:-- You can see from the dumps that the pim downstream router has joined on swp3 but that OIF has not been added to the OIL with flag PIM_OIF_FLAG_PROTO_PIM. This is because the join was rxed while the ifchannel was in a prune-pending state. Relevant logs - =============== [ PIM: recv_prune: prune (S,G)=(6.0.0.31,239.1.1.111) rpt=1 wc=0 upstream=6.0.0.22 holdtime=210 from 6.0.0.28 on swp3 PIM: pim_upstream_ref(pim_ifchannel_add): upstream (6.0.0.31,239.1.1.111) ref count 3 increment PIM: pim_upstream_add(pim_ifchannel_add): (6.0.0.31,239.1.1.111), iif 6.0.0.26/0 (swp1) found: 1: ref_count: 3 PIM: pim_ifchannel_add: ifchannel (6.0.0.31,239.1.1.111) is created PIM: pim_joinprune_recv: SGRpt flag is set, del inherit oif from up (6.0.0.31,239.1.1.111) PIM: pim_mroute_add(pim_channel_del_oif), vrf default Added Route: (6.0.0.31,239.1.1.111) IIF: swp1, OIFS: swp4 PIM: pim_channel_del_oif(pim_joinprune_recv): (S,G)=(6.0.0.31,239.1.1.111): proto_mask=4 IIF:1 OIF=swp3 vif_index=3 PIM: recv_join: join (S,G)=(6.0.0.31,239.1.1.111) rpt=0 wc=0 upstream=6.0.0.22 holdtime=210 from 6.0.0.28 on swp3 PIM: PIM_IFCHANNEL(swp3): (6.0.0.31,239.1.1.111) is switching from SGRpt(PP) to JOIN PIM: Sending Request for New Channel Oil Information(6.0.0.31,239.1.1.111) VIIF 1(default) ] Signed-off-by: Anuradha Karuppiah --- pimd/pim_ifchannel.c | 54 ++++++++++++++++++++++---------------------- pimd/pim_join.c | 1 - 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index d091505837..ca8f061681 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -781,6 +781,28 @@ static int nonlocal_upstream(int is_join, struct interface *recv_ifp, return 1; /* non-local */ } +static void pim_ifchannel_ifjoin_handler(struct pim_ifchannel *ch, + struct pim_interface *pim_ifp) +{ + pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, + PIM_IFJOIN_JOIN); + PIM_IF_FLAG_UNSET_S_G_RPT(ch->flags); + /* check if the interface qualifies as an immediate + * OIF + */ + if (pim_upstream_evaluate_join_desired_interface( + ch->upstream, ch, + NULL /*starch*/)) { + pim_channel_add_oif(ch->upstream->channel_oil, + ch->interface, + PIM_OIF_FLAG_PROTO_PIM, + __func__); + pim_upstream_update_join_desired(pim_ifp->pim, + ch->upstream); + } +} + + void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr, struct in_addr upstream, struct prefix_sg *sg, uint8_t source_flags, uint16_t holdtime) @@ -888,30 +910,8 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr, if (source_flags & PIM_ENCODE_RPT_BIT) pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, PIM_IFJOIN_NOINFO); - else { - /* - * We have received a S,G join and we are in - * S,G RPT Prune state. Which means we need - * to transition to Join state and setup - * state as appropriate. - */ - pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, - PIM_IFJOIN_JOIN); - PIM_IF_FLAG_UNSET_S_G_RPT(ch->flags); - /* check if the interface qualifies as an immediate - * OIF - */ - if (pim_upstream_evaluate_join_desired_interface( - ch->upstream, ch, - NULL /*starch*/)) { - pim_channel_add_oif(ch->upstream->channel_oil, - ch->interface, - PIM_OIF_FLAG_PROTO_PIM, - __func__); - pim_upstream_update_join_desired(pim_ifp->pim, - ch->upstream); - } - } + else + pim_ifchannel_ifjoin_handler(ch, pim_ifp); break; case PIM_IFJOIN_PRUNE_PENDING: THREAD_OFF(ch->t_ifjoin_prune_pending_timer); @@ -919,9 +919,9 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr, THREAD_OFF(ch->t_ifjoin_expiry_timer); pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, PIM_IFJOIN_NOINFO); - } else - pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, - PIM_IFJOIN_JOIN); + } else { + pim_ifchannel_ifjoin_handler(ch, pim_ifp); + } break; case PIM_IFJOIN_PRUNE_TMP: break; diff --git a/pimd/pim_join.c b/pimd/pim_join.c index 53bfb28228..d63bc83862 100644 --- a/pimd/pim_join.c +++ b/pimd/pim_join.c @@ -316,7 +316,6 @@ int pim_joinprune_recv(struct interface *ifp, struct pim_neighbor *neigh, recv_prune(ifp, neigh, msg_holdtime, msg_upstream_addr.u.prefix4, &sg, msg_source_flags); - /* * So if we are receiving a S,G,RPT prune * before we have any data for that S,G