From 43038bd5ef313382a9c8da73342ab193bdb178c7 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 22 Jul 2021 11:49:08 +0200 Subject: [PATCH] pimd: correctly process rp-count==0 BSMs rp-count==0 isn't a broken BSM, it just means the BSR no longer has any Candidate RPs for the group range. Previous behavior is badly mistaken since it stops processing the entire packet. Fix to correctly remove group range on rp-count==0 and continue processing remainder of the packet. Signed-off-by: David Lamparter --- pimd/pim_bsm.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c index 2078a859e5..4689b27034 100644 --- a/pimd/pim_bsm.c +++ b/pimd/pim_bsm.c @@ -1168,18 +1168,6 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf, buf += sizeof(struct bsmmsg_grpinfo); offset += sizeof(struct bsmmsg_grpinfo); - if (grpinfo.rp_count == 0) { - if (PIM_DEBUG_BSM) { - char grp_str[INET_ADDRSTRLEN]; - - pim_inet4_dump("", grpinfo.group.addr, - grp_str, sizeof(grp_str)); - zlog_debug("%s, Rp count is zero for group: %s", - __func__, grp_str); - } - return false; - } - group.family = AF_INET; if (grpinfo.group.mask > IPV4_MAX_BITLEN) { if (PIM_DEBUG_BSM) @@ -1194,6 +1182,32 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf, /* Get the Group node for the BSM rp table */ bsgrp = pim_bsm_get_bsgrp_node(scope, &group); + if (grpinfo.rp_count == 0) { + struct bsm_rpinfo *old_rpinfo; + + /* BSR explicitly no longer has RPs for this group */ + if (!bsgrp) + continue; + + if (PIM_DEBUG_BSM) { + char grp_str[INET_ADDRSTRLEN]; + + pim_inet4_dump("", grpinfo.group.addr, + grp_str, sizeof(grp_str)); + zlog_debug("%s, Rp count is zero for group: %s", + __func__, grp_str); + } + + old_rpinfo = bsm_rpinfos_first(bsgrp->bsrp_list); + if (old_rpinfo) + pim_rp_del(scope->pim, old_rpinfo->rp_address, + group, NULL, RP_SRC_BSR); + + pim_free_bsgrp_node(scope->bsrp_table, &bsgrp->group); + pim_free_bsgrp_data(bsgrp); + continue; + } + if (!bsgrp) { if (PIM_DEBUG_BSM) zlog_debug("%s, Create new BSM Group node.", -- 2.39.5