]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iptunnel: add support for mpls/ip to ipip tunnels
authorKrister Johansen <kjlx@templeofstupid.com>
Sat, 10 Jun 2017 01:31:32 +0000 (18:31 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 5 Jul 2017 16:04:59 +0000 (09:04 -0700)
Original-Author: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
ip/link_iptnl.c
man/man8/ip-link.8.in

index cf3a9ef4cf4862c715d7ea013ee3d6defddca2fa..d24e7376d23ccdb10a34a7ad84901ba763d69c7a 100644 (file)
@@ -50,6 +50,8 @@ static void print_usage(FILE *f, int sit)
        if (sit) {
                fprintf(f, "          [ mode { ip6ip | ipip | mplsip | any } ]\n");
                fprintf(f, "          [ isatap ]\n");
+       } else {
+               fprintf(f, "          [ mode { ipip | mplsip | any } ]\n");
        }
        fprintf(f, "                [ external ]\n");
        fprintf(f, "                [ fwmark MARK ]\n");
@@ -251,6 +253,21 @@ get_failed:
                                proto = 0;
                        else
                                invarg("Cannot guess tunnel mode.", *argv);
+               } else if (strcmp(lu->id, "ipip") == 0 &&
+                          strcmp(*argv, "mode") == 0) {
+                       NEXT_ARG();
+                       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) {
@@ -343,9 +360,11 @@ get_failed:
        addattr16(n, 1024, IFLA_IPTUN_ENCAP_SPORT, htons(encapsport));
        addattr16(n, 1024, IFLA_IPTUN_ENCAP_DPORT, htons(encapdport));
 
+       if (strcmp(lu->id, "ipip") == 0 || strcmp(lu->id, "sit") == 0)
+               addattr8(n, 1024, IFLA_IPTUN_PROTO, proto);
+
        if (strcmp(lu->id, "sit") == 0) {
                addattr16(n, 1024, IFLA_IPTUN_FLAGS, iflags);
-               addattr8(n, 1024, IFLA_IPTUN_PROTO, proto);
                if (ip6rdprefixlen) {
                        addattr_l(n, 1024, IFLA_IPTUN_6RD_PREFIX,
                                  &ip6rdprefix, sizeof(ip6rdprefix));
index 994b539e343ec57701f32b1ef24cffc17fe112e5..a7827124b6810c254463e16a60028b85d6b99487 100644 (file)
@@ -703,8 +703,9 @@ applicable for Generic UDP Encapsulation.
 .BI mode " { ip6ip | ipip | mplsip | any } "
 - specifies mode in which device should run. "ip6ip" indicates
 IPv6-Over-IPv4, "ipip" indicates "IPv4-Over-IPv4", "mplsip" indicates
-MPLS-Over-IPv4, "any" indicates IPv6, IPv4 or MPLS Over IPv4. Only
-supported for SIT where the default is "ip6ip".
+MPLS-Over-IPv4, "any" indicates IPv6, IPv4 or MPLS Over IPv4. Supported for
+SIT where the default is "ip6ip" and IPIP where the default is "ipip".
+IPv6-Over-IPv4 is not supported for IPIP.
 
 .in -8