From: Serhey Popovych <serhe.popovych@gmail.com>
To: netdev@vger.kernel.org
Subject: [PATCH iproute2 8/9] vti/tunnel: Unify ikey/okey printing
Date: Fri, 12 Jan 2018 19:39:33 +0200 [thread overview]
Message-ID: <1515778774-24173-9-git-send-email-serhe.popovych@gmail.com> (raw)
In-Reply-To: <1515778774-24173-1-git-send-email-serhe.popovych@gmail.com>
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@gmail.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
next prev parent reply other threads:[~2018-01-12 17:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 17:39 [PATCH iproute2 0/9] ip/tunnel: Improve tunnel parameters printing Serhey Popovych
2018-01-12 17:39 ` [PATCH iproute2 1/9] iplink: Use ll_index_to_name() instead of if_indextoname() Serhey Popovych
2018-01-17 18:53 ` Stephen Hemminger
2018-01-12 17:39 ` [PATCH iproute2 2/9] ip/tunnel: Correct and unify ttl/hoplimit printing Serhey Popovych
2018-01-12 17:39 ` [PATCH iproute2 3/9] ip/tunnel: Simplify and unify tos printing Serhey Popovych
2018-01-12 17:39 ` [PATCH iproute2 4/9] ip/tunnel: Use print_0xhex() instead of print_string() Serhey Popovych
2018-01-12 17:39 ` [PATCH iproute2 5/9] ip/tunnel: Use print_string() and simplify encap option printing Serhey Popovych
2018-01-12 17:39 ` [PATCH iproute2 6/9] gre/tunnel: Print erspan_index using print_uint() Serhey Popovych
2018-01-12 17:39 ` [PATCH iproute2 7/9] ip/tunnel: Minor cleanups in print routines Serhey Popovych
2018-01-12 17:39 ` Serhey Popovych [this message]
2018-01-12 17:39 ` [PATCH iproute2 9/9] vti6/tunnel: Unify and simplify link type help functions Serhey Popovych
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1515778774-24173-9-git-send-email-serhe.popovych@gmail.com \
--to=serhe.popovych@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).