gre: introduce native tunnel support for ERSPAN
Subsystems (3)
PATCH 1/1 gre: introduce native tunnel support for ERSPAN
The patch adds ERSPAN type II tunnel support. The implementation is based on the draft at [1]. One of the purposes is for Linux box to be able to receive ERSPAN monitoring traffic sent from the Cisco switch, by creating a ERSPAN tunnel device. In addition, the patch also adds ERSPAN TX, so traffic can also be encapsulated into ERSPAN and sent out.
The implementation reuses tunnel key as ERSPAN session ID, and field 'erspan' as ERSPAN Index fields:
./ip link add dev ers11 type erspan seq key 100 erspan 123 \
local 172.16.1.200 remote 172.16.1.100
[1] https://tools.ietf.org/html/draft-foschiano-erspan-01
The change to the iproute2 will be submitted in a separate patch. I use the following script to create end-to-end ERSPAN tunnel test.
#!/bin/bash
# In the namespace NS0, create veth0 and erspan00 # Out of the namespace, create veth1 and erspan11 # Ping in and out of namespace using ERSPAN protocol
# Namespace0:
# - erspan00
# IP: 10.1.1.100
# local 192.16.1.100 remote 192.16.1.200 # - veth0 # IP: 172.16.1.100
# Out of namespace:
# - erspan11
# IP: 10.1.1.200
# local 172.16.1.200 remote 172.16.1.100 # - veth1 # IP: 172.16.1.200
set -ex
TYPE=erspan
DEV_NS=erspan00
DEV=erspan11
cleanup() {
set +ex
ip netns del ns0
ip link del erspan11
ip link del veth1
}
trap cleanup 0 2 3 9
ip netns add ns0
ip link add veth0 type veth peer name veth1
ip link set veth0 netns ns0
ip netns exec ns0 ip addr add 172.16.1.100/24 dev veth0 ip netns exec ns0 ip link set dev veth0 up
# Tunnel
ip netns exec ns0 ip link add dev $DEV_NS type $TYPE \
key 1 seq local 172.16.1.100 remote 172.16.1.200 erspan 123
ip netns exec ns0 ip addr add dev $DEV_NS 10.1.1.100/24 ip netns exec ns0 ip link set dev $DEV_NS up
# Linux
ip link set dev veth1 up
ip addr add dev veth1 172.16.1.200/24
ip link add dev $DEV type $TYPE seq key 1 \
local 172.16.1.200 remote 172.16.1.100 erspan 123
ip addr add dev $DEV 10.1.1.200/24
ip link set dev $DEV up
# Ping from NS0
ip netns exec ns0 ping -c 3 10.1.1.200
ping -c 3 10.1.1.100
exit 0
# End
Thanks a lot!
William Tu (1):
gre: introduce native tunnel support for ERSPAN
include/net/ip_tunnels.h | 3 + include/uapi/linux/if_ether.h | 1 + include/uapi/linux/if_tunnel.h | 1 + net/ipv4/ip_gre.c | 248 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 253 insertions(+)
Signature · 1 line
2.7.4
PATCH 1/1 gre: introduce native tunnel support for ERSPAN
The patch adds ERSPAN type II tunnel support. The implementation is based on the draft at [1]. One of the purposes is for Linux box to be able to receive ERSPAN monitoring traffic sent from the Cisco switch, by creating a ERSPAN tunnel device. In addition, the patch also adds ERSPAN TX, so traffic can also be encapsulated into ERSPAN and sent out.
The implementation reuses the key as ERSPAN session ID, and field 'erspan' as ERSPAN Index fields:
./ip link add dev ers11 type erspan seq key 100 erspan 123 \
local 172.16.1.200 remote 172.16.1.100
[1] https://tools.ietf.org/html/draft-foschiano-erspan-01
--- include/net/ip_tunnels.h | 3 + include/uapi/linux/if_ether.h | 1 + include/uapi/linux/if_tunnel.h | 1 + net/ipv4/ip_gre.c | 248 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 253 insertions(+)
include/net/ip_tunnels.h +3 -0
@@ -115,6 +115,9 @@ struct ip_tunnel {u32 o_seqno;/* The last output seqno */ int tun_hlen;/* Precalculated header length */ +/* This field used only by ERSPAN */ +u32 index;/* ERSPAN type II index */ +struct dst_cache dst_cache;struct ip_tunnel_parm parms;
include/uapi/linux/if_ether.h +1 -0
@@ -66,6 +66,7 @@#define ETH_P_ATALK 0x809B/* Appletalk DDP */ #define ETH_P_AARP 0x80F3/* Appletalk AARP */ #define ETH_P_8021Q 0x8100/* 802.1Q VLAN Extended Header */ +#define ETH_P_ERSPAN 0x88BE/* ERSPAN type II */ #define ETH_P_IPX 0x8137/* IPX over DIX */ #define ETH_P_IPV6 0x86DD/* IPv6 over bluebook */ #define ETH_P_PAUSE 0x8808/* IEEE Pause frames. See 802.3 31B */
include/uapi/linux/if_tunnel.h +1 -0
@@ -134,6 +134,7 @@ enum {IFLA_GRE_COLLECT_METADATA ,IFLA_GRE_IGNORE_DF ,IFLA_GRE_FWMARK , +IFLA_GRE_ERSPAN_INDEX , __IFLA_GRE_MAX, };
net/ipv4/ip_gre.c +248 -0
359 lines not on this page · raw message
Signature · 1 line
2.7.4
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/William-Tu/gre-introduce-native-tunnel-support-for-ERSPAN/20170811-210323 config: x86_64-allyesdebian (attached as .config) compiler: gcc-6 (Debian…
Hi William,
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/William-Tu/gre-introduce-native-tunnel-support-for-ERSPAN/20170811-210323
config: x86_64-allyesdebian (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 All errors (new ones prefixed by >>):
>> net//ipv4/ip_gre.c:51:24: fatal error: net/erspan.h: No such file or directory
#include <net/erspan.h>
^compilation terminated.
vim +51 net//ipv4/ip_gre.c
35
36 #include <net/sock.h>
37 #include <net/ip.h>
38 #include <net/icmp.h>
39 #include <net/protocol.h>
40 #include <net/ip_tunnels.h>
41 #include <net/arp.h>
42 #include <net/checksum.h>
43 #include <net/dsfield.h>
44 #include <net/inet_ecn.h>
45 #include <net/xfrm.h>
46 #include <net/net_namespace.h>
47 #include <net/netns/generic.h>
48 #include <net/rtnetlink.h>
49 #include <net/gre.h>
50 #include <net/dst_metadata.h>
> 51 #include <net/erspan.h>
52 ---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation