From 5a81edeca6ed16b8a437fcbf49b96d411a9f71e6 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 28 Mar 2024 09:08:00 +0100 Subject: [PATCH] bgpd: fix route installation whereas nexthop group is uninstalled The test bgp_multi_vrf_topo2 testfails, because BGP fails to install 2 selected BGP routes in the ZEBRA FIB: > r2# show bgp vrf RED_A > [..] > *>i 1::1/128 ::ffff:a00:11 0 100 0 500 ? > *>i 1::2/128 ::ffff:a00:11 0 100 0 500 ? There are 2 nexthops groups associated to the BGP paths: > # show bgp vrf RED_A nexthop-group details > [..] > ID: 75757653, #paths 2 > Flags: 0x0003 (allowRecursion, internalBgp) > State: 0x0000 > via ::ffff:a00:11 (vrf RED_A) inactive, weight 1 > dependents 75757655 > Paths: > 2/1 1::2/128 VRF RED_A flags 0x418 > 2/1 1::1/128 VRF RED_A flags 0x418 > ID: 75757655, #paths 2 > Flags: 0x000b (allowRecursion, internalBgp, TypeGroup) > State: 0x0000 > depends count 1 > depends 75757653 > Paths: > 2/1 1::2/128 VRF RED_A flags 0x418 > 2/1 1::1/128 VRF RED_A flags 0x418 The nexthop groups could not be installed. When ZEBRA received the NHG_ADD message for ::ffff:a00:11, it failed to install a dependent nexthop: > 2024/03/28 10:36:45 ZEBRA: [VKWCR-QB19H] zebra_nhg_free: nhe 0x562597764120 (75757649[]), refcnt 0, NH ::ffff:a00:11, via r2-r1-eth0 > 2024/03/28 10:36:45 ZEBRA: [WVJCK-PPMGD][EC 4043309093] netlink-dp (NS 0) error: No route to host, type=RTM_NEWNEXTHOP(104), seq=558, pid=4061791196 > [..] > 2024/03/28 10:36:45 ZEBRA: [J7K9Z-9M7DT] Nexthop dplane ctx 0x5625977757a0, op NH_INSTALL, nexthop ID (109), result FAILURE > 2024/03/28 10:36:45 ZEBRA: [X5XE1-RS0SW][EC 4043309074] Failed to install Nexthop (109[::ffff:a00:11 if 2 vrfid 6]) into the kernel Actually, BGP tried to install an IPv6 mapped ipv4 address, whereas there are no ipv6 routes to that address. Adding to this, it is not possible to attach an IPv6 route to an IPv4 nexthop. Let us BGP use the regular ROUTE_ADD facility. Signed-off-by: Philippe Guibert --- bgpd/bgp_debug.c | 1 + bgpd/bgp_zebra.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index ba76c9c6967d..19e597ba78f0 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -2592,6 +2592,7 @@ void bgp_debug_init(void) /* debug bgp nexthop group */ install_element(ENABLE_NODE, &debug_bgp_nexthop_group_cmd); install_element(CONFIG_NODE, &debug_bgp_nexthop_group_cmd); + } /* Return true if this prefix is on the per_prefix_list of prefixes to debug diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 14d6c350ab9d..54fd40c61c05 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1537,6 +1537,12 @@ void bgp_zebra_announce_parse_nexthop(struct bgp_path_info *info, bgp_nhg_path_unlink(p_mpinfo[i]); return; } + if (api->nexthops[i].type == NEXTHOP_TYPE_IPV6 && + IS_MAPPED_IPV6(&api->nexthops[i].gate.ipv6)) { + for (i = 0; i < *valid_nh_count; i++) + bgp_nhg_path_unlink(p_mpinfo[i]); + return; + } if (p_mpinfo[i] && p_mpinfo[i]->nexthop && p_mpinfo[i]->nexthop->nexthop && p_mpinfo[i]->nexthop->nexthop->type ==