ip6_gre: add support for ERSPAN tunnel
Subsystems (2)
PATCH 1/1 ip6_gre: add support for ERSPAN tunnel
The patch adds ERSPAN type II tunnel support for IPv6.
Signed-off-by William Tu <[email protected]>
--- 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(-)
ip/ipaddress.c +3 -2
@@ -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 ); }
ip/iplink.c +3 -3
@@ -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 ); }
ip/link_gre6.c +27 -1
@@ -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, +};
man/man8/ip-address.8.in +1 -0
@@ -123,6 +123,7 @@ ip-address \- protocol address management .BR erspan " |" .BR ip6gre " |" .BR ip6gretap " |" +.BR ip6erspan " |" .BR vti " |" .BR vrf " |" .BR nlmon " |"
man/man8/ip-link.8.in +4 -0
@@ -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
Signature · 1 line
2.7.4
Quoted 3 lines · On Sun, 5 Nov 2017 10:35:30 -0800 William Tu <[email protected]> wrote:
The patch adds ERSPAN type II tunnel support for IPv6.
Signed-off-by William Tu <[email protected]>
Patch does not apply cleanly against current net-next branch.
Quoted 9 lines · Stephen Hemminger
Quoted 3 lines · On Sun, 5 Nov 2017 10:35:30 -0800 William Tu <[email protected]> wrote:
The patch adds ERSPAN type II tunnel support for IPv6.
Signed-off-by William Tu <[email protected]>Patch does not apply cleanly against current net-next branch.
Sorry for the mistake. I will send v2. Thanks!
William