From 6ba578ef294b041b6e677c78ccf464f775806688 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Tue, 21 Sep 2021 15:03:58 -0700 Subject: [PATCH] zebra: add resolver for nexthop in json zebra rib 'show ip route json' lists all nexthops in a flat list. To identify the recursively resolved nexthops relation adding a flag "resolver" as delimiter to identify recursively resolved nexthop in the list. Testing Done: { "1.1.1.0\/24":[ { "prefix":"1.1.1.0\/24", "protocol":"static", .... "nexthops":[ { "flags":5, "ip":"27.0.0.14", "afi":"ipv4", "active":true, "recursive":true, "weight":1 }, { "flags":3, "fib":true, "ip":"fe80::202:ff:fe00:11", "afi":"ipv6", "interfaceIndex":12, "interfaceName":"uplink-1", "resolver":true, <-- Resolver for recursive true flag nh "active":true, "weight":1 }, ] } ] } Signed-off-by: Chirag Shah --- zebra/zebra_vty.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 79087c5849..133034d1ab 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -775,6 +775,13 @@ static void show_nexthop_json_helper(json_object *json_nexthop, break; } + /* This nexthop is a resolver for the parent nexthop. + * Set resolver flag for better clarity and delimiter + * in flat list of nexthops in json. + */ + if (nexthop->rparent) + json_object_boolean_true_add(json_nexthop, "resolver"); + if (nexthop->vrf_id != re->vrf_id) json_object_string_add(json_nexthop, "vrf", vrf_id_to_name(nexthop->vrf_id)); -- 2.39.5