From 65d62d982eae072bf02fc80fe4c0a67c91af3c88 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Fri, 30 Aug 2024 17:50:40 +0200 Subject: [PATCH] nhrpd: fix sh ip nhrp opennhrp json counter "show ip nhrp opennhrp json" counter is incorrect. > root@nhs1:/# vtysh -c 'sh ip nhrp opennhrp json' | jq . > { > "attr": { > "status": "ok", > "entriesCount": 1 <=== NOK > }, > "table": [ > { > "type": "dynamic", > "up": true, > "used": false, > "protocolAddress": "172.16.1.4", > "protocolAddressSize": 32, > "nbmaAddress": "192.168.2.4" > }, > { > "type": "dynamic", > "up": true, > "used": false, > "protocolAddress": "172.16.1.5", > "protocolAddressSize": 32, > "nbmaAddress": "192.168.2.5" > } > ] > } > Fixes: 87b9e98203 ("nhrpd: add json support to show nhrp vty commands") Signed-off-by: Louis Scalbert --- nhrpd/nhrp_vty.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c index f202576960..0fc3dee98d 100644 --- a/nhrpd/nhrp_vty.c +++ b/nhrpd/nhrp_vty.c @@ -934,6 +934,8 @@ static void show_ip_opennhrp_cache(struct nhrp_cache *c, void *pctx) if (ctx->afi != family2afi(sockunion_family(&c->remote_addr))) return; + ctx->count++; + sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])); if (c->cur.peer) sockunion2str(&c->cur.peer->vc->remote.nbma, buf[1], @@ -1031,7 +1033,6 @@ DEFUN(show_ip_nhrp, show_ip_nhrp_cmd, else json_object_string_add(json_vrf, "status", "ok"); - ctx.count++; FOR_ALL_INTERFACES (vrf, ifp) nhrp_cache_foreach(ifp, show_ip_opennhrp_cache, &ctx); }