ip neigh: Support --json on ip neigh get

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: aac7f725fa ("ipneigh: add color and json support")
Signed-off-by: Leonard Crestez <cdleonard@gmail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
This commit is contained in:
Leonard Crestez 2022-12-01 23:41:05 +02:00 committed by David Ahern
parent a4442ce58e
commit 94fc813b85

View File

@ -729,12 +729,15 @@ static int ipneigh_get(int argc, char **argv)
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;
}