pim: Use INADDR_ANY for current_bsr checking is valid yet

In all places that pim_nht_bsr_del is called, the code
needs to not unregister if the current_bsr is INADDR_ANY.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 5f010b1205)
This commit is contained in:
Donald Sharp 2022-02-04 08:49:39 -05:00 committed by mergify-bot
parent 2711d7af9f
commit 03a097c32d
2 changed files with 11 additions and 6 deletions

View File

@ -171,8 +171,7 @@ static int pim_on_bs_timer(struct thread *t)
zlog_debug("%s: Bootstrap Timer expired for scope: %d",
__func__, scope->sz_id);
if (scope->current_bsr.s_addr)
pim_nht_bsr_del(scope->pim, scope->current_bsr);
pim_nht_bsr_del(scope->pim, scope->current_bsr);
/* Reset scope zone data */
scope->accept_nofwd_bsm = false;
@ -558,8 +557,7 @@ static void pim_bsm_update(struct pim_instance *pim, struct in_addr bsr,
uint32_t bsr_prio)
{
if (bsr.s_addr != pim->global_scope.current_bsr.s_addr) {
if (pim->global_scope.current_bsr.s_addr)
pim_nht_bsr_del(pim, pim->global_scope.current_bsr);
pim_nht_bsr_del(pim, pim->global_scope.current_bsr);
pim_nht_bsr_add(pim, bsr);
pim->global_scope.current_bsr = bsr;
@ -583,8 +581,7 @@ void pim_bsm_clear(struct pim_instance *pim)
struct rp_info *rp_info;
bool upstream_updated = false;
if (pim->global_scope.current_bsr.s_addr)
pim_nht_bsr_del(pim, pim->global_scope.current_bsr);
pim_nht_bsr_del(pim, pim->global_scope.current_bsr);
/* Reset scope zone data */
pim->global_scope.accept_nofwd_bsm = false;

View File

@ -259,6 +259,14 @@ void pim_nht_bsr_del(struct pim_instance *pim, struct in_addr addr)
struct pim_nexthop_cache *pnc = NULL;
struct pim_nexthop_cache lookup;
/*
* Nothing to do here if the address to unregister
* is 0.0.0.0 as that the BSR has not been registered
* for tracking yet.
*/
if (addr.s_addr == INADDR_ANY)
return;
lookup.rpf.rpf_addr.family = AF_INET;
lookup.rpf.rpf_addr.prefixlen = IPV4_MAX_BITLEN;
lookup.rpf.rpf_addr.u.prefix4 = addr;