]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
mptcp: fix JSON output when dumping endpoints by id
authorDavide Caratti <dcaratti@redhat.com>
Thu, 11 Nov 2021 09:52:13 +0000 (10:52 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 11 Nov 2021 18:07:26 +0000 (10:07 -0800)
iproute ignores '-j' command line argument when dumping endpoints by id:

 [dcaratti@dcaratti iproute2]$ ./ip/ip -j mptcp endpoint show
 [{"address":"1.2.3.4","id":42,"signal":true,"backup":true}]
 [dcaratti@dcaratti iproute2]$ ./ip/ip -j mptcp endpoint show id 42
 1.2.3.4 id 42 signal backup

fix mptcp_addr_show() to use the proper JSON helpers.

Fixes: 7e0767cd862b ("add support for mptcp netlink interface")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Acked-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/ipmptcp.c

index 0f5b6e2d08ba65ed714e9ffe722a56070e1ed9fa..857004446aa340c0192ee53b89c0189a8f99dd68 100644 (file)
@@ -305,7 +305,11 @@ static int mptcp_addr_show(int argc, char **argv)
        if (rtnl_talk(&genl_rth, &req.n, &answer) < 0)
                return -2;
 
-       return print_mptcp_addr(answer, stdout);
+       new_json_obj(json);
+       ret = print_mptcp_addr(answer, stdout);
+       delete_json_obj();
+       fflush(stdout);
+       return ret;
 }
 
 static int mptcp_addr_flush(int argc, char **argv)