]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: add resolver for nexthop in json 9656/head
authorChirag Shah <chirag@nvidia.com>
Tue, 21 Sep 2021 22:03:58 +0000 (15:03 -0700)
committerChirag Shah <chirag@nvidia.com>
Mon, 27 Sep 2021 23:05:08 +0000 (16:05 -0700)
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 <chirag@nvidia.com>
zebra/zebra_vty.c

index 79087c58499212a8b3df06acc88106e91a7d782c..133034d1abecacdc39d2e906683f55a116ee14ab 100644 (file)
@@ -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));