Few minor changes to reduce diffs between ip and ipv6 tunnel code:

  1) reduce intendation by one level when adding attributes in gre and
     gre6; reorder addattr*() calls to simplify diff

  2) reorder local variables definition; change their type (e.g. for
     IFLA_LINK) to match ones returned by rta_getattr_*()

  3) move "mode" parameter parsing in link_iptnl.c to the similar
     position as in link_ip6tnl.c

  4) handle "tc" as shortcut for "tclass"/"tos" in link_iptnl.c

  5) add whitespace where required

Signed-off-by: Serhey Popovych <serhe.popov...@gmail.com>
---
 ip/link_gre.c    |   91 +++++++++++++++++++++++++++---------------------------
 ip/link_gre6.c   |   83 ++++++++++++++++++++++++-------------------------
 ip/link_ip6tnl.c |   13 ++++----
 ip/link_iptnl.c  |   61 ++++++++++++++++++------------------
 ip/link_vti.c    |    2 +-
 ip/link_vti6.c   |    2 +-
 6 files changed, 127 insertions(+), 125 deletions(-)

diff --git a/ip/link_gre.c b/ip/link_gre.c
index b2573a1..69c8deb 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -84,23 +84,23 @@ static int gre_parse_opt(struct link_util *lu, int argc, 
char **argv,
        struct rtattr *tb[IFLA_MAX + 1];
        struct rtattr *linkinfo[IFLA_INFO_MAX+1];
        struct rtattr *greinfo[IFLA_GRE_MAX + 1];
+       int len;
        __u16 iflags = 0;
        __u16 oflags = 0;
        __be32 ikey = 0;
        __be32 okey = 0;
        unsigned int saddr = 0;
        unsigned int daddr = 0;
-       unsigned int link = 0;
        __u8 pmtudisc = 1;
-       __u8 ttl = 0;
+       __u8 ignore_df = 0;
        __u8 tos = 0;
-       int len;
+       __u8 ttl = 0;
+       __u32 link = 0;
        __u16 encaptype = 0;
        __u16 encapflags = 0;
        __u16 encapsport = 0;
        __u16 encapdport = 0;
        __u8 metadata = 0;
-       __u8 ignore_df = 0;
        __u32 fwmark = 0;
        __u32 erspan_idx = 0;
        __u8 erspan_ver = 0;
@@ -155,31 +155,34 @@ get_failed:
                        pmtudisc = rta_getattr_u8(
                                greinfo[IFLA_GRE_PMTUDISC]);
 
-               if (greinfo[IFLA_GRE_TTL])
-                       ttl = rta_getattr_u8(greinfo[IFLA_GRE_TTL]);
+               if (greinfo[IFLA_GRE_IGNORE_DF])
+                       ignore_df =
+                               !!rta_getattr_u8(greinfo[IFLA_GRE_IGNORE_DF]);
 
                if (greinfo[IFLA_GRE_TOS])
                        tos = rta_getattr_u8(greinfo[IFLA_GRE_TOS]);
 
+               if (greinfo[IFLA_GRE_TTL])
+                       ttl = rta_getattr_u8(greinfo[IFLA_GRE_TTL]);
+
                if (greinfo[IFLA_GRE_LINK])
                        link = rta_getattr_u32(greinfo[IFLA_GRE_LINK]);
 
                if (greinfo[IFLA_GRE_ENCAP_TYPE])
                        encaptype = 
rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_TYPE]);
+
                if (greinfo[IFLA_GRE_ENCAP_FLAGS])
                        encapflags = 
rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_FLAGS]);
+
                if (greinfo[IFLA_GRE_ENCAP_SPORT])
                        encapsport = 
rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]);
+
                if (greinfo[IFLA_GRE_ENCAP_DPORT])
                        encapdport = 
rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]);
 
                if (greinfo[IFLA_GRE_COLLECT_METADATA])
                        metadata = 1;
 
-               if (greinfo[IFLA_GRE_IGNORE_DF])
-                       ignore_df =
-                               !!rta_getattr_u8(greinfo[IFLA_GRE_IGNORE_DF]);
-
                if (greinfo[IFLA_GRE_FWMARK])
                        fwmark = rta_getattr_u32(greinfo[IFLA_GRE_FWMARK]);
 
@@ -354,49 +357,47 @@ get_failed:
                return -1;
        }
 
-       if (!metadata) {
-               addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
-               addattr32(n, 1024, IFLA_GRE_OKEY, okey);
-               addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
-               addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
-               addattr_l(n, 1024, IFLA_GRE_LOCAL, &saddr, 4);
-               addattr_l(n, 1024, IFLA_GRE_REMOTE, &daddr, 4);
-               addattr_l(n, 1024, IFLA_GRE_PMTUDISC, &pmtudisc, 1);
-               if (ignore_df)
-                       addattr8(n, 1024, IFLA_GRE_IGNORE_DF, ignore_df & 1);
-               if (link)
-                       addattr32(n, 1024, IFLA_GRE_LINK, link);
-               addattr_l(n, 1024, IFLA_GRE_TTL, &ttl, 1);
-               addattr_l(n, 1024, IFLA_GRE_TOS, &tos, 1);
-               addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
-               if (erspan_ver) {
-                       addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
-                       if (erspan_ver == 1 && erspan_idx != 0) {
-                               addattr32(n, 1024,
-                                         IFLA_GRE_ERSPAN_INDEX, erspan_idx);
-                       } else if (erspan_ver == 2) {
-                               addattr8(n, 1024,
-                                        IFLA_GRE_ERSPAN_DIR, erspan_dir);
-                               addattr16(n, 1024,
-                                         IFLA_GRE_ERSPAN_HWID, erspan_hwid);
-                       }
-               }
-               addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
-               addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
-               addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
-               addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
-       } else {
+       if (metadata) {
                addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
+               return 0;
        }
 
+       addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
+       addattr32(n, 1024, IFLA_GRE_OKEY, okey);
+       addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
+       addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
+       addattr_l(n, 1024, IFLA_GRE_LOCAL, &saddr, 4);
+       addattr_l(n, 1024, IFLA_GRE_REMOTE, &daddr, 4);
+       addattr_l(n, 1024, IFLA_GRE_PMTUDISC, &pmtudisc, 1);
+       if (ignore_df)
+               addattr8(n, 1024, IFLA_GRE_IGNORE_DF, ignore_df & 1);
+       addattr_l(n, 1024, IFLA_GRE_TOS, &tos, 1);
+       if (link)
+               addattr32(n, 1024, IFLA_GRE_LINK, link);
+       addattr_l(n, 1024, IFLA_GRE_TTL, &ttl, 1);
+       addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
+       if (erspan_ver) {
+               addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
+               if (erspan_ver == 1 && erspan_idx != 0) {
+                       addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
+               } else if (erspan_ver == 2) {
+                       addattr8(n, 1024, IFLA_GRE_ERSPAN_DIR, erspan_dir);
+                       addattr16(n, 1024, IFLA_GRE_ERSPAN_HWID, erspan_hwid);
+               }
+       }
+       addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
+       addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
+       addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
+       addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
+
        return 0;
 }
 
 static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 {
        char s2[64];
-       unsigned int iflags = 0;
-       unsigned int oflags = 0;
+       __u16 iflags = 0;
+       __u16 oflags = 0;
        __u8 ttl = 0;
        __u8 tos = 0;
 
@@ -412,7 +413,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, 
struct rtattr *tb[])
        tnl_print_endpoint("local", tb[IFLA_GRE_LOCAL], AF_INET);
 
        if (tb[IFLA_GRE_LINK]) {
-               unsigned int link = rta_getattr_u32(tb[IFLA_GRE_LINK]);
+               __u32 link = rta_getattr_u32(tb[IFLA_GRE_LINK]);
 
                if (link) {
                        print_string(PRINT_ANY, "link", "dev %s ",
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 880b75d..a813c14 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -94,23 +94,23 @@ static int gre_parse_opt(struct link_util *lu, int argc, 
char **argv,
        struct rtattr *tb[IFLA_MAX + 1];
        struct rtattr *linkinfo[IFLA_INFO_MAX+1];
        struct rtattr *greinfo[IFLA_GRE_MAX + 1];
+       int len;
        __u16 iflags = 0;
        __u16 oflags = 0;
        __be32 ikey = 0;
        __be32 okey = 0;
        struct in6_addr raddr = IN6ADDR_ANY_INIT;
        struct in6_addr laddr = IN6ADDR_ANY_INIT;
-       unsigned int link = 0;
-       unsigned int flowinfo = 0;
-       unsigned int flags = 0;
        __u8 hop_limit = DEFAULT_TNL_HOP_LIMIT;
        __u8 encap_limit = IPV6_DEFAULT_TNL_ENCAP_LIMIT;
+       __u32 flowinfo = 0;
+       __u32 flags = 0;
+       __u32 link = 0;
        __u16 encaptype = 0;
        __u16 encapflags = TUNNEL_ENCAP_FLAG_CSUM6;
        __u16 encapsport = 0;
        __u16 encapdport = 0;
        __u8 metadata = 0;
-       int len;
        __u32 fwmark = 0;
        __u32 erspan_idx = 0;
        __u8 erspan_ver = 0;
@@ -185,12 +185,12 @@ get_failed:
                if (greinfo[IFLA_GRE_ENCAP_SPORT])
                        encapsport = 
rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]);
 
-               if (greinfo[IFLA_GRE_COLLECT_METADATA])
-                       metadata = 1;
-
                if (greinfo[IFLA_GRE_ENCAP_DPORT])
                        encapdport = 
rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]);
 
+               if (greinfo[IFLA_GRE_COLLECT_METADATA])
+                       metadata = 1;
+
                if (greinfo[IFLA_GRE_FWMARK])
                        fwmark = rta_getattr_u32(greinfo[IFLA_GRE_FWMARK]);
 
@@ -389,39 +389,37 @@ get_failed:
                argc--; argv++;
        }
 
-       if (!metadata) {
-               addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
-               addattr32(n, 1024, IFLA_GRE_OKEY, okey);
-               addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
-               addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
-               addattr_l(n, 1024, IFLA_GRE_LOCAL, &laddr, sizeof(laddr));
-               addattr_l(n, 1024, IFLA_GRE_REMOTE, &raddr, sizeof(raddr));
-               if (link)
-                       addattr32(n, 1024, IFLA_GRE_LINK, link);
-               addattr_l(n, 1024, IFLA_GRE_TTL, &hop_limit, 1);
-               addattr_l(n, 1024, IFLA_GRE_ENCAP_LIMIT, &encap_limit, 1);
-               addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
-               addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
-               addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
-               if (erspan_ver) {
-                       addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
-                       if (erspan_ver == 1 && erspan_idx != 0) {
-                               addattr32(n, 1024,
-                                         IFLA_GRE_ERSPAN_INDEX, erspan_idx);
-                       } else if (erspan_ver == 2) {
-                               addattr8(n, 1024,
-                                        IFLA_GRE_ERSPAN_DIR, erspan_dir);
-                               addattr16(n, 1024,
-                                         IFLA_GRE_ERSPAN_HWID, erspan_hwid);
-                       }
-               }
-               addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
-               addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
-               addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
-               addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
-       } else {
+       if (metadata) {
                addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
+               return 0;
+       }
+
+       addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
+       addattr32(n, 1024, IFLA_GRE_OKEY, okey);
+       addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
+       addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
+       addattr_l(n, 1024, IFLA_GRE_LOCAL, &laddr, sizeof(laddr));
+       addattr_l(n, 1024, IFLA_GRE_REMOTE, &raddr, sizeof(raddr));
+       if (link)
+               addattr32(n, 1024, IFLA_GRE_LINK, link);
+       addattr_l(n, 1024, IFLA_GRE_TTL, &hop_limit, 1);
+       addattr_l(n, 1024, IFLA_GRE_ENCAP_LIMIT, &encap_limit, 1);
+       addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
+       addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
+       addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
+       if (erspan_ver) {
+               addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
+               if (erspan_ver == 1 && erspan_idx != 0) {
+                       addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
+               } else if (erspan_ver == 2) {
+                       addattr8(n, 1024, IFLA_GRE_ERSPAN_DIR, erspan_dir);
+                       addattr16(n, 1024, IFLA_GRE_ERSPAN_HWID, erspan_hwid);
+               }
        }
+       addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
+       addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
+       addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
+       addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
 
        return 0;
 }
@@ -429,9 +427,9 @@ get_failed:
 static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 {
        char s2[64];
-       unsigned int iflags = 0;
-       unsigned int oflags = 0;
-       unsigned int flags = 0;
+       __u16 iflags = 0;
+       __u16 oflags = 0;
+       __u32 flags = 0;
        __u32 flowinfo = 0;
        __u8 ttl = 0;
 
@@ -453,7 +451,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, 
struct rtattr *tb[])
        tnl_print_endpoint("local", tb[IFLA_GRE_LOCAL], AF_INET6);
 
        if (tb[IFLA_GRE_LINK]) {
-               unsigned int link = rta_getattr_u32(tb[IFLA_GRE_LINK]);
+               __u32 link = rta_getattr_u32(tb[IFLA_GRE_LINK]);
 
                if (link) {
                        print_string(PRINT_ANY, "link", "dev %s ",
@@ -550,6 +548,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, 
struct rtattr *tb[])
 
        if (tb[IFLA_GRE_ERSPAN_INDEX]) {
                __u32 erspan_idx = rta_getattr_u32(tb[IFLA_GRE_ERSPAN_INDEX]);
+
                print_uint(PRINT_ANY,
                           "erspan_index", "erspan_index %u ", erspan_idx);
        }
diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
index 91d7d99..b67ec6e 100644
--- a/ip/link_ip6tnl.c
+++ b/ip/link_ip6tnl.c
@@ -94,8 +94,8 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int 
argc, char **argv,
        __u8 encap_limit = IPV6_DEFAULT_TNL_ENCAP_LIMIT;
        __u32 flowinfo = 0;
        __u32 flags = 0;
-       __u32 link = 0;
        __u8 proto = 0;
+       __u32 link = 0;
        __u16 encaptype = 0;
        __u16 encapflags = TUNNEL_ENCAP_FLAG_CSUM6;
        __u16 encapsport = 0;
@@ -164,7 +164,7 @@ get_failed:
        }
 
        while (argc > 0) {
-               if (matches(*argv, "mode") == 0) {
+               if (strcmp(*argv, "mode") == 0) {
                        NEXT_ARG();
                        if (strcmp(*argv, "ipv6/ipv6") == 0 ||
                            strcmp(*argv, "ip6ip6") == 0)
@@ -217,9 +217,9 @@ get_failed:
                                encap_limit = uval;
                                flags &= ~IP6_TNL_F_IGN_ENCAP_LIMIT;
                        }
-               } else if (strcmp(*argv, "tclass") == 0 ||
+               } else if (strcmp(*argv, "tos") == 0 ||
+                          strcmp(*argv, "tclass") == 0 ||
                           strcmp(*argv, "tc") == 0 ||
-                          strcmp(*argv, "tos") == 0 ||
                           matches(*argv, "dsfield") == 0) {
                        __u8 uval;
 
@@ -314,6 +314,7 @@ get_failed:
                addattr_l(n, 1024, IFLA_IPTUN_COLLECT_METADATA, NULL, 0);
                return 0;
        }
+
        addattr_l(n, 1024, IFLA_IPTUN_LOCAL, &laddr, sizeof(laddr));
        addattr_l(n, 1024, IFLA_IPTUN_REMOTE, &raddr, sizeof(raddr));
        addattr8(n, 1024, IFLA_IPTUN_TTL, hop_limit);
@@ -334,7 +335,7 @@ get_failed:
 static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr 
*tb[])
 {
        char s2[64];
-       int flags = 0;
+       __u32 flags = 0;
        __u32 flowinfo = 0;
        __u8 ttl = 0;
 
@@ -370,7 +371,7 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE 
*f, struct rtattr *tb
        tnl_print_endpoint("local", tb[IFLA_IPTUN_LOCAL], AF_INET6);
 
        if (tb[IFLA_IPTUN_LINK]) {
-               unsigned int link = rta_getattr_u32(tb[IFLA_IPTUN_LINK]);
+               __u32 link = rta_getattr_u32(tb[IFLA_IPTUN_LINK]);
 
                if (link) {
                        print_string(PRINT_ANY, "link", "dev %s ",
diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
index 3e653b7..494eabf 100644
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -88,18 +88,18 @@ static int iptunnel_parse_opt(struct link_util *lu, int 
argc, char **argv,
        struct rtattr *linkinfo[IFLA_INFO_MAX+1];
        struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1];
        int len;
-       __u32 link = 0;
        __u32 laddr = 0;
        __u32 raddr = 0;
-       __u8 ttl = 0;
-       __u8 tos = 0;
        __u8 pmtudisc = 1;
+       __u8 tos = 0;
        __u16 iflags = 0;
-       __u8 proto = 0;
+       __u8 ttl = 0;
        struct in6_addr ip6rdprefix = {};
        __u16 ip6rdprefixlen = 0;
        __u32 ip6rdrelayprefix = 0;
        __u16 ip6rdrelayprefixlen = 0;
+       __u8 proto = 0;
+       __u32 link = 0;
        __u16 encaptype = 0;
        __u16 encapflags = 0;
        __u16 encapsport = 0;
@@ -142,13 +142,13 @@ get_failed:
                if (iptuninfo[IFLA_IPTUN_TTL])
                        ttl = rta_getattr_u8(iptuninfo[IFLA_IPTUN_TTL]);
 
-               if (iptuninfo[IFLA_IPTUN_TOS])
-                       tos = rta_getattr_u8(iptuninfo[IFLA_IPTUN_TOS]);
-
                if (iptuninfo[IFLA_IPTUN_PMTUDISC])
                        pmtudisc =
                                rta_getattr_u8(iptuninfo[IFLA_IPTUN_PMTUDISC]);
 
+               if (iptuninfo[IFLA_IPTUN_TOS])
+                       tos = rta_getattr_u8(iptuninfo[IFLA_IPTUN_TOS]);
+
                if (iptuninfo[IFLA_IPTUN_FLAGS])
                        iflags = rta_getattr_u16(iptuninfo[IFLA_IPTUN_FLAGS]);
 
@@ -192,7 +192,25 @@ get_failed:
        }
 
        while (argc > 0) {
-               if (strcmp(*argv, "remote") == 0) {
+               if (strcmp(*argv, "mode") == 0) {
+                       NEXT_ARG();
+                       if (strcmp(lu->id, "sit") == 0 &&
+                           (strcmp(*argv, "ipv6/ipv4") == 0 ||
+                            strcmp(*argv, "ip6ip") == 0))
+                               proto = IPPROTO_IPV6;
+                       else if (strcmp(*argv, "ipv4/ipv4") == 0 ||
+                                strcmp(*argv, "ipip") == 0 ||
+                                strcmp(*argv, "ip4ip4") == 0)
+                               proto = IPPROTO_IPIP;
+                       else if (strcmp(*argv, "mpls/ipv4") == 0 ||
+                                  strcmp(*argv, "mplsip") == 0)
+                               proto = IPPROTO_MPLS;
+                       else if (strcmp(*argv, "any/ipv4") == 0 ||
+                                strcmp(*argv, "any") == 0)
+                               proto = 0;
+                       else
+                               invarg("Cannot guess tunnel mode.", *argv);
+               } else if (strcmp(*argv, "remote") == 0) {
                        NEXT_ARG();
                        raddr = get_addr32(*argv);
                } else if (strcmp(*argv, "local") == 0) {
@@ -214,6 +232,7 @@ get_failed:
                                ttl = 0;
                } else if (strcmp(*argv, "tos") == 0 ||
                           strcmp(*argv, "tclass") == 0 ||
+                          strcmp(*argv, "tc") == 0 ||
                           matches(*argv, "dsfield") == 0) {
                        __u32 uval;
 
@@ -231,24 +250,6 @@ get_failed:
                } else if (strcmp(lu->id, "sit") == 0 &&
                           strcmp(*argv, "isatap") == 0) {
                        iflags |= SIT_ISATAP;
-               } else if (strcmp(*argv, "mode") == 0) {
-                       NEXT_ARG();
-                       if (strcmp(lu->id, "sit") == 0 &&
-                           (strcmp(*argv, "ipv6/ipv4") == 0 ||
-                            strcmp(*argv, "ip6ip") == 0))
-                               proto = IPPROTO_IPV6;
-                       else if (strcmp(*argv, "ipv4/ipv4") == 0 ||
-                                strcmp(*argv, "ipip") == 0 ||
-                                strcmp(*argv, "ip4ip4") == 0)
-                               proto = IPPROTO_IPIP;
-                       else if (strcmp(*argv, "mpls/ipv4") == 0 ||
-                                  strcmp(*argv, "mplsip") == 0)
-                               proto = IPPROTO_MPLS;
-                       else if (strcmp(*argv, "any/ipv4") == 0 ||
-                                strcmp(*argv, "any") == 0)
-                               proto = 0;
-                       else
-                               invarg("Cannot guess tunnel mode.", *argv);
                } else if (strcmp(*argv, "noencap") == 0) {
                        encaptype = TUNNEL_ENCAP_NONE;
                } else if (strcmp(*argv, "encap") == 0) {
@@ -329,12 +330,12 @@ get_failed:
                return 0;
        }
 
-       addattr32(n, 1024, IFLA_IPTUN_LINK, link);
        addattr32(n, 1024, IFLA_IPTUN_LOCAL, laddr);
        addattr32(n, 1024, IFLA_IPTUN_REMOTE, raddr);
-       addattr8(n, 1024, IFLA_IPTUN_TTL, ttl);
-       addattr8(n, 1024, IFLA_IPTUN_TOS, tos);
        addattr8(n, 1024, IFLA_IPTUN_PMTUDISC, pmtudisc);
+       addattr8(n, 1024, IFLA_IPTUN_TOS, tos);
+       addattr8(n, 1024, IFLA_IPTUN_TTL, ttl);
+       addattr32(n, 1024, IFLA_IPTUN_LINK, link);
        addattr32(n, 1024, IFLA_IPTUN_FWMARK, fwmark);
 
        addattr16(n, 1024, IFLA_IPTUN_ENCAP_TYPE, encaptype);
@@ -395,7 +396,7 @@ static void iptunnel_print_opt(struct link_util *lu, FILE 
*f, struct rtattr *tb[
        tnl_print_endpoint("local", tb[IFLA_IPTUN_LOCAL], AF_INET);
 
        if (tb[IFLA_IPTUN_LINK]) {
-               unsigned int link = rta_getattr_u32(tb[IFLA_IPTUN_LINK]);
+               __u32 link = rta_getattr_u32(tb[IFLA_IPTUN_LINK]);
 
                if (link) {
                        print_string(PRINT_ANY, "link", "dev %s ",
diff --git a/ip/link_vti.c b/ip/link_vti.c
index 49b87e9..b59b904 100644
--- a/ip/link_vti.c
+++ b/ip/link_vti.c
@@ -174,7 +174,7 @@ static void vti_print_opt(struct link_util *lu, FILE *f, 
struct rtattr *tb[])
        tnl_print_endpoint("local", tb[IFLA_VTI_LOCAL], AF_INET);
 
        if (tb[IFLA_VTI_LINK]) {
-               unsigned int link = rta_getattr_u32(tb[IFLA_VTI_LINK]);
+               __u32 link = rta_getattr_u32(tb[IFLA_VTI_LINK]);
 
                if (link) {
                        print_string(PRINT_ANY, "link", "dev %s ",
diff --git a/ip/link_vti6.c b/ip/link_vti6.c
index d1fbec5..78e8f16 100644
--- a/ip/link_vti6.c
+++ b/ip/link_vti6.c
@@ -180,7 +180,7 @@ static void vti6_print_opt(struct link_util *lu, FILE *f, 
struct rtattr *tb[])
        tnl_print_endpoint("local", tb[IFLA_VTI_LOCAL], AF_INET6);
 
        if (tb[IFLA_VTI_LINK]) {
-               unsigned int link = rta_getattr_u32(tb[IFLA_VTI_LINK]);
+               __u32 link = rta_getattr_u32(tb[IFLA_VTI_LINK]);
 
                if (link) {
                        print_string(PRINT_ANY, "link", "dev %s ",
-- 
1.7.10.4

Reply via email to