From c10cdcd79aa02ee17b1d701c16ce07285c37a178 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 29 Aug 2024 14:49:36 -0400 Subject: [PATCH 1/2] zebra: Display afi of the nexthop hash entry Let's display the afi of the nexthop hash entry. Right now it is impossible to tell the difference between v4 or v6 nexthops, especially since it is important for the kernel. Signed-off-by: Donald Sharp --- zebra/zebra_vty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 3b786e3257c0..91aa4e400b01 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1195,6 +1195,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe, json_object_string_add(json, "uptime", up_str); json_object_string_add(json, "vrf", vrf_id_to_name(nhe->vrf_id)); + json_object_string_add(json, "afi", afi2str(nhe->afi)); } else { vty_out(vty, "ID: %u (%s)\n", nhe->id, @@ -1208,7 +1209,8 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe, vty_out(vty, "\n"); vty_out(vty, " Uptime: %s\n", up_str); - vty_out(vty, " VRF: %s\n", vrf_id_to_name(nhe->vrf_id)); + vty_out(vty, " VRF: %s(%s)\n", vrf_id_to_name(nhe->vrf_id), + afi2str(nhe->afi)); } if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_VALID)) { From f90989d52a7152cbd63f73c4761689aaf4c20f15 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 29 Aug 2024 15:06:31 -0400 Subject: [PATCH 2/2] zebra: Allow blackhole singleton nexthops to be v6 A blackhole nexthop, according to the linux kernel, can be v4 or v6. A v4 blackhole nexthop cannot be used on a v6 route, but a v6 blackhole nexthop can be used with a v4 route. Convert all blackhole singleton nexthops to v6 and just use that. Possibly reducing the number of active nexthops by 1. Signed-off-by: Donald Sharp --- zebra/zebra_nhg.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 27b7f6340bef..ffcdcdd6ff9b 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -356,18 +356,23 @@ void zebra_nhe_init(struct nhg_hash_entry *nhe, afi_t afi, */ if (nh && (nh->next == NULL)) { switch (nh->type) { - case NEXTHOP_TYPE_IFINDEX: - case NEXTHOP_TYPE_BLACKHOLE: /* * This switch case handles setting the afi different - * for ipv4/v6 routes. Ifindex/blackhole nexthop + * for ipv4/v6 routes. Ifindex nexthop * objects cannot be ambiguous, they must be Address - * Family specific. If we get here, we will either use - * the AF of the route, or the one we got passed from - * here from the kernel. + * Family specific as that the kernel relies on these + * for some reason. blackholes can be v6 because the + * v4 kernel infrastructure allows the usage of v6 + * blackholes in this case. if we get here, we will + * either use the AF of the route, or the one we got + * passed from here from the kernel. */ + case NEXTHOP_TYPE_IFINDEX: nhe->afi = afi; break; + case NEXTHOP_TYPE_BLACKHOLE: + nhe->afi = AFI_IP6; + break; case NEXTHOP_TYPE_IPV4_IFINDEX: case NEXTHOP_TYPE_IPV4: nhe->afi = AFI_IP;