* [PATCH iproute2 net-next v2 0/2] Add support for seg6 l2encap mode
@ 2017-08-28 19:26 David Lebrun
2017-08-28 19:26 ` [PATCH iproute2 net-next v2 1/2] iproute: add " David Lebrun
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: David Lebrun @ 2017-08-28 19:26 UTC (permalink / raw)
To: netdev; +Cc: David Lebrun
This patch series adds support for the new L2ENCAP mode for SRv6
encapsulations.
v2: use a name/value table for encap modes
David Lebrun (2):
iproute: add support for seg6 l2encap mode
man: add documentation for seg6 l2encap mode
ip/iproute_lwtunnel.c | 41 ++++++++++++++++++++++++++++++-----------
man/man8/ip-route.8.in | 6 +++++-
2 files changed, 35 insertions(+), 12 deletions(-)
--
2.10.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH iproute2 net-next v2 1/2] iproute: add support for seg6 l2encap mode
2017-08-28 19:26 [PATCH iproute2 net-next v2 0/2] Add support for seg6 l2encap mode David Lebrun
@ 2017-08-28 19:26 ` David Lebrun
2017-08-28 19:26 ` [PATCH iproute2 net-next v2 2/2] man: add documentation " David Lebrun
2017-08-30 15:30 ` [PATCH iproute2 net-next v2 0/2] Add support " Stephen Hemminger
2 siblings, 0 replies; 4+ messages in thread
From: David Lebrun @ 2017-08-28 19:26 UTC (permalink / raw)
To: netdev; +Cc: David Lebrun
This patch adds support for the L2ENCAP seg6 mode, enabling to encapsulate
L2 frames within SRv6 packets.
Signed-off-by: David Lebrun <david.lebrun@uclouvain.be>
---
ip/iproute_lwtunnel.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index 14294c6..02f36ef 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -110,6 +110,32 @@ static void print_srh(FILE *fp, struct ipv6_sr_hdr *srh)
}
}
+static const char *seg6_mode_types[] = {
+ [SEG6_IPTUN_MODE_INLINE] = "inline",
+ [SEG6_IPTUN_MODE_ENCAP] = "encap",
+ [SEG6_IPTUN_MODE_L2ENCAP] = "l2encap",
+};
+
+static const char *format_seg6mode_type(int mode)
+{
+ if (mode < 0 || mode > ARRAY_SIZE(seg6_mode_types))
+ return "<unknown>";
+
+ return seg6_mode_types[mode];
+}
+
+static int read_seg6mode_type(const char *mode)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(seg6_mode_types); i++) {
+ if (strcmp(mode, seg6_mode_types[i]) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
static void print_encap_seg6(FILE *fp, struct rtattr *encap)
{
struct rtattr *tb[SEG6_IPTUNNEL_MAX+1];
@@ -121,8 +147,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 +482,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 +512,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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH iproute2 net-next v2 2/2] man: add documentation for seg6 l2encap mode
2017-08-28 19:26 [PATCH iproute2 net-next v2 0/2] Add support for seg6 l2encap mode David Lebrun
2017-08-28 19:26 ` [PATCH iproute2 net-next v2 1/2] iproute: add " David Lebrun
@ 2017-08-28 19:26 ` David Lebrun
2017-08-30 15:30 ` [PATCH iproute2 net-next v2 0/2] Add support " Stephen Hemminger
2 siblings, 0 replies; 4+ messages in thread
From: David Lebrun @ 2017-08-28 19:26 UTC (permalink / raw)
To: netdev; +Cc: David Lebrun
This patch adds documentation for the seg6 L2ENCAP encapsulation mode.
Signed-off-by: David Lebrun <david.lebrun@uclouvain.be>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH iproute2 net-next v2 0/2] Add support for seg6 l2encap mode
2017-08-28 19:26 [PATCH iproute2 net-next v2 0/2] Add support for seg6 l2encap mode David Lebrun
2017-08-28 19:26 ` [PATCH iproute2 net-next v2 1/2] iproute: add " David Lebrun
2017-08-28 19:26 ` [PATCH iproute2 net-next v2 2/2] man: add documentation " David Lebrun
@ 2017-08-30 15:30 ` Stephen Hemminger
2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2017-08-30 15:30 UTC (permalink / raw)
To: David Lebrun; +Cc: netdev
On Mon, 28 Aug 2017 20:26:38 +0100
David Lebrun <david.lebrun@uclouvain.be> wrote:
> This patch series adds support for the new L2ENCAP mode for SRv6
> encapsulations.
>
> v2: use a name/value table for encap modes
>
> David Lebrun (2):
> iproute: add support for seg6 l2encap mode
> man: add documentation for seg6 l2encap mode
>
> ip/iproute_lwtunnel.c | 41 ++++++++++++++++++++++++++++++-----------
> man/man8/ip-route.8.in | 6 +++++-
> 2 files changed, 35 insertions(+), 12 deletions(-)
>
Applied to net-next
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-30 15:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-28 19:26 [PATCH iproute2 net-next v2 0/2] Add support for seg6 l2encap mode David Lebrun
2017-08-28 19:26 ` [PATCH iproute2 net-next v2 1/2] iproute: add " David Lebrun
2017-08-28 19:26 ` [PATCH iproute2 net-next v2 2/2] man: add documentation " David Lebrun
2017-08-30 15:30 ` [PATCH iproute2 net-next v2 0/2] Add support " Stephen Hemminger
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).