netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC iproute2 0/3] iptunnel: support MPLS in IPv4 and UDP
@ 2016-07-06 18:23 Simon Horman
  2016-07-06 18:23 ` [PATCH/RFC iproute2 1/3] iptunnel: document mode parameter for sit tunnels Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Simon Horman @ 2016-07-06 18:23 UTC (permalink / raw)
  To: netdev; +Cc: stephen

This short series provides support for MPLS in IPv4 (RFC4023), and by
virtue of FOU MPLS in UDP (RFC7510).

The changes are as follows:
1. Document the mode parameter of SIT tunnels
2. Enhance ipip and sit to handle MPLS. Both already handle IPv4.
   sit also already handles IPv6.

A corresponding kernel patchset will also be posted.

Simon Horman (3):
  iptunnel: document mode parameter for sit tunnels
  iptunnel: add support for mpls/ip to sit tunnels
  iptunnel: add support for mpls/ip to ipip tunnels

 ip/link_iptnl.c       | 47 ++++++++++++++++++++++++++++++++++++++---------
 ip/tunnel.c           | 10 ++++++++++
 man/man8/ip-link.8.in | 10 ++++++++++
 3 files changed, 58 insertions(+), 9 deletions(-)

-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH/RFC iproute2 1/3] iptunnel: document mode parameter for sit tunnels
  2016-07-06 18:23 [PATCH/RFC iproute2 0/3] iptunnel: support MPLS in IPv4 and UDP Simon Horman
@ 2016-07-06 18:23 ` Simon Horman
  2016-07-06 18:23 ` [PATCH/RFC iproute2 2/3] iptunnel: add support for mpls/ip to " Simon Horman
  2016-07-06 18:23 ` [PATCH/RFC iproute2 3/3] iptunnel: add support for mpls/ip to ipip tunnels Simon Horman
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2016-07-06 18:23 UTC (permalink / raw)
  To: netdev; +Cc: stephen

Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 man/man8/ip-link.8.in | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 375b4d081408..822cf1bbd5f1 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -605,6 +605,8 @@ the following additional arguments are supported:
 .I " [no]encap-csum "
 ] [
 .I " [no]encap-remcsum "
+] [
+.I " mode " { ip6ip | ipip | any } "
 ]
 
 .in +8
@@ -641,6 +643,12 @@ encapsulation.
 - specifies if Remote Checksum Offload is enabled. This is only
 applicable for Generic UDP Encapsulation.
 
+.sp
+.BI mode " { ip6ip | ipip | any } "
+- specifies mode in which device should run. "ip6ip" indicates
+IPv6-Over-IPv4, "ipip" indicates "IPv4-Over-IPv4", "any" indicates either
+IPv6 or IPv4 Over IPv4. Only supported for SIT where the default is "ip6ip".
+
 .in -8
 
 .TP
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH/RFC iproute2 2/3] iptunnel: add support for mpls/ip to sit tunnels
  2016-07-06 18:23 [PATCH/RFC iproute2 0/3] iptunnel: support MPLS in IPv4 and UDP Simon Horman
  2016-07-06 18:23 ` [PATCH/RFC iproute2 1/3] iptunnel: document mode parameter for sit tunnels Simon Horman
@ 2016-07-06 18:23 ` Simon Horman
  2016-08-03  0:48   ` David Ahern
  2016-07-06 18:23 ` [PATCH/RFC iproute2 3/3] iptunnel: add support for mpls/ip to ipip tunnels Simon Horman
  2 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2016-07-06 18:23 UTC (permalink / raw)
  To: netdev; +Cc: stephen

Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 ip/link_iptnl.c       | 12 +++++++++++-
 ip/tunnel.c           | 10 ++++++++++
 man/man8/ip-link.8.in |  9 +++++----
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
index 8411a6a00a1b..34e4625b4335 100644
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -23,6 +23,13 @@
 #include "ip_common.h"
 #include "tunnel.h"
 
+/* This should be in ip.h but it might not be.
+ * What to do?
+ */
+#ifndef IPPROTO_MPLS
+#define IPPROTO_MPLS 137 /* RFC 4023 */
+#endif
+
 static void print_usage(FILE *f, int sit)
 {
 	fprintf(f, "Usage: ip link { add | set | change | replace | del } NAME\n");
@@ -33,7 +40,7 @@ static void print_usage(FILE *f, int sit)
 	fprintf(f, "          [ encap-sport PORT ] [ encap-dport PORT ]\n");
 	fprintf(f, "          [ [no]encap-csum ] [ [no]encap-csum6 ] [ [no]encap-remcsum ]\n");
 	if (sit) {
-		fprintf(f, "          [ mode { ip6ip | ipip | any } ]\n");
+		fprintf(f, "          [ mode { ip6ip | ipip | mplsip | any } ]\n");
 		fprintf(f, "          [ isatap ]\n");
 	}
 	fprintf(f, "\n");
@@ -222,6 +229,9 @@ get_failed:
 				 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;
diff --git a/ip/tunnel.c b/ip/tunnel.c
index 7956d71aa733..760fa18a5be6 100644
--- a/ip/tunnel.c
+++ b/ip/tunnel.c
@@ -37,6 +37,13 @@
 #include "utils.h"
 #include "tunnel.h"
 
+/* This should be in ip.h but it might not be.
+ * What to do?
+ */
+#ifndef IPPROTO_MPLS
+#define IPPROTO_MPLS 137 /* RFC 4023 */
+#endif
+
 const char *tnl_strproto(__u8 proto)
 {
 	static char buf[16];
@@ -54,6 +61,9 @@ const char *tnl_strproto(__u8 proto)
 	case IPPROTO_ESP:
 		strcpy(buf, "esp");
 		break;
+	case IPPROTO_MPLS:
+		strcpy(buf, "mpls");
+		break;
 	case 0:
 		strcpy(buf, "any");
 		break;
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 822cf1bbd5f1..ba43255859de 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -606,7 +606,7 @@ the following additional arguments are supported:
 ] [
 .I " [no]encap-remcsum "
 ] [
-.I " mode " { ip6ip | ipip | any } "
+.I " mode " { ip6ip | ipip | mplsip | any } "
 ]
 
 .in +8
@@ -644,10 +644,11 @@ encapsulation.
 applicable for Generic UDP Encapsulation.
 
 .sp
-.BI mode " { ip6ip | ipip | any } "
+.BI mode " { ip6ip | ipip | mplsip | any } "
 - specifies mode in which device should run. "ip6ip" indicates
-IPv6-Over-IPv4, "ipip" indicates "IPv4-Over-IPv4", "any" indicates either
-IPv6 or IPv4 Over IPv4. Only supported for SIT where the default is "ip6ip".
+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".
 
 .in -8
 
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH/RFC iproute2 3/3] iptunnel: add support for mpls/ip to ipip tunnels
  2016-07-06 18:23 [PATCH/RFC iproute2 0/3] iptunnel: support MPLS in IPv4 and UDP Simon Horman
  2016-07-06 18:23 ` [PATCH/RFC iproute2 1/3] iptunnel: document mode parameter for sit tunnels Simon Horman
  2016-07-06 18:23 ` [PATCH/RFC iproute2 2/3] iptunnel: add support for mpls/ip to " Simon Horman
@ 2016-07-06 18:23 ` Simon Horman
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2016-07-06 18:23 UTC (permalink / raw)
  To: netdev; +Cc: stephen

Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 ip/link_iptnl.c       | 35 +++++++++++++++++++++++++++--------
 man/man8/ip-link.8.in |  5 +++--
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
index 34e4625b4335..43a431f6d3a7 100644
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -30,7 +30,7 @@
 #define IPPROTO_MPLS 137 /* RFC 4023 */
 #endif
 
-static void print_usage(FILE *f, int sit)
+static void print_usage(FILE *f, const char *id)
 {
 	fprintf(f, "Usage: ip link { add | set | change | replace | del } NAME\n");
 	fprintf(f, "          type { ipip | sit } [ remote ADDR ] [ local ADDR ]\n");
@@ -39,9 +39,11 @@ static void print_usage(FILE *f, int sit)
 	fprintf(f, "          [ noencap ] [ encap { fou | gue | none } ]\n");
 	fprintf(f, "          [ encap-sport PORT ] [ encap-dport PORT ]\n");
 	fprintf(f, "          [ [no]encap-csum ] [ [no]encap-csum6 ] [ [no]encap-remcsum ]\n");
-	if (sit) {
+	if (strcmp(id, "sit") == 0) {
 		fprintf(f, "          [ mode { ip6ip | ipip | mplsip | any } ]\n");
 		fprintf(f, "          [ isatap ]\n");
+	} else if (strcmp(id, "ipip") == 0) {
+		fprintf(f, "          [ mode { ipip | mplsip | any } ]\n");
 	}
 	fprintf(f, "\n");
 	fprintf(f, "Where: NAME := STRING\n");
@@ -50,10 +52,10 @@ static void print_usage(FILE *f, int sit)
 	fprintf(f, "       TTL  := { 1..255 | inherit }\n");
 }
 
-static void usage(int sit) __attribute__((noreturn));
-static void usage(int sit)
+static void usage(const char *id) __attribute__((noreturn));
+static void usage(const char *id)
 {
-	print_usage(stderr, sit);
+	print_usage(stderr, id);
 	exit(-1);
 }
 
@@ -237,6 +239,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) {
@@ -296,7 +313,7 @@ get_failed:
 			ip6rdrelayprefix = 0;
 			ip6rdrelayprefixlen = 0;
 		} else
-			usage(strcmp(lu->id, "sit") == 0);
+			usage(lu->id);
 		argc--, argv++;
 	}
 
@@ -317,9 +334,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));
@@ -466,7 +485,7 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
 static void iptunnel_print_help(struct link_util *lu, int argc, char **argv,
 	FILE *f)
 {
-	print_usage(f, strcmp(lu->id, "sit") == 0);
+	print_usage(f, lu->id);
 }
 
 struct link_util ipip_link_util = {
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index ba43255859de..f02501c0e4fd 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -647,8 +647,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
 
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH/RFC iproute2 2/3] iptunnel: add support for mpls/ip to sit tunnels
  2016-07-06 18:23 ` [PATCH/RFC iproute2 2/3] iptunnel: add support for mpls/ip to " Simon Horman
@ 2016-08-03  0:48   ` David Ahern
  0 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2016-08-03  0:48 UTC (permalink / raw)
  To: Simon Horman, netdev; +Cc: stephen

On 7/6/16 12:23 PM, Simon Horman wrote:
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
> ---
>  ip/link_iptnl.c       | 12 +++++++++++-
>  ip/tunnel.c           | 10 ++++++++++
>  man/man8/ip-link.8.in |  9 +++++----
>  3 files changed, 26 insertions(+), 5 deletions(-)
>
> diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
> index 8411a6a00a1b..34e4625b4335 100644
> --- a/ip/link_iptnl.c
> +++ b/ip/link_iptnl.c
> @@ -23,6 +23,13 @@
>  #include "ip_common.h"
>  #include "tunnel.h"
>
> +/* This should be in ip.h but it might not be.
> + * What to do?
> + */
> +#ifndef IPPROTO_MPLS
> +#define IPPROTO_MPLS 137 /* RFC 4023 */
> +#endif
> +

This is defined in iproute2's copy of linux/in.h


>  static void print_usage(FILE *f, int sit)
>  {
>  	fprintf(f, "Usage: ip link { add | set | change | replace | del } NAME\n");
> @@ -33,7 +40,7 @@ static void print_usage(FILE *f, int sit)
>  	fprintf(f, "          [ encap-sport PORT ] [ encap-dport PORT ]\n");
>  	fprintf(f, "          [ [no]encap-csum ] [ [no]encap-csum6 ] [ [no]encap-remcsum ]\n");
>  	if (sit) {
> -		fprintf(f, "          [ mode { ip6ip | ipip | any } ]\n");
> +		fprintf(f, "          [ mode { ip6ip | ipip | mplsip | any } ]\n");
>  		fprintf(f, "          [ isatap ]\n");
>  	}
>  	fprintf(f, "\n");
> @@ -222,6 +229,9 @@ get_failed:
>  				 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;
> diff --git a/ip/tunnel.c b/ip/tunnel.c
> index 7956d71aa733..760fa18a5be6 100644
> --- a/ip/tunnel.c
> +++ b/ip/tunnel.c
> @@ -37,6 +37,13 @@
>  #include "utils.h"
>  #include "tunnel.h"
>
> +/* This should be in ip.h but it might not be.
> + * What to do?
> + */
> +#ifndef IPPROTO_MPLS
> +#define IPPROTO_MPLS 137 /* RFC 4023 */
> +#endif

ditto

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-03  0:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-06 18:23 [PATCH/RFC iproute2 0/3] iptunnel: support MPLS in IPv4 and UDP Simon Horman
2016-07-06 18:23 ` [PATCH/RFC iproute2 1/3] iptunnel: document mode parameter for sit tunnels Simon Horman
2016-07-06 18:23 ` [PATCH/RFC iproute2 2/3] iptunnel: add support for mpls/ip to " Simon Horman
2016-08-03  0:48   ` David Ahern
2016-07-06 18:23 ` [PATCH/RFC iproute2 3/3] iptunnel: add support for mpls/ip to ipip tunnels Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).