From 5dba25927df87613142091a6869a12db2eb7f2ab Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Fri, 13 Jan 2023 15:51:59 +0100 Subject: [PATCH] bgpd: correctly initialize the IP nexthop of redistributed routes This is a preliminary work to export redistributed routes from a given VRF in an VPN network. The exportation works well, when the label allocation is based on an per-vrf mode, but not on a per nexthop mode. To associate a label with a connected nexthop, the nexthop tracking contexts are used. Until today, there was no tracking context for redistributed routes. But when using this vpn allocation mode, one needs to know whether the route is directly connected or not. When using the nexthop tracking context, the nexthop attribute of the bgp update needs to have the nexthop properly set. This was not the case for the mp_nexthop_global_in attribute which was empty. This commit is mandatory in order to later use nexthop tracking context. Signed-off-by: Philippe Guibert --- bgpd/bgp_route.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2d395538c0..4e4dce84fe 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8685,6 +8685,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, case AF_INET: attr.nexthop.s_addr = INADDR_ANY; attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4; + attr.mp_nexthop_global_in.s_addr = INADDR_ANY; break; case AF_INET6: memset(&attr.mp_nexthop_global, 0, @@ -8697,6 +8698,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, case NEXTHOP_TYPE_IPV4_IFINDEX: attr.nexthop = nexthop->ipv4; attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4; + attr.mp_nexthop_global_in = nexthop->ipv4; break; case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6_IFINDEX: @@ -8708,6 +8710,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, case AF_INET: attr.nexthop.s_addr = INADDR_ANY; attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4; + attr.mp_nexthop_global_in.s_addr = INADDR_ANY; break; case AF_INET6: memset(&attr.mp_nexthop_global, 0,