From patchwork Mon Oct 19 21:32:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kubecek X-Patchwork-Id: 288308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31D83C433DF for ; Mon, 19 Oct 2020 21:32:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDC0B2224D for ; Mon, 19 Oct 2020 21:32:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733094AbgJSVcq (ORCPT ); Mon, 19 Oct 2020 17:32:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:41452 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733061AbgJSVcp (ORCPT ); Mon, 19 Oct 2020 17:32:45 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 274ADAD11; Mon, 19 Oct 2020 21:32:44 +0000 (UTC) Received: by lion.mk-sys.cz (Postfix, from userid 1000) id E118760563; Mon, 19 Oct 2020 23:32:43 +0200 (CEST) Message-Id: <1193886b3994f75c86327b09e6e1a966413181e1.1603142897.git.mkubecek@suse.cz> In-Reply-To: References: From: Michal Kubecek Subject: [PATCH ethtool 2/4] netlink: support 64-bit attribute types in pretty printed messages To: netdev@vger.kernel.org Cc: Jakub Kicinski Date: Mon, 19 Oct 2020 23:32:43 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add NLA_U64 (unsigned), NLA_X64 (unsigned, printed as hex) and NLA_S64 (signed) attribute types in pretty printing code. Signed-off-by: Michal Kubecek --- netlink/prettymsg.c | 10 ++++++++++ netlink/prettymsg.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/netlink/prettymsg.c b/netlink/prettymsg.c index d5d999fddfbb..0a1fae3da54e 100644 --- a/netlink/prettymsg.c +++ b/netlink/prettymsg.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -110,6 +111,9 @@ static int pretty_print_attr(const struct nlattr *attr, case NLA_U32: printf("%u", mnl_attr_get_u32(attr)); break; + case NLA_U64: + printf("%" PRIu64, mnl_attr_get_u64(attr)); + break; case NLA_X8: printf("0x%02x", mnl_attr_get_u8(attr)); break; @@ -119,6 +123,9 @@ static int pretty_print_attr(const struct nlattr *attr, case NLA_X32: printf("0x%08x", mnl_attr_get_u32(attr)); break; + case NLA_X64: + printf("%" PRIx64, mnl_attr_get_u64(attr)); + break; case NLA_S8: printf("%d", (int)mnl_attr_get_u8(attr)); break; @@ -128,6 +135,9 @@ static int pretty_print_attr(const struct nlattr *attr, case NLA_S32: printf("%d", (int)mnl_attr_get_u32(attr)); break; + case NLA_S64: + printf("%" PRId64, (int64_t)mnl_attr_get_u64(attr)); + break; case NLA_STRING: printf("\"%.*s\"", alen, (const char *)adata); break; diff --git a/netlink/prettymsg.h b/netlink/prettymsg.h index 6987c6ec5bca..25990cceffca 100644 --- a/netlink/prettymsg.h +++ b/netlink/prettymsg.h @@ -17,12 +17,15 @@ enum pretty_nla_format { NLA_U8, NLA_U16, NLA_U32, + NLA_U64, NLA_X8, NLA_X16, NLA_X32, + NLA_X64, NLA_S8, NLA_S16, NLA_S32, + NLA_S64, NLA_STRING, NLA_FLAG, NLA_BOOL, @@ -62,12 +65,15 @@ struct pretty_nlmsg_desc { #define NLATTR_DESC_U8(_name) NLATTR_DESC(_name, NLA_U8) #define NLATTR_DESC_U16(_name) NLATTR_DESC(_name, NLA_U16) #define NLATTR_DESC_U32(_name) NLATTR_DESC(_name, NLA_U32) +#define NLATTR_DESC_U64(_name) NLATTR_DESC(_name, NLA_U64) #define NLATTR_DESC_X8(_name) NLATTR_DESC(_name, NLA_X8) #define NLATTR_DESC_X16(_name) NLATTR_DESC(_name, NLA_X16) #define NLATTR_DESC_X32(_name) NLATTR_DESC(_name, NLA_X32) +#define NLATTR_DESC_X64(_name) NLATTR_DESC(_name, NLA_X64) #define NLATTR_DESC_S8(_name) NLATTR_DESC(_name, NLA_U8) #define NLATTR_DESC_S16(_name) NLATTR_DESC(_name, NLA_U16) #define NLATTR_DESC_S32(_name) NLATTR_DESC(_name, NLA_U32) +#define NLATTR_DESC_S64(_name) NLATTR_DESC(_name, NLA_S64) #define NLATTR_DESC_STRING(_name) NLATTR_DESC(_name, NLA_STRING) #define NLATTR_DESC_FLAG(_name) NLATTR_DESC(_name, NLA_FLAG) #define NLATTR_DESC_BOOL(_name) NLATTR_DESC(_name, NLA_BOOL)