All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] json: make 0xhex handle u64
@ 2018-10-12 15:34 Sabrina Dubroca
  2018-10-15 16:34 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Sabrina Dubroca @ 2018-10-12 15:34 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger, Sabrina Dubroca, David Ahern

Stephen converted macsec's sci to use 0xhex, but 0xhex handles
unsigned int's, not 64 bits ints. Thus, the output of the "ip macsec
show" command is mangled, with half of the SCI replaced with 0s:

# ip macsec show
11: macsec0: [...]
    cipher suite: GCM-AES-128, using ICV length 16
    TXSC: 0000000001560001 on SA 0

# ip -d link show macsec0
11: macsec0@ens3: [...]
    link/ether 52:54:00:12:01:56 brd ff:ff:ff:ff:ff:ff promiscuity 0 
    macsec sci 5254001201560001 [...]

where TXSC and sci should match.

Fixes: c0b904de6211 ("macsec: support JSON")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 include/json_print.h | 2 +-
 lib/json_print.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/json_print.h b/include/json_print.h
index 78a6c83fb516..218da31a73fe 100644
--- a/include/json_print.h
+++ b/include/json_print.h
@@ -66,7 +66,7 @@ _PRINT_FUNC(uint, unsigned int);
 _PRINT_FUNC(u64, uint64_t);
 _PRINT_FUNC(hu, unsigned short);
 _PRINT_FUNC(hex, unsigned int);
-_PRINT_FUNC(0xhex, unsigned int);
+_PRINT_FUNC(0xhex, unsigned long long int);
 _PRINT_FUNC(luint, unsigned long int);
 _PRINT_FUNC(lluint, unsigned long long int);
 _PRINT_FUNC(float, double);
diff --git a/lib/json_print.c b/lib/json_print.c
index eed109c56401..f7ef41c1570f 100644
--- a/lib/json_print.c
+++ b/lib/json_print.c
@@ -172,12 +172,12 @@ void print_color_0xhex(enum output_type type,
 		       enum color_attr color,
 		       const char *key,
 		       const char *fmt,
-		       unsigned int hex)
+		       unsigned long long hex)
 {
 	if (_IS_JSON_CONTEXT(type)) {
 		SPRINT_BUF(b1);
 
-		snprintf(b1, sizeof(b1), "%#x", hex);
+		snprintf(b1, sizeof(b1), "%#llx", hex);
 		print_string(PRINT_JSON, key, NULL, b1);
 	} else if (_IS_FP_CONTEXT(type)) {
 		color_fprintf(stdout, color, fmt, hex);
-- 
2.19.1

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

* Re: [PATCH iproute2] json: make 0xhex handle u64
  2018-10-12 15:34 [PATCH iproute2] json: make 0xhex handle u64 Sabrina Dubroca
@ 2018-10-15 16:34 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2018-10-15 16:34 UTC (permalink / raw)
  To: Sabrina Dubroca; +Cc: netdev, David Ahern

On Fri, 12 Oct 2018 17:34:32 +0200
Sabrina Dubroca <sd@queasysnail.net> wrote:

> Stephen converted macsec's sci to use 0xhex, but 0xhex handles
> unsigned int's, not 64 bits ints. Thus, the output of the "ip macsec
> show" command is mangled, with half of the SCI replaced with 0s:
> 
> # ip macsec show
> 11: macsec0: [...]
>     cipher suite: GCM-AES-128, using ICV length 16
>     TXSC: 0000000001560001 on SA 0
> 
> # ip -d link show macsec0
> 11: macsec0@ens3: [...]
>     link/ether 52:54:00:12:01:56 brd ff:ff:ff:ff:ff:ff promiscuity 0 
>     macsec sci 5254001201560001 [...]
> 
> where TXSC and sci should match.
> 
> Fixes: c0b904de6211 ("macsec: support JSON")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>

Thanks for finding this. We should add JSON (and macsec) to tests.

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

end of thread, other threads:[~2018-10-16  0:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12 15:34 [PATCH iproute2] json: make 0xhex handle u64 Sabrina Dubroca
2018-10-15 16:34 ` Stephen Hemminger

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.