From: Serhey Popovych <serhe.popovych@gmail.com>
To: netdev@vger.kernel.org
Cc: jbenc@redhat.com, u9012063@gmail.com, julien@cumulusnetworks.com
Subject: [PATCH iproute2-next 1/2] ip/tunnel: Be consistent when printing tunnel collect metadata
Date: Mon, 22 Jan 2018 18:46:53 +0200 [thread overview]
Message-ID: <1516639614-12960-2-git-send-email-serhe.popovych@gmail.com> (raw)
In-Reply-To: <1516639614-12960-1-git-send-email-serhe.popovych@gmail.com>
Print only "external" if collect meta data attribute
is given: rest of parameters are irrelevant. This is
to follow gre6.
For JSON output use "collect_metadata" for iptnl, ip6tnl and
gre to match with vxlan, geneve and gre6 modules.
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
ip/link_gre.c | 27 ++++++++++++---------------
ip/link_ip6tnl.c | 6 ++++--
ip/link_iptnl.c | 6 ++++--
3 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/ip/link_gre.c b/ip/link_gre.c
index 674603b..131a087 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -395,7 +395,7 @@ get_failed:
return 0;
}
-static void gre_print_direct_opt(FILE *f, struct rtattr *tb[])
+static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{
char s2[64];
const char *local = "any";
@@ -405,6 +405,14 @@ static void gre_print_direct_opt(FILE *f, struct rtattr *tb[])
__u8 ttl = 0;
__u8 tos = 0;
+ if (!tb)
+ return;
+
+ if (tb[IFLA_GRE_COLLECT_METADATA]) {
+ print_bool(PRINT_ANY, "collect_metadata", "external", true);
+ return;
+ }
+
if (tb[IFLA_GRE_REMOTE]) {
unsigned int addr = rta_getattr_u32(tb[IFLA_GRE_REMOTE]);
@@ -455,6 +463,9 @@ static void gre_print_direct_opt(FILE *f, struct rtattr *tb[])
print_bool(PRINT_JSON, "pmtudisc", NULL, true);
}
+ if (tb[IFLA_GRE_IGNORE_DF] && rta_getattr_u8(tb[IFLA_GRE_IGNORE_DF]))
+ print_bool(PRINT_ANY, "ignore_df", "ignore-df ", true);
+
if (tb[IFLA_GRE_IFLAGS])
iflags = rta_getattr_u16(tb[IFLA_GRE_IFLAGS]);
@@ -488,20 +499,6 @@ static void gre_print_direct_opt(FILE *f, struct rtattr *tb[])
"fwmark", "fwmark 0x%x ", fwmark);
}
}
-}
-
-static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
-{
- if (!tb)
- return;
-
- if (!tb[IFLA_GRE_COLLECT_METADATA])
- gre_print_direct_opt(f, tb);
- else
- print_bool(PRINT_ANY, "external", "external ", true);
-
- if (tb[IFLA_GRE_IGNORE_DF] && rta_getattr_u8(tb[IFLA_GRE_IGNORE_DF]))
- print_bool(PRINT_ANY, "ignore_df", "ignore-df ", true);
if (tb[IFLA_GRE_ERSPAN_INDEX]) {
__u32 erspan_idx = rta_getattr_u32(tb[IFLA_GRE_ERSPAN_INDEX]);
diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
index 8f5c9bd..e4db643 100644
--- a/ip/link_ip6tnl.c
+++ b/ip/link_ip6tnl.c
@@ -341,8 +341,10 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
if (!tb)
return;
- if (tb[IFLA_IPTUN_COLLECT_METADATA])
- print_bool(PRINT_ANY, "external", "external ", true);
+ if (tb[IFLA_IPTUN_COLLECT_METADATA]) {
+ print_bool(PRINT_ANY, "collect_metadata", "external", true);
+ return;
+ }
if (tb[IFLA_IPTUN_FLAGS])
flags = rta_getattr_u32(tb[IFLA_IPTUN_FLAGS]);
diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
index ce3855c..93a1eb4 100644
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -370,8 +370,10 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
if (!tb)
return;
- if (tb[IFLA_IPTUN_COLLECT_METADATA])
- print_bool(PRINT_ANY, "external", "external ", true);
+ if (tb[IFLA_IPTUN_COLLECT_METADATA]) {
+ print_bool(PRINT_ANY, "collect_metadata", "external", true);
+ return;
+ }
if (tb[IFLA_IPTUN_PROTO]) {
switch (rta_getattr_u8(tb[IFLA_IPTUN_PROTO])) {
--
1.7.10.4
next prev parent reply other threads:[~2018-01-22 16:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-22 16:46 [PATCH iproute2-next 0/2] ip/tunnel: Unify collect metadata handling Serhey Popovych
2018-01-22 16:46 ` Serhey Popovych [this message]
2018-01-22 16:58 ` [PATCH iproute2-next 1/2] ip/tunnel: Be consistent when printing tunnel collect metadata Jiri Benc
2018-01-22 17:00 ` Serhey Popovych
2018-01-22 16:46 ` [PATCH iproute2-next 2/2] gre/gre6: Unify attribute addition to netlink buffer 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=1516639614-12960-2-git-send-email-serhe.popovych@gmail.com \
--to=serhe.popovych@gmail.com \
--cc=jbenc@redhat.com \
--cc=julien@cumulusnetworks.com \
--cc=netdev@vger.kernel.org \
--cc=u9012063@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.