]> git.ipfire.org Git - thirdparty/iproute2.git/commit
ip: route: print and cache detailed nexthop information when requested
authorNikolay Aleksandrov <nikolay@nvidia.com>
Thu, 30 Sep 2021 11:38:43 +0000 (14:38 +0300)
committerDavid Ahern <dsahern@kernel.org>
Mon, 4 Oct 2021 00:24:55 +0000 (18:24 -0600)
commit5d5dc549ce7d0db0b34f0ecc3a96871c3806fb83
tree73db59dde777c453281877d1111b7f9cde493117
parentcb3d18c29e20fa95bd98a614cc5a86f9a1336115
ip: route: print and cache detailed nexthop information when requested

If -d (show_details) is used when printing/monitoring routes then print
detailed nexthop information in the field "nh_info". The nexthop is also
cached for future searches.

Output looks like:
 unicast 198.51.100.0/24 nhid 103 table 3 proto boot scope global
 nh_info id 103 group 101/102 type resilient buckets 512 idle_timer 0 unbalanced_timer 0 unbalanced_time 0 scope global proto unspec
 nexthop via 169.254.2.22 dev veth2 weight 1
 nexthop via 169.254.3.23 dev veth4 weight 1

The nh_info field has the same format as ip -d nexthop show would've had
for the same nexthop id.

For completeness the JSON version looks like:
 {
        "type": "unicast",
        "dst": "198.51.100.0/24",
        "nhid": 103,
        "table": "3",
        "protocol": "boot",
        "scope": "global",
        "flags": [ ],
        "nh_info": {
            "id": 103,
            "group": [ {
                    "id": 101
                },{
                    "id": 102
                } ],
            "type": "resilient",
            "resilient_args": {
                "buckets": 512,
                "idle_timer": 0,
                "unbalanced_timer": 0,
                "unbalanced_time": 0
            },
            "scope": "global",
            "protocol": "unspec",
            "flags": [ ]
        },
        "nexthops": [ {
                "gateway": "169.254.2.22",
                "dev": "veth2",
                "weight": 1,
                "flags": [ ]
            },{
                "gateway": "169.254.3.23",
                "dev": "veth4",
                "weight": 1,
                "flags": [ ]
            } ]
 }

Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/iproute.c