[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1509906930-42639-1-git-send-email-u9012063@gmail.com>
Date: Sun, 5 Nov 2017 10:35:30 -0800
From: William Tu <u9012063@...il.com>
To: netdev@...r.kernel.org
Subject: [PATCH net-next iproute2] ip6_gre: add support for ERSPAN tunnel
The patch adds ERSPAN type II tunnel support for IPv6.
Signed-off-by: William Tu <u9012063@...il.com>
---
ip/ipaddress.c | 5 +++--
ip/iplink.c | 6 +++---
ip/link_gre6.c | 28 +++++++++++++++++++++++++++-
man/man8/ip-address.8.in | 1 +
man/man8/ip-link.8.in | 4 ++++
5 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 9e9a7e0a6477..c0cd66538ea2 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -77,8 +77,9 @@ static void usage(void)
fprintf(stderr, "LFT := forever | SECONDS\n");
fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n");
fprintf(stderr, " bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan | lowpan |\n");
- fprintf(stderr, " gre | gretap | erspan | ip6gre | ip6gretap | vti | nlmon | can |\n");
- fprintf(stderr, " bond_slave | ipvlan | geneve | bridge_slave | vrf | hsr | macsec }\n");
+ fprintf(stderr, " gre | gretap | erspan | ip6gre | ip6gretap | ip6erspan | vti |\n");
+ fprintf(stderr, " nlmon | can | bond_slave | ipvlan | geneve | bridge_slave |\n");
+ fprintf(stderr, " hsr | macsec\n");
exit(-1);
}
diff --git a/ip/iplink.c b/ip/iplink.c
index 6a96ea9ff56a..be41749af036 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -112,9 +112,9 @@ void iplink_usage(void)
"\n"
"TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n"
" bridge | bond | team | ipoib | ip6tnl | ipip | sit | vxlan |\n"
- " gre | gretap | erspan | ip6gre | ip6gretap | vti | nlmon |\n"
- " team_slave | bond_slave | ipvlan | geneve | bridge_slave |\n"
- " vrf | macsec }\n");
+ " gre | gretap | erspan | ip6gre | ip6gretap | ip6erspan |\n"
+ " vti | nlmon | team_slave | bond_slave | ipvlan | geneve |\n"
+ " bridge_slave | vrf | macsec }\n");
}
exit(-1);
}
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 7d07932a60f0..a738739ff1e8 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -33,7 +33,7 @@
static void print_usage(FILE *f)
{
fprintf(f,
- "Usage: ... { ip6gre | ip6gretap } [ remote ADDR ]\n"
+ "Usage: ... { ip6gre | ip6gretap | ip6erspan} [ remote ADDR ]\n"
" [ local ADDR ]\n"
" [ [i|o]seq ]\n"
" [ [i|o]key KEY ]\n"
@@ -52,6 +52,7 @@ static void print_usage(FILE *f)
" [ [no]encap-csum ]\n"
" [ [no]encap-csum6 ]\n"
" [ [no]encap-remcsum ]\n"
+ " [ erspan IDX ]\n"
"\n"
"Where: ADDR := IPV6_ADDRESS\n"
" TTL := { 0..255 } (default=%d)\n"
@@ -106,6 +107,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
__u16 encapdport = 0;
int len;
__u32 fwmark = 0;
+ __u32 erspan_idx = 0;
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
if (rtnl_talk(&rth, &req.n, &req.n, sizeof(req)) < 0) {
@@ -180,6 +182,9 @@ get_failed:
if (greinfo[IFLA_GRE_FWMARK])
fwmark = rta_getattr_u32(greinfo[IFLA_GRE_FWMARK]);
+
+ if (greinfo[IFLA_GRE_ERSPAN_INDEX])
+ erspan_idx = rta_getattr_u32(greinfo[IFLA_GRE_ERSPAN_INDEX]);
}
while (argc > 0) {
@@ -369,6 +374,12 @@ get_failed:
encap_limit = uval;
flags &= ~IP6_TNL_F_IGN_ENCAP_LIMIT;
}
+ } else if (strcmp(*argv, "erspan") == 0) {
+ NEXT_ARG();
+ if (get_u32(&erspan_idx, *argv, 0))
+ invarg("invalid erspan index\n", *argv);
+ if (erspan_idx & ~((1<<20) - 1) || erspan_idx == 0)
+ invarg("erspan index must be > 0 and <= 20-bit\n", *argv);
} else
usage();
argc--; argv++;
@@ -387,6 +398,8 @@ get_failed:
addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
+ if (erspan_idx != 0)
+ addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
@@ -554,6 +567,11 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
}
}
+ if (tb[IFLA_GRE_ERSPAN_INDEX]) {
+ __u32 erspan_idx = rta_getattr_u32(tb[IFLA_GRE_ERSPAN_INDEX]);
+ fprintf(f, "erspan_index %u ", erspan_idx);
+ }
+
if (tb[IFLA_GRE_ENCAP_TYPE] &&
rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) {
__u16 type = rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]);
@@ -636,3 +654,11 @@ struct link_util ip6gretap_link_util = {
.print_opt = gre_print_opt,
.print_help = gre_print_help,
};
+
+struct link_util ip6erspan_link_util = {
+ .id = "ip6erspan",
+ .maxattr = IFLA_GRE_MAX,
+ .parse_opt = gre_parse_opt,
+ .print_opt = gre_print_opt,
+ .print_help = gre_print_help,
+};
diff --git a/man/man8/ip-address.8.in b/man/man8/ip-address.8.in
index 988a79652f6f..eaa179c6de91 100644
--- a/man/man8/ip-address.8.in
+++ b/man/man8/ip-address.8.in
@@ -123,6 +123,7 @@ ip-address \- protocol address management
.BR erspan " |"
.BR ip6gre " |"
.BR ip6gretap " |"
+.BR ip6erspan " |"
.BR vti " |"
.BR vrf " |"
.BR nlmon " |"
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index d96ee28815a7..e4c5346104aa 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -205,6 +205,7 @@ ip-link \- network device configuration
.BR erspan " |"
.BR ip6gre " |"
.BR ip6gretap " |"
+.BR ip6erspan " |"
.BR vti " |"
.BR nlmon " |"
.BR ipvlan " |"
@@ -308,6 +309,9 @@ Link types:
.BR ip6gretap
- Virtual L2 tunnel interface GRE over IPv6
.sp
+.BR ip6erspan
+- Encapsulated Remote SPAN over GRE and IPv6
+.sp
.BR vti
- Virtual tunnel interface
.sp
--
2.7.4
Powered by blists - more mailing lists