From f8ac50d4b67d9951324f3869a8b5cda06b232b04 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 e035ccdd0e..a1e570c296 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8675,6 +8675,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, @@ -8687,6 +8688,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: @@ -8698,6 +8700,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,