diff mbox series

[iproute2,1/2] ip neigh: Support --json on ip neigh get

Message ID 63b6585719b0307d81191bbcf5228b94f81c112f.1669930736.git.cdleonard@gmail.com (mailing list archive)
State Accepted
Delegated to: David Ahern
Headers show
Series [iproute2,1/2] ip neigh: Support --json on ip neigh get | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Leonard Crestez Dec. 1, 2022, 9:41 p.m. UTC
The ip neigh command supports --json for "list" but not for "get". Add
json support for the "get" command so that it's possible to fetch
information about specific neighbors without regular expressions.

Fixes: aac7f725fa46 ("ipneigh: add color and json support")
Signed-off-by: Leonard Crestez <cdleonard@gmail.com>
---
 ip/ipneigh.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 2, 2022, 4 p.m. UTC | #1
Hello:

This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

On Thu,  1 Dec 2022 23:41:05 +0200 you wrote:
> The ip neigh command supports --json for "list" but not for "get". Add
> json support for the "get" command so that it's possible to fetch
> information about specific neighbors without regular expressions.
> 
> Fixes: aac7f725fa46 ("ipneigh: add color and json support")
> Signed-off-by: Leonard Crestez <cdleonard@gmail.com>
> 
> [...]

Here is the summary with links:
  - [iproute2,1/2] ip neigh: Support --json on ip neigh get
    (no matching commit)
  - [iproute2,2/2] testsuite: Add test for ip --json neigh get
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=acea9032e92e

You are awesome, thank you!
diff mbox series

Patch

diff --git a/ip/ipneigh.c b/ip/ipneigh.c
index 61b0a4a22cbf..0cf7bb60553a 100644
--- a/ip/ipneigh.c
+++ b/ip/ipneigh.c
@@ -727,16 +727,19 @@  static int ipneigh_get(int argc, char **argv)
 
 	if (rtnl_talk(&rth, &req.n, &answer) < 0)
 		return -2;
 
 	ipneigh_reset_filter(0);
+	new_json_obj(json);
 	if (print_neigh(answer, stdout) < 0) {
 		fprintf(stderr, "An error :-)\n");
 		free(answer);
+		delete_json_obj();
 		return -1;
 	}
 	free(answer);
+	delete_json_obj();
 
 	return 0;
 }
 
 int do_ipneigh(int argc, char **argv)