netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* iproute2 ERSPAN version 2 JSON output shows valueless key
@ 2021-04-06  8:07 Christian Pössinger
  2021-04-06 16:28 ` [PATCH iproute2] erspan: fix JSON output Stephen Hemminger
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Pössinger @ 2021-04-06  8:07 UTC (permalink / raw)
  To: netdev

Dear Maintainers,

I am new to the reporting process for iproute2 thus please bear with me.

I am playing around with ERSPAN version 2 and noticed a valueless key on the
JSON output for iproute2. When creating an ERSPAN interface using the following
command:

$ ip link add dev myerspan type erspan seq key 30 local 192.168.1.4 \
  remote 192.168.1.1 erspan_ver 2 erspan_dir ingres
   
The interface is created - as expected - and also the information can be read
back in "human readable" format by:


$ ip -d link show myerspan
211: myerspan@NONE: <BROADCAST,MULTICAST> mtu 1460 qdisc noop state DOWN mode DEFAULT
    group default qlen 1000
    link/ether b6:e5:28:78:fa:54 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 0
    erspan remote 192.168.1.1 local 192.168.1.4 ttl inherit ikey 0.0.0.30 okey
	0.0.0.30 iseq oseq erspan_ver 2 erspan_dir ingress erspan_hwid 0 addrgenmode
	none numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535


This proper lists the key/value pair of "erspan_dir ingress".

When now switching to JSON output mode, the "erspan_dir" key won't have a
value. Output has been stripped to only contain the relevant keys in this structure:

$ ip -d -j link show myerspan
[{... "erspan_ver":2,"erspan_dir":"erspan_hwid":"0" ... }]

Both erspan_ver and erspan_hwid are populated with the proper values, but 
erspan_dir is a valueless key which will break most JSON parses (e.g. the one
from Python)

I have tested this with the following iproute2 versions:

iproute2-5.11.0
iproute2-5.9.0

If you can point me to the location which could be responsible for this issue,
I am happy to submit a fix to the net tree.

Thanks in advance,
Christian Poessinger

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

* [PATCH iproute2] erspan: fix JSON output
  2021-04-06  8:07 iproute2 ERSPAN version 2 JSON output shows valueless key Christian Pössinger
@ 2021-04-06 16:28 ` Stephen Hemminger
  2021-04-06 16:40   ` William Tu
  2021-04-09 10:49   ` [PATCH] erspan/erspan6: " Christian Poessinger
  0 siblings, 2 replies; 6+ messages in thread
From: Stephen Hemminger @ 2021-04-06 16:28 UTC (permalink / raw)
  To: Christian Pössinger; +Cc: netdev, Stephen Hemminger, u9012063

The format for erspan output is not valid JSON.
The direction should be value and erspan_dir should be the key.

Fixes: 289763626721 ("erspan: add erspan version II support")
Cc: u9012063@gmail.com
Reported-by: Christian Pössinger <christian@poessinger.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 ip/link_gre6.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 9d270f4b4455..f33598af8989 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -594,10 +594,10 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
 		if (erspan_dir == 0)
 			print_string(PRINT_ANY, "erspan_dir",
-				     "erspan_dir ingress ", NULL);
+				     "erspan_dir %s ", "ingress");
 		else
 			print_string(PRINT_ANY, "erspan_dir",
-				     "erspan_dir egress ", NULL);
+				     "erspan_dir %s ", "egress");
 	}
 
 	if (tb[IFLA_GRE_ERSPAN_HWID]) {
-- 
2.30.2


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

* Re: [PATCH iproute2] erspan: fix JSON output
  2021-04-06 16:28 ` [PATCH iproute2] erspan: fix JSON output Stephen Hemminger
@ 2021-04-06 16:40   ` William Tu
  2021-04-09 10:49   ` [PATCH] erspan/erspan6: " Christian Poessinger
  1 sibling, 0 replies; 6+ messages in thread
From: William Tu @ 2021-04-06 16:40 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Christian Pössinger, Linux Kernel Network Developers

On Tue, Apr 6, 2021 at 9:28 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> The format for erspan output is not valid JSON.
> The direction should be value and erspan_dir should be the key.
>
> Fixes: 289763626721 ("erspan: add erspan version II support")
> Cc: u9012063@gmail.com
> Reported-by: Christian Pössinger <christian@poessinger.com>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

LGTM, Thanks.
Acked-by: William Tu <u9012063@gmail.com>

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

* [PATCH] erspan/erspan6: fix JSON output
  2021-04-06 16:28 ` [PATCH iproute2] erspan: fix JSON output Stephen Hemminger
  2021-04-06 16:40   ` William Tu
@ 2021-04-09 10:49   ` Christian Poessinger
  2021-04-12 16:35     ` William Tu
  1 sibling, 1 reply; 6+ messages in thread
From: Christian Poessinger @ 2021-04-09 10:49 UTC (permalink / raw)
  To: stephen; +Cc: christian, netdev, u9012063

The format for erspan/erspan6 output is not valid JSON, as on version 2 a
valueless key was presented. The direction should be value and erspan_dir
should be the key.

Fixes: 289763626721 ("erspan: add erspan version II support")
Cc: u9012063@gmail.com
Cc: Stephen Hemminger <stephen@networkplumber.org>
Reported-by: Christian Poessinger <christian@poessinger.com>
Signed-off-by: Christian Poessinger <christian@poessinger.com>
---
 ip/link_gre.c  | 4 ++--
 ip/link_gre6.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ip/link_gre.c b/ip/link_gre.c
index 0461e5d0..6d4a8be8 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -536,10 +536,10 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
 		if (erspan_dir == 0)
 			print_string(PRINT_ANY, "erspan_dir",
-				     "erspan_dir ingress ", NULL);
+				     "erspan_dir %s ", "ingress");
 		else
 			print_string(PRINT_ANY, "erspan_dir",
-				     "erspan_dir egress ", NULL);
+				     "erspan_dir %s ", "egress");
 	}
 
 	if (tb[IFLA_GRE_ERSPAN_HWID]) {
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 9d270f4b..f33598af 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -594,10 +594,10 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
 		if (erspan_dir == 0)
 			print_string(PRINT_ANY, "erspan_dir",
-				     "erspan_dir ingress ", NULL);
+				     "erspan_dir %s ", "ingress");
 		else
 			print_string(PRINT_ANY, "erspan_dir",
-				     "erspan_dir egress ", NULL);
+				     "erspan_dir %s ", "egress");
 	}
 
 	if (tb[IFLA_GRE_ERSPAN_HWID]) {
-- 
2.20.1


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

* Re: [PATCH] erspan/erspan6: fix JSON output
  2021-04-09 10:49   ` [PATCH] erspan/erspan6: " Christian Poessinger
@ 2021-04-12 16:35     ` William Tu
  0 siblings, 0 replies; 6+ messages in thread
From: William Tu @ 2021-04-12 16:35 UTC (permalink / raw)
  To: Christian Poessinger; +Cc: Stephen Hemminger, Linux Kernel Network Developers

On Fri, Apr 9, 2021 at 3:50 AM Christian Poessinger
<christian@poessinger.com> wrote:
>
> The format for erspan/erspan6 output is not valid JSON, as on version 2 a
> valueless key was presented. The direction should be value and erspan_dir
> should be the key.
>
> Fixes: 289763626721 ("erspan: add erspan version II support")
> Cc: u9012063@gmail.com
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Reported-by: Christian Poessinger <christian@poessinger.com>
> Signed-off-by: Christian Poessinger <christian@poessinger.com>
> ---

LGTM, thanks
Acked-by: William Tu <u9012063@gmail.com>

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

* Re: [PATCH iproute2] erspan: fix JSON output
@ 2021-04-07  9:03 Christian Pössinger
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Pössinger @ 2021-04-07  9:03 UTC (permalink / raw)
  To: u9012063; +Cc: Christian Pössinger, netdev, stephen

On Tue, Apr 6, 2021 at 9:28 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> The format for erspan output is not valid JSON.
> The direction should be value and erspan_dir should be the key.
>
> Fixes: 289763626721 ("erspan: add erspan version II support")
> Cc: u9012063@gmail.com
> Reported-by: Christian Pössinger <christian@poessinger.com>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

I have rebuild iproute2 with the mentioned changes above but I can
not confirm this working. The behavior is still a missing value
for the JSON "erspan_dir" key.

--
Christian

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

end of thread, other threads:[~2021-04-12 16:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06  8:07 iproute2 ERSPAN version 2 JSON output shows valueless key Christian Pössinger
2021-04-06 16:28 ` [PATCH iproute2] erspan: fix JSON output Stephen Hemminger
2021-04-06 16:40   ` William Tu
2021-04-09 10:49   ` [PATCH] erspan/erspan6: " Christian Poessinger
2021-04-12 16:35     ` William Tu
2021-04-07  9:03 [PATCH iproute2] erspan: " Christian Pössinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).