]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip/tunnel: Be consistent when printing tunnel collect metadata
authorSerhey Popovych <serhe.popovych@gmail.com>
Mon, 22 Jan 2018 17:23:45 +0000 (19:23 +0200)
committerDavid Ahern <dsahern@gmail.com>
Wed, 24 Jan 2018 18:01:26 +0000 (10:01 -0800)
Print only "external" if collect meta data attribute
is given: rest of parameters are irrelevant. This is
to follow gre6.

For both JSON and non-JSON output use "external" for
all tunnels including vxlan and geneve.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
ip/iplink_geneve.c
ip/iplink_vxlan.c
ip/link_gre.c
ip/link_gre6.c
ip/link_ip6tnl.c
ip/link_iptnl.c

index 1c28bb9cb5e0c7ae2d2632331e7d0d6d74c8b3ef..c66607267f7d1c618d3e2dd184c64792f9e40a2e 100644 (file)
@@ -230,6 +230,11 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
        if (!tb)
                return;
 
+       if (tb[IFLA_GENEVE_COLLECT_METADATA]) {
+               print_bool(PRINT_ANY, "external", "external", true);
+               return;
+       }
+
        if (!tb[IFLA_GENEVE_ID] ||
            RTA_PAYLOAD(tb[IFLA_GENEVE_ID]) < sizeof(__u32))
                return;
@@ -292,9 +297,6 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                           "dstport %u ",
                           rta_getattr_be16(tb[IFLA_GENEVE_PORT]));
 
-       if (tb[IFLA_GENEVE_COLLECT_METADATA])
-               print_bool(PRINT_ANY, "collect_metadata", "external ", true);
-
        if (tb[IFLA_GENEVE_UDP_CSUM]) {
                if (is_json_context()) {
                        print_bool(PRINT_JSON,
index ad03ffb640cf18acee5b7336d6a17bc2e5a7c566..00875ba73cb4066e45af60f915c384714eeeba71 100644 (file)
@@ -381,6 +381,12 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
        if (!tb)
                return;
 
+       if (tb[IFLA_VXLAN_COLLECT_METADATA] &&
+           rta_getattr_u8(tb[IFLA_VXLAN_COLLECT_METADATA])) {
+               print_bool(PRINT_ANY, "external", "external", true);
+               return;
+       }
+
        if (!tb[IFLA_VXLAN_ID] ||
            RTA_PAYLOAD(tb[IFLA_VXLAN_ID]) < sizeof(__u32))
                return;
@@ -582,10 +588,6 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
            rta_getattr_u8(tb[IFLA_VXLAN_REMCSUM_RX]))
                print_bool(PRINT_ANY, "remcsum_rx", "remcsumrx ", true);
 
-       if (tb[IFLA_VXLAN_COLLECT_METADATA] &&
-           rta_getattr_u8(tb[IFLA_VXLAN_COLLECT_METADATA]))
-               print_bool(PRINT_ANY, "collect_metadata", "external ", true);
-
        if (tb[IFLA_VXLAN_GBP])
                print_bool(PRINT_ANY, "gbp", "gbp ", true);
        if (tb[IFLA_VXLAN_GPE])
index 850eddb74cd6a008960685d3c984de00ad43d8be..c7e65fcfade63dab7a018b5e1ac60efb6eb495d2 100644 (file)
@@ -391,7 +391,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";
@@ -401,6 +401,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, "external", "external", true);
+               return;
+       }
+
        if (tb[IFLA_GRE_REMOTE]) {
                unsigned int addr = rta_getattr_u32(tb[IFLA_GRE_REMOTE]);
 
@@ -451,6 +459,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]);
 
@@ -484,20 +495,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]);
index bb196494cde65edeba940dcf9db8c3b3d57928b5..3500b529aac86d8b964bfe2ed14a2a83d9bd2323 100644 (file)
@@ -439,7 +439,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                return;
 
        if (tb[IFLA_GRE_COLLECT_METADATA]) {
-               print_bool(PRINT_ANY, "collect_metadata", "external", true);
+               print_bool(PRINT_ANY, "external", "external", true);
                return;
        }
 
index fdf113e032c320d81bf3ac8e1f86f0997a30de90..ce3bcdec4b39fbb1099d00d6125676fd14c2940c 100644 (file)
@@ -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, "external", "external", true);
+               return;
+       }
 
        if (tb[IFLA_IPTUN_FLAGS])
                flags = rta_getattr_u32(tb[IFLA_IPTUN_FLAGS]);
index 96048e2e97a4ef4e099d1429b761a9f07ec38a31..d7957637b9e4b267321d828205c4860daa0c143d 100644 (file)
@@ -371,8 +371,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, "external", "external", true);
+               return;
+       }
 
        if (tb[IFLA_IPTUN_PROTO]) {
                switch (rta_getattr_u8(tb[IFLA_IPTUN_PROTO])) {