All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] mptcp: fix JSON output when dumping endpoints by id
@ 2021-11-11  9:52 ` Davide Caratti
  0 siblings, 0 replies; 3+ messages in thread
From: Davide Caratti @ 2021-11-11  9:35 UTC (permalink / raw)
  To: pabeni, aclaudi, Matthieu Baerts, Stephen Hemminger; +Cc: mptcp, netdev

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>
---
 ip/ipmptcp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c
index 0f5b6e2d08ba..857004446aa3 100644
--- a/ip/ipmptcp.c
+++ b/ip/ipmptcp.c
@@ -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)
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH iproute2] mptcp: fix JSON output when dumping endpoints by id
@ 2021-11-11  9:52 ` Davide Caratti
  0 siblings, 0 replies; 3+ messages in thread
From: Davide Caratti @ 2021-11-11  9:52 UTC (permalink / raw)
  To: netdev

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>
---
 ip/ipmptcp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c
index 0f5b6e2d08ba..857004446aa3 100644
--- a/ip/ipmptcp.c
+++ b/ip/ipmptcp.c
@@ -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)
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2] mptcp: fix JSON output when dumping endpoints by id
  2021-11-11  9:52 ` Davide Caratti
  (?)
@ 2021-11-11 10:47 ` Andrea Claudi
  -1 siblings, 0 replies; 3+ messages in thread
From: Andrea Claudi @ 2021-11-11 10:47 UTC (permalink / raw)
  To: Davide Caratti; +Cc: netdev

On Thu, Nov 11, 2021 at 10:52:13AM +0100, Davide Caratti wrote:
> 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>
> ---
>  ip/ipmptcp.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c
> index 0f5b6e2d08ba..857004446aa3 100644
> --- a/ip/ipmptcp.c
> +++ b/ip/ipmptcp.c
> @@ -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)
> -- 
> 2.31.1

Looks good to me.
Acked-by: Andrea Claudi <aclaudi@redhat.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-11 10:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11  9:35 [PATCH iproute2] mptcp: fix JSON output when dumping endpoints by id Davide Caratti
2021-11-11  9:52 ` Davide Caratti
2021-11-11 10:47 ` Andrea Claudi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.