From 8a02d9fe1e167bc57bcf8f8968107a739b41b654 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sun, 15 Jan 2023 12:43:37 +0200 Subject: [PATCH] bgpd: Set nh ifindex to VRF's interface, not the real The kernel will lookup the real interface later. Signed-off-by: Donatas Abraitis --- bgpd/bgp_mplsvpn.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index ddc9a525f9..ab568d1d6f 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1868,6 +1868,7 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */ struct bgp_path_info *bpi_ultimate = NULL; int origin_local = 0; struct bgp *src_vrf; + struct interface *ifp; int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF); @@ -1961,9 +1962,16 @@ static bool 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. + * Let the kernel to decide with double lookup the real next-hop + * interface when installing the route. */ - if (src_bgp) + if (src_bgp) { subgroup_announce_reset_nhop(nhfamily, &static_attr); + ifp = if_get_vrf_loopback(src_vrf->vrf_id); + if (ifp) + static_attr.nh_ifindex = ifp->ifindex; + } switch (nhfamily) { case AF_INET: -- 2.39.5