lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 12 Jan 2018 19:39:33 +0200
From:   Serhey Popovych <serhe.popovych@...il.com>
To:     netdev@...r.kernel.org
Subject: [PATCH iproute2 8/9] vti/tunnel: Unify ikey/okey printing

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 <serhe.popovych@...il.com>
---
 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

Powered by blists - more mailing lists