From c3b95419ba3a3f7cb6cdcb96e58bcc85b6965557 Mon Sep 17 00:00:00 2001 From: Emanuele Di Pascale Date: Thu, 22 Apr 2021 19:04:47 +0200 Subject: [PATCH] bgpd: fix invalid labeled nexthop check the code processing an NHT update was only resetting the BGP_NEXTHOP_VALID flag, so labeled nexthops were considered valid even if there was no nexthop. Reset the flag in response to the update, and also make the isvalid_nexthop functions a little more robust by checking the number of nexthops. Signed-off-by: Emanuele Di Pascale --- bgpd/bgp_nht.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 7ccfae4ba4..dc2b0b679b 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -60,13 +60,15 @@ static int bgp_nht_ifp_initial(struct thread *thread); static int bgp_isvalid_nexthop(struct bgp_nexthop_cache *bnc) { return (bgp_zebra_num_connects() == 0 - || (bnc && CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID))); + || (bnc && CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID) + && bnc->nexthop_num > 0)); } static int bgp_isvalid_labeled_nexthop(struct bgp_nexthop_cache *bnc) { return (bgp_zebra_num_connects() == 0 - || (bnc && CHECK_FLAG(bnc->flags, BGP_NEXTHOP_LABELED_VALID))); + || (bnc && CHECK_FLAG(bnc->flags, BGP_NEXTHOP_LABELED_VALID) + && bnc->nexthop_num > 0)); } static void bgp_unlink_nexthop_check(struct bgp_nexthop_cache *bnc) @@ -477,6 +479,7 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc, bnc->nexthop = nhlist_head; } else { bnc->flags &= ~BGP_NEXTHOP_VALID; + bnc->flags &= ~BGP_NEXTHOP_LABELED_VALID; bnc->nexthop_num = nhr->nexthop_num; /* notify bgp fsm if nbr ip goes from valid->invalid */ -- 2.39.5