]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip neigh: Support --json on ip neigh get
authorLeonard Crestez <cdleonard@gmail.com>
Thu, 1 Dec 2022 21:41:05 +0000 (23:41 +0200)
committerDavid Ahern <dsahern@kernel.org>
Fri, 2 Dec 2022 15:54:28 +0000 (08:54 -0700)
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>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/ipneigh.c

index 61b0a4a22cbf90c7fd75b5358cebf1f0d0908442..0cf7bb60553aefd5d818bd5896e4dd056cb7cd40 100644 (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;
 }