From 0139efe0848346c8f8f4281f24f065cdce882504 Mon Sep 17 00:00:00 2001 From: vivek Date: Mon, 25 May 2020 14:17:12 -0700 Subject: [PATCH] bgpd: During NHT change evaluation, skip inappropriate paths When there is a NHT change and the paths dependent on that NHT are being evaluated, skip those that are marked for removal or as history. When a route gets withdrawn, its valid flag is cleared and it is flagged for removal; in the case of an EVPN route, it is also unimported from VRFs (L2 and/or L3). bgp_process is then scheduled. Under rare timing conditions, an NHT update for the route's next hop may arrive right after, and if routes flagged for removal are not skipped, they may not only be incorrectly marked as valid but also re-imported in the case of EVPN, which will be a serious error. Signed-off-by: Vivek Venkatraman --- bgpd/bgp_nht.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 78911c82f..e3b05e8b7 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -776,6 +776,11 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc) path->flags); } + /* Skip paths marked for removal or as history. */ + if (CHECK_FLAG(path->flags, BGP_PATH_REMOVED) + || CHECK_FLAG(path->flags, BGP_PATH_HISTORY)) + continue; + /* Copy the metric to the path. Will be used for bestpath * computation */ if (bgp_isvalid_nexthop(bnc) && bnc->metric) -- 2.39.5