naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

Blame SOURCES/0021-json-make-0xhex-handle-u64.patch

930fb9
From 9822fef7a13eaec70be8e86c23bdb71569835bd0 Mon Sep 17 00:00:00 2001
930fb9
From: Phil Sutter <psutter@redhat.com>
930fb9
Date: Thu, 18 Oct 2018 12:49:51 +0200
930fb9
Subject: [PATCH] json: make 0xhex handle u64
930fb9
930fb9
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1628428
930fb9
Upstream Status: iproute2.git commit 45ec4771d40cb
930fb9
930fb9
commit 45ec4771d40cb367377e4148a2af22f25c20f3bf
930fb9
Author: Sabrina Dubroca <sd@queasysnail.net>
930fb9
Date:   Fri Oct 12 17:34:32 2018 +0200
930fb9
930fb9
    json: make 0xhex handle u64
930fb9
930fb9
    Stephen converted macsec's sci to use 0xhex, but 0xhex handles
930fb9
    unsigned int's, not 64 bits ints. Thus, the output of the "ip macsec
930fb9
    show" command is mangled, with half of the SCI replaced with 0s:
930fb9
930fb9
    # ip macsec show
930fb9
    11: macsec0: [...]
930fb9
        cipher suite: GCM-AES-128, using ICV length 16
930fb9
        TXSC: 0000000001560001 on SA 0
930fb9
930fb9
    # ip -d link show macsec0
930fb9
    11: macsec0@ens3: [...]
930fb9
        link/ether 52:54:00:12:01:56 brd ff:ff:ff:ff:ff:ff promiscuity 0
930fb9
        macsec sci 5254001201560001 [...]
930fb9
930fb9
    where TXSC and sci should match.
930fb9
930fb9
    Fixes: c0b904de6211 ("macsec: support JSON")
930fb9
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
930fb9
    Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
930fb9
---
930fb9
 include/json_print.h | 2 +-
930fb9
 lib/json_print.c     | 4 ++--
930fb9
 2 files changed, 3 insertions(+), 3 deletions(-)
930fb9
930fb9
diff --git a/include/json_print.h b/include/json_print.h
930fb9
index 78a6c83..218da31 100644
930fb9
--- a/include/json_print.h
930fb9
+++ b/include/json_print.h
930fb9
@@ -66,7 +66,7 @@ _PRINT_FUNC(uint, unsigned int);
930fb9
 _PRINT_FUNC(u64, uint64_t);
930fb9
 _PRINT_FUNC(hu, unsigned short);
930fb9
 _PRINT_FUNC(hex, unsigned int);
930fb9
-_PRINT_FUNC(0xhex, unsigned int);
930fb9
+_PRINT_FUNC(0xhex, unsigned long long int);
930fb9
 _PRINT_FUNC(luint, unsigned long int);
930fb9
 _PRINT_FUNC(lluint, unsigned long long int);
930fb9
 _PRINT_FUNC(float, double);
930fb9
diff --git a/lib/json_print.c b/lib/json_print.c
930fb9
index 09e51d0..cf13e9b 100644
930fb9
--- a/lib/json_print.c
930fb9
+++ b/lib/json_print.c
930fb9
@@ -171,12 +171,12 @@ void print_color_0xhex(enum output_type type,
930fb9
 		       enum color_attr color,
930fb9
 		       const char *key,
930fb9
 		       const char *fmt,
930fb9
-		       unsigned int hex)
930fb9
+		       unsigned long long hex)
930fb9
 {
930fb9
 	if (_IS_JSON_CONTEXT(type)) {
930fb9
 		SPRINT_BUF(b1);
930fb9
 
930fb9
-		snprintf(b1, sizeof(b1), "%#x", hex);
930fb9
+		snprintf(b1, sizeof(b1), "%#llx", hex);
930fb9
 		print_string(PRINT_JSON, key, NULL, b1);
930fb9
 	} else if (_IS_FP_CONTEXT(type)) {
930fb9
 		color_fprintf(stdout, color, fmt, hex);
930fb9
-- 
930fb9
1.8.3.1
930fb9