Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: fix interface of routes leaked from another VRF #15255

Merged
merged 7 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions bgpd/bgp_mplsvpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2209,12 +2209,22 @@ static void vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
/* If the path has accept-own community and the source VRF
* is valid, reset next-hop to self, to allow importing own
* routes between different VRFs on the same node.
* Set the nh ifindex to VRF's interface, not the real interface.
*/

if (src_bgp)
subgroup_announce_reset_nhop(nhfamily, &static_attr);

bpi_ultimate = bgp_get_imported_bpi_ultimate(path_vpn);

/* The nh ifindex may not be defined (when the route is
* imported from the network statement => BGP_ROUTE_STATIC)
* or to the real interface.
* Rewrite the nh ifindex to VRF's interface.
* Let the kernel to decide with double lookup the real next-hop
* interface when installing the route.
*/
if (src_bgp) {
subgroup_announce_reset_nhop(nhfamily, &static_attr);
if (src_bgp || bpi_ultimate->sub_type == BGP_ROUTE_STATIC ||
bpi_ultimate->sub_type == BGP_ROUTE_REDISTRIBUTE) {
ifp = if_get_vrf_loopback(src_vrf->vrf_id);
if (ifp)
static_attr.nh_ifindex = ifp->ifindex;
Expand Down Expand Up @@ -2300,9 +2310,6 @@ static void vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
*/
if (!CHECK_FLAG(to_bgp->af_flags[afi][safi],
BGP_CONFIG_VRF_TO_VRF_IMPORT)) {
/* work back to original route */
bpi_ultimate = bgp_get_imported_bpi_ultimate(path_vpn);

/*
* if original route was unicast,
* then it did not arrive over vpn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
"fib": true,
"directlyConnected": true,
"interfaceName": "eth0",
"interfaceName": "vrf10",
"vrf": "vrf10",
"active": true
}
Expand Down
17 changes: 17 additions & 0 deletions tests/topotests/bgp_vrf_route_leak_basic/r1/bgpd.conf
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
hostname r1

router bgp 99
no bgp ebgp-requires-policy
address-family ipv4 unicast
redistribute connected
import vrf DONNA
!
!
router bgp 99 vrf DONNA
no bgp ebgp-requires-policy
address-family ipv4 unicast
redistribute connected
import vrf EVA
import vrf NOTEXISTING
import vrf default
!
!
router bgp 99 vrf EVA
no bgp ebgp-requires-policy
address-family ipv4 unicast
redistribute connected
import vrf DONNA
import vrf NOTEXISTING
!
!
router bgp 99 vrf NOTEXISTING
no bgp ebgp-requires-policy
no bgp network import-check
address-family ipv4 unicast
network 172.16.101.0/24
!
!
10 changes: 10 additions & 0 deletions tests/topotests/bgp_vrf_route_leak_basic/r1/zebra.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
hostname r1

int dummy0
ip address 10.0.4.1/24
no shut
!
int dummy1
ip address 10.0.0.1/24
no shut
Expand All @@ -16,3 +20,9 @@ int dummy4
ip address 10.0.3.1/24
no shut
!
int EVA
no shut
!
int DONNA
no shut
!
1 change: 1 addition & 0 deletions tests/topotests/bgp_vrf_route_leak_basic/setup_vrfs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ip link add DONNA type vrf table 1001
ip link add EVA type vrf table 1002

ip link add dummy0 type dummy # vrf default
ip link add dummy1 type dummy
ip link add dummy2 type dummy
ip link add dummy3 type dummy
Expand Down
Loading
Loading