From mboxrd@z Thu Jan 1 00:00:00 1970 From: Serhey Popovych Subject: [PATCH iproute2 8/9] vti/tunnel: Unify ikey/okey printing Date: Fri, 12 Jan 2018 19:39:33 +0200 Message-ID: <1515778774-24173-9-git-send-email-serhe.popovych@gmail.com> References: <1515778774-24173-1-git-send-email-serhe.popovych@gmail.com> To: netdev@vger.kernel.org Return-path: Received: from mail-lf0-f68.google.com ([209.85.215.68]:46007 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964926AbeALRkF (ORCPT ); Fri, 12 Jan 2018 12:40:05 -0500 Received: by mail-lf0-f68.google.com with SMTP id y71so6750585lfd.12 for ; Fri, 12 Jan 2018 09:40:04 -0800 (PST) Received: from tuxracer.localdomain ([2a01:6d80::195:20:96:53]) by smtp.gmail.com with ESMTPSA id c190sm3781968lfc.81.2018.01.12.09.40.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 09:40:03 -0800 (PST) In-Reply-To: <1515778774-24173-1-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: For vti6 tunnel we print [io]key in dotted-quad notation (ipv4 address) while in vti we do that in hex format. For vti tunnel we print [io]key only if value is not zero while for vti6 we miss such check. Unify vti and vti6 tunnel [io]key output. While here enlarge s2 buffer to the same size as in rest of tunnel support code (64 bytes). Signed-off-by: Serhey Popovych --- ip/link_vti.c | 15 +++++++++------ ip/link_vti6.c | 7 +++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ip/link_vti.c b/ip/link_vti.c index eebf542..5fccf74 100644 --- a/ip/link_vti.c +++ b/ip/link_vti.c @@ -170,7 +170,7 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) __u32 key; __u32 fwmark; unsigned int link; - char s2[IFNAMSIZ]; + char s2[64]; if (!tb) return; @@ -201,13 +201,16 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) } if (tb[IFLA_VTI_IKEY] && - (key = rta_getattr_u32(tb[IFLA_VTI_IKEY]))) - print_0xhex(PRINT_ANY, "ikey", "ikey %#x ", ntohl(key)); - + (key = rta_getattr_u32(tb[IFLA_VTI_IKEY]))) { + inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_IKEY]), s2, sizeof(s2)); + print_string(PRINT_ANY, "ikey", "ikey %s ", s2); + } if (tb[IFLA_VTI_OKEY] && - (key = rta_getattr_u32(tb[IFLA_VTI_OKEY]))) - print_0xhex(PRINT_ANY, "okey", "okey %#x ", ntohl(key)); + (key = rta_getattr_u32(tb[IFLA_VTI_OKEY]))) { + inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_OKEY]), s2, sizeof(s2)); + print_string(PRINT_ANY, "okey", "okey %s ", s2); + } if (tb[IFLA_VTI_FWMARK] && (fwmark = rta_getattr_u32(tb[IFLA_VTI_FWMARK]))) diff --git a/ip/link_vti6.c b/ip/link_vti6.c index 29a7062..a4ad650 100644 --- a/ip/link_vti6.c +++ b/ip/link_vti6.c @@ -168,6 +168,7 @@ static void vti6_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) const char *remote = "any"; struct in6_addr saddr; struct in6_addr daddr; + __u32 key; __u32 fwmark; unsigned int link; char s2[64]; @@ -198,12 +199,14 @@ static void vti6_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) print_string(PRINT_ANY, "link", "dev %s ", n); } - if (tb[IFLA_VTI_IKEY]) { + if (tb[IFLA_VTI_IKEY] && + (key = rta_getattr_u32(tb[IFLA_VTI_IKEY]))) { inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_IKEY]), s2, sizeof(s2)); print_string(PRINT_ANY, "ikey", "ikey %s ", s2); } - if (tb[IFLA_VTI_OKEY]) { + if (tb[IFLA_VTI_OKEY] && + (key = rta_getattr_u32(tb[IFLA_VTI_OKEY]))) { inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_OKEY]), s2, sizeof(s2)); print_string(PRINT_ANY, "okey", "okey %s ", s2); } -- 1.7.10.4