]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - ip/link_gre6.c
Merge branch 'iproute2-master' into iproute2-next
[mirror_iproute2.git] / ip / link_gre6.c
index 6c77038a65b91a94fcb16edd088c8cef9b102e02..20f930596027972d23d4798cebb167e9c54d7d32 100644 (file)
@@ -38,9 +38,9 @@ static void gre_print_help(struct link_util *lu, int argc, char **argv, FILE *f)
        );
        fprintf(f,
                "                     [ local ADDR ]\n"
-               "                     [ [i|o]seq ]\n"
-               "                     [ [i|o]key KEY ]\n"
-               "                     [ [i|o]csum ]\n"
+               "                     [ [no][i|o]seq ]\n"
+               "                     [ [i|o]key KEY | no[i|o]key ]\n"
+               "                     [ [no][i|o]csum ]\n"
                "                     [ hoplimit TTL ]\n"
                "                     [ encaplimit ELIM ]\n"
                "                     [ tclass TCLASS ]\n"
@@ -48,6 +48,7 @@ static void gre_print_help(struct link_util *lu, int argc, char **argv, FILE *f)
                "                     [ dscp inherit ]\n"
                "                     [ dev PHYS_DEV ]\n"
                "                     [ fwmark MARK ]\n"
+               "                     [ [no]allow-localremote ]\n"
                "                     [ external ]\n"
                "                     [ noencap ]\n"
                "                     [ encap { fou | gue | none } ]\n"
@@ -219,28 +220,52 @@ get_failed:
                        iflags |= GRE_KEY;
                        oflags |= GRE_KEY;
                        ikey = okey = tnl_parse_key("key", *argv);
+               } else if (!matches(*argv, "nokey")) {
+                       iflags &= ~GRE_KEY;
+                       oflags &= ~GRE_KEY;
+                       ikey = okey = 0;
                } else if (!matches(*argv, "ikey")) {
                        NEXT_ARG();
                        iflags |= GRE_KEY;
                        ikey = tnl_parse_key("ikey", *argv);
+               } else if (!matches(*argv, "noikey")) {
+                       iflags &= ~GRE_KEY;
+                       ikey = 0;
                } else if (!matches(*argv, "okey")) {
                        NEXT_ARG();
                        oflags |= GRE_KEY;
                        okey = tnl_parse_key("okey", *argv);
+               } else if (!matches(*argv, "nookey")) {
+                       oflags &= ~GRE_KEY;
+                       okey = 0;
                } else if (!matches(*argv, "seq")) {
                        iflags |= GRE_SEQ;
                        oflags |= GRE_SEQ;
+               } else if (!matches(*argv, "noseq")) {
+                       iflags &= ~GRE_SEQ;
+                       oflags &= ~GRE_SEQ;
                } else if (!matches(*argv, "iseq")) {
                        iflags |= GRE_SEQ;
+               } else if (!matches(*argv, "noiseq")) {
+                       iflags &= ~GRE_SEQ;
                } else if (!matches(*argv, "oseq")) {
                        oflags |= GRE_SEQ;
+               } else if (!matches(*argv, "nooseq")) {
+                       oflags &= ~GRE_SEQ;
                } else if (!matches(*argv, "csum")) {
                        iflags |= GRE_CSUM;
                        oflags |= GRE_CSUM;
+               } else if (!matches(*argv, "nocsum")) {
+                       iflags &= ~GRE_CSUM;
+                       oflags &= ~GRE_CSUM;
                } else if (!matches(*argv, "icsum")) {
                        iflags |= GRE_CSUM;
+               } else if (!matches(*argv, "noicsum")) {
+                       iflags &= ~GRE_CSUM;
                } else if (!matches(*argv, "ocsum")) {
                        oflags |= GRE_CSUM;
+               } else if (!matches(*argv, "noocsum")) {
+                       oflags &= ~GRE_CSUM;
                } else if (!matches(*argv, "remote")) {
                        NEXT_ARG();
                        get_addr(&daddr, *argv, AF_INET6);
@@ -250,11 +275,8 @@ get_failed:
                } else if (!matches(*argv, "dev")) {
                        NEXT_ARG();
                        link = ll_name_to_index(*argv);
-                       if (link == 0) {
-                               fprintf(stderr, "Cannot find device \"%s\"\n",
-                                       *argv);
-                               exit(-1);
-                       }
+                       if (!link)
+                               exit(nodev(*argv));
                } else if (!matches(*argv, "ttl") ||
                           !matches(*argv, "hoplimit") ||
                           !matches(*argv, "hlim")) {
@@ -346,6 +368,10 @@ get_failed:
                                        invarg("invalid fwmark\n", *argv);
                                flags &= ~IP6_TNL_F_USE_ORIG_FWMARK;
                        }
+               } else if (strcmp(*argv, "allow-localremote") == 0) {
+                       flags |= IP6_TNL_F_ALLOW_LOCAL_REMOTE;
+               } else if (strcmp(*argv, "noallow-localremote") == 0) {
+                       flags &= ~IP6_TNL_F_ALLOW_LOCAL_REMOTE;
                } else if (strcmp(*argv, "encaplimit") == 0) {
                        NEXT_ARG();
                        if (strcmp(*argv, "none") == 0) {
@@ -398,9 +424,9 @@ get_failed:
        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);
-       if (is_addrtype_inet(&saddr))
+       if (is_addrtype_inet_not_unspec(&saddr))
                addattr_l(n, 1024, IFLA_GRE_LOCAL, saddr.data, saddr.bytelen);
-       if (is_addrtype_inet(&daddr))
+       if (is_addrtype_inet_not_unspec(&daddr))
                addattr_l(n, 1024, IFLA_GRE_REMOTE, daddr.data, daddr.bytelen);
        if (link)
                addattr32(n, 1024, IFLA_GRE_LINK, link);
@@ -534,6 +560,12 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
        if (oflags & GRE_CSUM)
                print_bool(PRINT_ANY, "ocsum", "ocsum ", true);
 
+       if (flags & IP6_TNL_F_ALLOW_LOCAL_REMOTE)
+               print_bool(PRINT_ANY,
+                          "ip6_tnl_f_allow_local_remote",
+                          "allow-localremote ",
+                          true);
+
        if (flags & IP6_TNL_F_USE_ORIG_FWMARK) {
                print_bool(PRINT_ANY,
                           "ip6_tnl_f_use_orig_fwmark",