|
|
268297 |
From 2ed28d2a92d05a4a1d8bd98dab1607741202f4a3 Mon Sep 17 00:00:00 2001
|
|
|
268297 |
From: Michal Kubecek <mkubecek@suse.cz>
|
|
|
268297 |
Date: Mon, 19 Oct 2020 23:32:43 +0200
|
|
|
268297 |
Subject: [PATCH 35/37] netlink: support 64-bit attribute types in pretty
|
|
|
268297 |
printed messages
|
|
|
268297 |
|
|
|
268297 |
Add NLA_U64 (unsigned), NLA_X64 (unsigned, printed as hex) and NLA_S64
|
|
|
268297 |
(signed) attribute types in pretty printing code.
|
|
|
268297 |
|
|
|
268297 |
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
|
|
|
268297 |
(cherry picked from commit 0f5f1bacee2bfb0b29fe037f8236b3cd714fb10e)
|
|
|
268297 |
---
|
|
|
268297 |
netlink/prettymsg.c | 10 ++++++++++
|
|
|
268297 |
netlink/prettymsg.h | 6 ++++++
|
|
|
268297 |
2 files changed, 16 insertions(+)
|
|
|
268297 |
|
|
|
268297 |
diff --git a/netlink/prettymsg.c b/netlink/prettymsg.c
|
|
|
268297 |
index d5d999fddfbb..0a1fae3da54e 100644
|
|
|
268297 |
--- a/netlink/prettymsg.c
|
|
|
268297 |
+++ b/netlink/prettymsg.c
|
|
|
268297 |
@@ -9,6 +9,7 @@
|
|
|
268297 |
#include <errno.h>
|
|
|
268297 |
#include <stdint.h>
|
|
|
268297 |
#include <limits.h>
|
|
|
268297 |
+#include <inttypes.h>
|
|
|
268297 |
#include <linux/genetlink.h>
|
|
|
268297 |
#include <linux/rtnetlink.h>
|
|
|
268297 |
#include <linux/if_link.h>
|
|
|
268297 |
@@ -110,6 +111,9 @@ static int pretty_print_attr(const struct nlattr *attr,
|
|
|
268297 |
case NLA_U32:
|
|
|
268297 |
printf("%u", mnl_attr_get_u32(attr));
|
|
|
268297 |
break;
|
|
|
268297 |
+ case NLA_U64:
|
|
|
268297 |
+ printf("%" PRIu64, mnl_attr_get_u64(attr));
|
|
|
268297 |
+ break;
|
|
|
268297 |
case NLA_X8:
|
|
|
268297 |
printf("0x%02x", mnl_attr_get_u8(attr));
|
|
|
268297 |
break;
|
|
|
268297 |
@@ -119,6 +123,9 @@ static int pretty_print_attr(const struct nlattr *attr,
|
|
|
268297 |
case NLA_X32:
|
|
|
268297 |
printf("0x%08x", mnl_attr_get_u32(attr));
|
|
|
268297 |
break;
|
|
|
268297 |
+ case NLA_X64:
|
|
|
268297 |
+ printf("%" PRIx64, mnl_attr_get_u64(attr));
|
|
|
268297 |
+ break;
|
|
|
268297 |
case NLA_S8:
|
|
|
268297 |
printf("%d", (int)mnl_attr_get_u8(attr));
|
|
|
268297 |
break;
|
|
|
268297 |
@@ -128,6 +135,9 @@ static int pretty_print_attr(const struct nlattr *attr,
|
|
|
268297 |
case NLA_S32:
|
|
|
268297 |
printf("%d", (int)mnl_attr_get_u32(attr));
|
|
|
268297 |
break;
|
|
|
268297 |
+ case NLA_S64:
|
|
|
268297 |
+ printf("%" PRId64, (int64_t)mnl_attr_get_u64(attr));
|
|
|
268297 |
+ break;
|
|
|
268297 |
case NLA_STRING:
|
|
|
268297 |
printf("\"%.*s\"", alen, (const char *)adata);
|
|
|
268297 |
break;
|
|
|
268297 |
diff --git a/netlink/prettymsg.h b/netlink/prettymsg.h
|
|
|
268297 |
index 6987c6ec5bca..25990cceffca 100644
|
|
|
268297 |
--- a/netlink/prettymsg.h
|
|
|
268297 |
+++ b/netlink/prettymsg.h
|
|
|
268297 |
@@ -17,12 +17,15 @@ enum pretty_nla_format {
|
|
|
268297 |
NLA_U8,
|
|
|
268297 |
NLA_U16,
|
|
|
268297 |
NLA_U32,
|
|
|
268297 |
+ NLA_U64,
|
|
|
268297 |
NLA_X8,
|
|
|
268297 |
NLA_X16,
|
|
|
268297 |
NLA_X32,
|
|
|
268297 |
+ NLA_X64,
|
|
|
268297 |
NLA_S8,
|
|
|
268297 |
NLA_S16,
|
|
|
268297 |
NLA_S32,
|
|
|
268297 |
+ NLA_S64,
|
|
|
268297 |
NLA_STRING,
|
|
|
268297 |
NLA_FLAG,
|
|
|
268297 |
NLA_BOOL,
|
|
|
268297 |
@@ -62,12 +65,15 @@ struct pretty_nlmsg_desc {
|
|
|
268297 |
#define NLATTR_DESC_U8(_name) NLATTR_DESC(_name, NLA_U8)
|
|
|
268297 |
#define NLATTR_DESC_U16(_name) NLATTR_DESC(_name, NLA_U16)
|
|
|
268297 |
#define NLATTR_DESC_U32(_name) NLATTR_DESC(_name, NLA_U32)
|
|
|
268297 |
+#define NLATTR_DESC_U64(_name) NLATTR_DESC(_name, NLA_U64)
|
|
|
268297 |
#define NLATTR_DESC_X8(_name) NLATTR_DESC(_name, NLA_X8)
|
|
|
268297 |
#define NLATTR_DESC_X16(_name) NLATTR_DESC(_name, NLA_X16)
|
|
|
268297 |
#define NLATTR_DESC_X32(_name) NLATTR_DESC(_name, NLA_X32)
|
|
|
268297 |
+#define NLATTR_DESC_X64(_name) NLATTR_DESC(_name, NLA_X64)
|
|
|
268297 |
#define NLATTR_DESC_S8(_name) NLATTR_DESC(_name, NLA_U8)
|
|
|
268297 |
#define NLATTR_DESC_S16(_name) NLATTR_DESC(_name, NLA_U16)
|
|
|
268297 |
#define NLATTR_DESC_S32(_name) NLATTR_DESC(_name, NLA_U32)
|
|
|
268297 |
+#define NLATTR_DESC_S64(_name) NLATTR_DESC(_name, NLA_S64)
|
|
|
268297 |
#define NLATTR_DESC_STRING(_name) NLATTR_DESC(_name, NLA_STRING)
|
|
|
268297 |
#define NLATTR_DESC_FLAG(_name) NLATTR_DESC(_name, NLA_FLAG)
|
|
|
268297 |
#define NLATTR_DESC_BOOL(_name) NLATTR_DESC(_name, NLA_BOOL)
|
|
|
268297 |
--
|
|
|
268297 |
2.26.2
|
|
|
268297 |
|