From f6e28717ecd9192cf2b3b809aeb43f75685f31d1 Mon Sep 17 00:00:00 2001 From: Enke Chen Date: Sat, 14 Sep 2024 23:47:00 -0700 Subject: [PATCH] zebra: include the prefix in nht show command Include the prefix in "show ip nht" and "show ipv6 nht". Signed-off-by: Enke Chen --- .../all_protocol_startup/r1/ip_nht.ref | 24 +++++++++---------- .../all_protocol_startup/r1/ipv6_nht.ref | 6 ++--- zebra/zebra_rnh.c | 12 ++++++---- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/tests/topotests/all_protocol_startup/r1/ip_nht.ref b/tests/topotests/all_protocol_startup/r1/ip_nht.ref index 3592f29b5454..2b4363b69e88 100644 --- a/tests/topotests/all_protocol_startup/r1/ip_nht.ref +++ b/tests/topotests/all_protocol_startup/r1/ip_nht.ref @@ -1,35 +1,35 @@ VRF default: Resolve via default: on 1.1.1.1 - resolved via static + resolved via static, prefix 1.1.1.1/32 is directly connected, r1-eth1 (vrf default), weight 1 Client list: pbr(fd XX) 1.1.1.2 - resolved via static + resolved via static, prefix 1.1.1.2/32 is directly connected, r1-eth2 (vrf default), weight 1 Client list: pbr(fd XX) 1.1.1.3 - resolved via static + resolved via static, prefix 1.1.1.3/32 is directly connected, r1-eth3 (vrf default), weight 1 Client list: pbr(fd XX) 1.1.1.4 - resolved via static + resolved via static, prefix 1.1.1.4/32 is directly connected, r1-eth4 (vrf default), weight 1 Client list: pbr(fd XX) 1.1.1.5 - resolved via static + resolved via static, prefix 1.1.1.5/32 is directly connected, r1-eth5 (vrf default), weight 1 Client list: pbr(fd XX) 1.1.1.6 - resolved via static + resolved via static, prefix 1.1.1.6/32 is directly connected, r1-eth6 (vrf default), weight 1 Client list: pbr(fd XX) 1.1.1.7 - resolved via static + resolved via static, prefix 1.1.1.7/32 is directly connected, r1-eth7 (vrf default), weight 1 Client list: pbr(fd XX) 1.1.1.8 - resolved via static + resolved via static, prefix 1.1.1.8/32 is directly connected, r1-eth8 (vrf default), weight 1 Client list: pbr(fd XX) 2.2.2.1 @@ -54,19 +54,19 @@ VRF default: unresolved Client list: pbr(fd XX) 192.168.0.2 - resolved via connected + resolved via connected, prefix 192.168.0.0/24 is directly connected, r1-eth0 (vrf default), weight 1 Client list: static(fd XX) 192.168.0.4 - resolved via connected + resolved via connected, prefix 192.168.0.0/24 is directly connected, r1-eth0 (vrf default), weight 1 Client list: static(fd XX) 192.168.7.10 - resolved via connected + resolved via connected, prefix 192.168.7.0/26 is directly connected, r1-eth7 (vrf default), weight 1 Client list: bgp(fd XX) 192.168.7.20(Connected) - resolved via connected + resolved via connected, prefix 192.168.7.0/26 is directly connected, r1-eth7 (vrf default), weight 1 Client list: bgp(fd XX) 192.168.161.4 diff --git a/tests/topotests/all_protocol_startup/r1/ipv6_nht.ref b/tests/topotests/all_protocol_startup/r1/ipv6_nht.ref index 7b71761185d8..3f03d6fe9321 100644 --- a/tests/topotests/all_protocol_startup/r1/ipv6_nht.ref +++ b/tests/topotests/all_protocol_startup/r1/ipv6_nht.ref @@ -1,15 +1,15 @@ VRF default: Resolve via default: on fc00::2 - resolved via connected + resolved via connected, prefix fc00::/64 is directly connected, r1-eth0 (vrf default), weight 1 Client list: static(fd XX) fc00:0:0:8::1000 - resolved via connected + resolved via connected, prefix fc00:0:0:8::/64 is directly connected, r1-eth8 (vrf default), weight 1 Client list: bgp(fd XX) fc00:0:0:8::2000(Connected) - resolved via connected + resolved via connected, prefix fc00:0:0:8::/64 is directly connected, r1-eth8 (vrf default), weight 1 Client list: bgp(fd XX) diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 303a81bb3e2b..89317be74d37 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -1344,13 +1344,17 @@ static void print_rnh(struct route_node *rn, struct vty *vty, json_object *json) } if (rnh->state) { - if (json) + if (json) { json_object_string_add( json_nht, "resolvedProtocol", zebra_route_string(rnh->state->type)); - else - vty_out(vty, " resolved via %s\n", - zebra_route_string(rnh->state->type)); + json_object_string_addf(json_nht, "prefix", "%pFX", + &rnh->resolved_route); + } else { + vty_out(vty, " resolved via %s, prefix %pFX\n", + zebra_route_string(rnh->state->type), + &rnh->resolved_route); + } for (nexthop = rnh->state->nhe->nhg.nexthop; nexthop; nexthop = nexthop->next) {