From: Krister Johansen Date: Sat, 10 Jun 2017 01:31:32 +0000 (-0700) Subject: iptunnel: add support for mpls/ip to ipip tunnels X-Git-Tag: v4.12.0~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=288c28bc114890cb043e13934e39677fd3532ff9;p=thirdparty%2Fiproute2.git iptunnel: add support for mpls/ip to ipip tunnels Original-Author: Simon Horman Signed-off-by: Krister Johansen --- diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c index cf3a9ef4c..d24e7376d 100644 --- a/ip/link_iptnl.c +++ b/ip/link_iptnl.c @@ -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)); diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index 994b539e3..a7827124b 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -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