From: liuze03 Date: Wed, 7 Dec 2022 04:22:43 +0000 (+0800) Subject: bgpd: Fix aggregated routes are withdrawn abnormally. X-Git-Tag: docker/8.4.2~4^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=2865946b03feada837020d6dcbca06f28581efc8;p=matthieu%2Ffrr.git bgpd: Fix aggregated routes are withdrawn abnormally. The withdraw message and announcement message of a prefix are received continuously within 50ms, which may lead to abnormal aggregation route reference count. Steps to reproduce: -------------------------- step1: local config aggregate route 111.0.0.0/24 received route:111.0.0.1/32 111.0.0.02/32 ref_count:2 step2: peer withdraw 111.0.0.1/32 and network 111.0.0.1/32 in 50ms received route:111.0.0.1/32 111.0.0.02/32 ref_count:1 step3: peer withdraw 111.0.0.1/32 received route:111.0.0.02/32 ref_count:0 aggregate route will be withdrawn abnormally Signed-off-by: liuze03 (cherry picked from commit 704e189e594418571463c80a3efcc2c1020adcf4) --- diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 35223f5569..29e2768d17 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -4233,6 +4233,12 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id, * need to be imported again, so flag accordingly. */ force_evpn_import = true; + } else { + /* implicit withdraw, decrement aggregate and pcount + * here. only if update is accepted, they'll increment + * below. + */ + bgp_aggregate_decrement(bgp, p, pi, afi, safi); } /* Received Logging. */ @@ -4253,11 +4259,6 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id, /* The attribute is changed. */ bgp_path_info_set_flag(dest, pi, BGP_PATH_ATTR_CHANGED); - /* implicit withdraw, decrement aggregate and pcount here. - * only if update is accepted, they'll increment below. - */ - bgp_aggregate_decrement(bgp, p, pi, afi, safi); - /* Update bgp route dampening information. */ if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) && peer->sort == BGP_PEER_EBGP) {