From 31b66ed67d8bbc979baed5985e5d8f4bf6592495 Mon Sep 17 00:00:00 2001 From: Sarita Patra Date: Thu, 10 Nov 2022 23:21:35 -0800 Subject: [PATCH] pimd, pim6d: Don't allow pim disabled interface as nexthop While doing nexthop lookup, only allow the nexthop interafce which is PIM enabled. Issue: #10782 Issue: #11931 Signed-off-by: Sarita Patra --- pimd/pim_nht.c | 15 +++++++++++---- pimd/pim_rpf.c | 10 ++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index c3e72557b7..a33da64568 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -529,6 +529,7 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim, uint32_t hash_val = 0, mod_val = 0; uint8_t nh_iter = 0, found = 0; uint32_t i, num_nbrs = 0; + struct pim_interface *pim_ifp; if (!pnc || !pnc->nexthop_num || !nexthop) return 0; @@ -645,10 +646,13 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim, nh_iter++; continue; } - if (!ifp->info) { + + pim_ifp = ifp->info; + + if (!pim_ifp || !pim_ifp->pim_enable) { if (PIM_DEBUG_PIM_NHT) zlog_debug( - "%s: multicast not enabled on input interface %s(%s) (ifindex=%d, RPF for source %pPA)", + "%s: pim not enabled on input interface %s(%s) (ifindex=%d, RPF for source %pPA)", __func__, ifp->name, pim->vrf->name, first_ifindex, &src); if (nh_iter == mod_val) @@ -916,6 +920,7 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim, uint8_t i = 0; uint32_t hash_val = 0, mod_val = 0; uint32_t num_nbrs = 0; + struct pim_interface *pim_ifp; if (PIM_DEBUG_PIM_NHT_DETAIL) zlog_debug("%s: Looking up: %pPA(%s), last lookup time: %lld", @@ -998,10 +1003,12 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim, continue; } - if (!ifp->info) { + pim_ifp = ifp->info; + + if (!pim_ifp || !pim_ifp->pim_enable) { if (PIM_DEBUG_PIM_NHT) zlog_debug( - "%s: multicast not enabled on input interface %s(%s) (ifindex=%d, RPF for source %pPA)", + "%s: pim not enabled on input interface %s(%s) (ifindex=%d, RPF for source %pPA)", __func__, ifp->name, pim->vrf->name, first_ifindex, &src); if (i == mod_val) diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index f5834029a5..d237a73126 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -61,6 +61,7 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop, ifindex_t first_ifindex = 0; int found = 0; int i = 0; + struct pim_interface *pim_ifp; #if PIM_IPV == 4 /* @@ -118,15 +119,16 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop, continue; } - if (!ifp->info) { + pim_ifp = ifp->info; + if (!pim_ifp || !pim_ifp->pim_enable) { if (PIM_DEBUG_ZEBRA) zlog_debug( - "%s: multicast not enabled on input interface %s (ifindex=%d, RPF for source %pPAs)", + "%s: pim not enabled on input interface %s (ifindex=%d, RPF for source %pPAs)", __func__, ifp->name, first_ifindex, &addr); i++; - } else if (neighbor_needed - && !pim_if_connected_to_source(ifp, addr)) { + } else if (neighbor_needed && + !pim_if_connected_to_source(ifp, addr)) { nbr = pim_neighbor_find(ifp, nexthop_tab[i].nexthop_addr); if (PIM_DEBUG_PIM_TRACE_DETAIL)