diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2024-03-12 19:48:26 +0200 | 
|---|---|---|
| committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-03-13 21:45:12 +0000 | 
| commit | 77f05ac096c860809dc0e2faa938e8d5c4456408 (patch) | |
| tree | 7f2e62188f61d194e56387f4740f95465f1dade1 | |
| parent | 21d6498ad092cb08fb3d146e983b91eee4cc8158 (diff) | |
bgpd: Check the route and the nexthop appropriately when validating NH
A route and its nexthop might belong to different VRFs. Therefore, we need
both the bgp and bgp_nexthop pointers.
Fixes: 8d51fafdcbef3dcf06df796e4f9b83d2bbd5edc2 ("bgpd: Drop bgp_static_update_safi() function")
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 778357e9efd8deaa4612587959c9ef94b50ef288)
| -rw-r--r-- | bgpd/bgp_route.c | 14 | 
1 files changed, 9 insertions, 5 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 01ca6d0a73..4e85b2a4eb 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -6293,13 +6293,14 @@ static void bgp_nexthop_reachability_check(afi_t afi, safi_t safi,  					   struct bgp_path_info *bpi,  					   const struct prefix *p,  					   struct bgp_dest *dest, -					   struct bgp *bgp) +					   struct bgp *bgp, +					   struct bgp *bgp_nexthop)  {  	/* Nexthop reachability check. */  	if (safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST) {  		if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { -			if (bgp_find_or_add_nexthop(bgp, bgp, afi, safi, bpi, -						    NULL, 0, p)) +			if (bgp_find_or_add_nexthop(bgp, bgp_nexthop, afi, safi, +						    bpi, NULL, 0, p))  				bgp_path_info_set_flag(dest, bpi,  						       BGP_PATH_VALID);  			else { @@ -6357,6 +6358,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,  	mpls_label_t label = 0;  #endif  	uint32_t num_labels = 0; +	struct bgp *bgp_nexthop = bgp;  	assert(bgp_static); @@ -6511,9 +6513,11 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,  						&pi->extra->label[0]);  			}  #endif +			if (pi->extra && pi->extra->vrfleak->bgp_orig) +				bgp_nexthop = pi->extra->vrfleak->bgp_orig;  			bgp_nexthop_reachability_check(afi, safi, pi, p, dest, -						       bgp); +						       bgp, bgp_nexthop);  			/* Process change. */  			bgp_aggregate_increment(bgp, p, pi, afi, safi); @@ -6563,7 +6567,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,  #endif  	} -	bgp_nexthop_reachability_check(afi, safi, new, p, dest, bgp); +	bgp_nexthop_reachability_check(afi, safi, new, p, dest, bgp, bgp);  	/* Aggregate address increment. */  	bgp_aggregate_increment(bgp, p, new, afi, safi);  | 
