diff options
| author | Louis Scalbert <louis.scalbert@6wind.com> | 2022-04-28 17:01:35 +0200 | 
|---|---|---|
| committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-02-06 10:29:46 +0000 | 
| commit | 78872311a0347b9d6953c965aa3dd9d412c812b9 (patch) | |
| tree | 2628f7f167dd22ede601a75a7699dfa0998f2ac2 /bgpd/bgp_mplsvpn.c | |
| parent | da022905ca2c27318a7e7b34e753237943c82ab8 (diff) | |
bgpd: fix VRF leaking with 'no bgp network import-check'
BGP static routes are defined using the network statement, e.g.:
> router bgp XXX
>  address-family ipv4 unicast
>   network 192.168.0.0/24
When "no bgp network import-check" is set, it is impossible to
successfully import the static routes into the BGP VPN table. The prefix
is present in the table but is not marked as valid. This issue applies
regardless of whether or not routes are present in the router's RIB.
Always mark as valid the nexthops of BGP static routes when "no bgp
network import-check" is set.
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
(cherry picked from commit 45bf46441a2e0b02650a1d162367c357b220c7b1)
Diffstat (limited to 'bgpd/bgp_mplsvpn.c')
| -rw-r--r-- | bgpd/bgp_mplsvpn.c | 14 | 
1 files changed, 13 insertions, 1 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index ed74e0f08b..bdbb4a2a5b 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1011,9 +1011,11 @@ static bool leak_update_nexthop_valid(struct bgp *to_bgp, struct bgp_dest *bn,  {  	struct bgp_path_info *bpi_ultimate;  	struct bgp *bgp_nexthop; +	struct bgp_table *table;  	bool nh_valid;  	bpi_ultimate = bgp_get_imported_bpi_ultimate(source_bpi); +	table = bgp_dest_table(bpi_ultimate->net);  	if (bpi->extra && bpi->extra->vrfleak && bpi->extra->vrfleak->bgp_orig)  		bgp_nexthop = bpi->extra->vrfleak->bgp_orig; @@ -1029,7 +1031,17 @@ static bool leak_update_nexthop_valid(struct bgp *to_bgp, struct bgp_dest *bn,  	    is_pi_family_evpn(bpi_ultimate) ||  	    CHECK_FLAG(bpi_ultimate->flags, BGP_PATH_ACCEPT_OWN))  		nh_valid = true; -	else +	else if (bpi_ultimate->type == ZEBRA_ROUTE_BGP && +		 bpi_ultimate->sub_type == BGP_ROUTE_STATIC && table && +		 (table->safi == SAFI_UNICAST || +		  table->safi == SAFI_LABELED_UNICAST) && +		 !CHECK_FLAG(bgp_nexthop->flags, BGP_FLAG_IMPORT_CHECK)) { +		/* if the route is defined with the "network <prefix>" command +		 * and "no bgp network import-check" is set, +		 * then mark the nexthop as valid. +		 */ +		nh_valid = true; +	} else  		/*  		 * TBD do we need to do anything about the  		 * 'connected' parameter?  | 
