[PATCH iproute2 net-next 0/2] Add support for seg6 l2encap mode

STALE3340d SUPERSEDED

Revision v1 of 2 in this series.

6 messages, 2 authors, 2017-08-28 · open the first message on its own page

[PATCH iproute2 net-next 0/2] Add support for seg6 l2encap mode

From: David Lebrun <hidden>
Date: 2017-08-28 19:04:56

This patch series adds support for the new L2ENCAP mode for SRv6
encapsulations.

David Lebrun (2):
  iproute: add support for seg6 l2encap mode
  man: add documentation for seg6 l2encap mode

 ip/iproute_lwtunnel.c  | 39 ++++++++++++++++++++++++++++-----------
 man/man8/ip-route.8.in |  6 +++++-
 2 files changed, 33 insertions(+), 12 deletions(-)

-- 
2.10.2

[PATCH iproute2 net-next 1/2] iproute: add support for seg6 l2encap mode

From: David Lebrun <hidden>
Date: 2017-08-28 19:04:57

This patch adds support for the L2ENCAP seg6 mode, enabling to encapsulate
L2 frames within SRv6 packets.

Signed-off-by: David Lebrun <redacted>
---
 ip/iproute_lwtunnel.c | 39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index 14294c6..f125670 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -110,6 +110,30 @@ static void print_srh(FILE *fp, struct ipv6_sr_hdr *srh)
 	}
 }
 
+static const char *format_seg6mode_type(int mode)
+{
+	if (mode == SEG6_IPTUN_MODE_ENCAP)
+		return "encap";
+	else if (mode == SEG6_IPTUN_MODE_INLINE)
+		return "inline";
+	else if (mode == SEG6_IPTUN_MODE_L2ENCAP)
+		return "l2encap";
+
+	return "<unknown>";
+}
+
+static int read_seg6mode_type(const char *mode)
+{
+	if (strcmp(mode, "encap") == 0)
+		return SEG6_IPTUN_MODE_ENCAP;
+	else if (strcmp(mode, "inline") == 0)
+		return SEG6_IPTUN_MODE_INLINE;
+	else if (strcmp(mode, "l2encap") == 0)
+		return SEG6_IPTUN_MODE_L2ENCAP;
+
+	return -1;
+}
+
 static void print_encap_seg6(FILE *fp, struct rtattr *encap)
 {
 	struct rtattr *tb[SEG6_IPTUNNEL_MAX+1];
@@ -121,8 +145,7 @@ static void print_encap_seg6(FILE *fp, struct rtattr *encap)
 		return;
 
 	tuninfo = RTA_DATA(tb[SEG6_IPTUNNEL_SRH]);
-	fprintf(fp, "mode %s ",
-		(tuninfo->mode == SEG6_IPTUN_MODE_ENCAP) ? "encap" : "inline");
+	fprintf(fp, "mode %s ", format_seg6mode_type(tuninfo->mode));
 
 	print_srh(fp, tuninfo->srh);
 }
@@ -457,11 +480,8 @@ static int parse_encap_seg6(struct rtattr *rta, size_t len, int *argcp,
 			NEXT_ARG();
 			if (mode_ok++)
 				duparg2("mode", *argv);
-			if (strcmp(*argv, "encap") == 0)
-				encap = 1;
-			else if (strcmp(*argv, "inline") == 0)
-				encap = 0;
-			else
+			encap = read_seg6mode_type(*argv);
+			if (encap < 0)
 				invarg("\"mode\" value is invalid\n", *argv);
 		} else if (strcmp(*argv, "segs") == 0) {
 			NEXT_ARG();
@@ -490,10 +510,7 @@ static int parse_encap_seg6(struct rtattr *rta, size_t len, int *argcp,
 	tuninfo = malloc(sizeof(*tuninfo) + srhlen);
 	memset(tuninfo, 0, sizeof(*tuninfo) + srhlen);
 
-	if (encap)
-		tuninfo->mode = SEG6_IPTUN_MODE_ENCAP;
-	else
-		tuninfo->mode = SEG6_IPTUN_MODE_INLINE;
+	tuninfo->mode = encap;
 
 	memcpy(tuninfo->srh, srh, srhlen);
 
-- 
2.10.2

[PATCH iproute2 net-next 2/2] man: add documentation for seg6 l2encap mode

From: David Lebrun <hidden>
Date: 2017-08-28 19:04:57

This patch adds documentation for the seg6 L2ENCAP encapsulation mode.

Signed-off-by: David Lebrun <redacted>
---
 man/man8/ip-route.8.in | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in
index 11dd9d0..803de3b 100644
--- a/man/man8/ip-route.8.in
+++ b/man/man8/ip-route.8.in
@@ -214,7 +214,7 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
 .IR ENCAP_SEG6 " := "
 .B seg6
 .BR mode " [ "
-.BR encap " | " inline " ] "
+.BR encap " | " inline " | " l2encap " ] "
 .B segs
 .IR SEGMENTS " [ "
 .B hmac
@@ -750,6 +750,10 @@ is a set of encapsulation attributes specific to the
 - Encapsulate packet in an outer IPv6 header with SRH
 .sp
 
+.B mode l2encap
+- Encapsulate ingress L2 frame within an outer IPv6 header and SRH
+.sp
+
 .I SEGMENTS
 - List of comma-separated IPv6 addresses
 .sp
-- 
2.10.2

Re: [PATCH iproute2 net-next 1/2] iproute: add support for seg6 l2encap mode

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2017-08-28 19:07:27

On Mon, 28 Aug 2017 20:05:24 +0100
David Lebrun [off-list ref] wrote:
quoted hunk
 
+static const char *format_seg6mode_type(int mode)
+{
+	if (mode == SEG6_IPTUN_MODE_ENCAP)
+		return "encap";
+	else if (mode == SEG6_IPTUN_MODE_INLINE)
+		return "inline";
+	else if (mode == SEG6_IPTUN_MODE_L2ENCAP)
+		return "l2encap";
+
+	return "<unknown>";
+}
+
+static int read_seg6mode_type(const char *mode)
+{
+	if (strcmp(mode, "encap") == 0)
+		return SEG6_IPTUN_MODE_ENCAP;
+	else if (strcmp(mode, "inline") == 0)
+		return SEG6_IPTUN_MODE_INLINE;
+	else if (strcmp(mode, "l2encap") == 0)
+		return SEG6_IPTUN_MODE_L2ENCAP;
+
+	return -1;
+}
Since these values probably will grow over time, it would make
sense to have this a name/value table.

Re: [PATCH iproute2 net-next 1/2] iproute: add support for seg6 l2encap mode

From: David Lebrun <hidden>
Date: 2017-08-28 19:11:31

On 08/28/2017 08:07 PM, Stephen Hemminger wrote:
Since these values probably will grow over time, it would make
sense to have this a name/value table.
I wasn't sure if it was worth it for 3 values. I do not foresee a large
growth either, but I will send a v2 will a table anyway

David

Re: [PATCH iproute2 net-next 1/2] iproute: add support for seg6 l2encap mode

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2017-08-28 19:32:46

On Mon, 28 Aug 2017 20:11:59 +0100
David Lebrun [off-list ref] wrote:
On 08/28/2017 08:07 PM, Stephen Hemminger wrote:
quoted
Since these values probably will grow over time, it would make
sense to have this a name/value table.  
I wasn't sure if it was worth it for 3 values. I do not foresee a large
growth either, but I will send a v2 will a table anyway

David
Either way, not a big worry.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help