All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/4] ERSPAN version 2 (type III) support
@ 2017-12-14  0:38 William Tu
  2017-12-14  0:38 ` [PATCH net-next 1/4] net: erspan: refactor existing erspan code William Tu
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: William Tu @ 2017-12-14  0:38 UTC (permalink / raw)
  To: netdev

ERSPAN has two versions, v1 (type II) and v2 (type III).  This patch
series add support for erspan v2 based on existing erspan v1
implementation.  The first patch refactors the existing erspan v1's
header structure, making it extensible to put additional v2's header.
The second and third patch introduces erspan v2's implementation to
ipv4 and ipv6 erspan, for both native mode and collect metadata mode.
Finally, test cases are added under the samples/bpf.

Note:
ERSPAN version 2 has many features and this patch does not implement
all.  One major use case of version 2 over version 1 is its timestamp
and direction.  So the traffic collector is able to distinguish the
mirrorred traffic better.  Other features such as SGT (security group
tag), FT (frame type) for carrying non-ethernet packet, and optional
subheader are not implemented yet.

Example commandline for ERSPAN version 2:
ip link add dev ip6erspan11 type ip6erspan seq key 102 \ 
	local fc00:100::2 remote fc00:100::1 \        
	erspan_ver 2 erspan_dir 1 erspan_hwid 17

The corresponding iproute2 patch:
https://marc.info/?l=linux-netdev&m=151321141525106&w=2

William Tu (4):
  net: erspan: refactor existing erspan code
  net: erspan: introduce erspan v2 for ip_gre
  ip6_gre: add erspan v2 support
  samples/bpf: add erspan v2 sample code

 include/net/erspan.h           | 152 ++++++++++++++++++++++++++++++++++++++---
 include/net/ip6_tunnel.h       |   3 +
 include/net/ip_tunnels.h       |   5 +-
 include/uapi/linux/if_ether.h  |   1 +
 include/uapi/linux/if_tunnel.h |   3 +
 net/ipv4/ip_gre.c              | 124 +++++++++++++++++++++++++++------
 net/ipv6/ip6_gre.c             | 139 +++++++++++++++++++++++++++++++------
 net/openvswitch/flow_netlink.c |   8 +--
 samples/bpf/tcbpf2_kern.c      |  77 ++++++++++++++++++---
 samples/bpf/test_tunnel_bpf.sh |  38 ++++++++---
 10 files changed, 472 insertions(+), 78 deletions(-)

--
A simple script to test it:
#!/bin/bash
# In the namespace NS0, create veth0 and ip6erspan00
# Out of the namespace, create veth1 and ip6erspan11
# Ping in and out of namespace using ERSPAN protocol 

set -ex
function cleanup() {
	set +ex
	ip netns del ns0
	ip link del ip6erspan11
	ip link del veth1
}

function main() {
	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

	# non-namespace
	ip addr add dev veth1 fc00:100::2/96

	if [ "$1" == "v1" ]; then
		echo "create IP6 ERSPAN v1 tunnel"
		ip link add dev ip6erspan11 type ip6erspan seq key 102 \
			local fc00:100::2 remote fc00:100::1 \
			erspan 123 erspan_ver 1
	else	
		echo "create IP6 ERSPAN v2 tunnel"
		ip link add dev ip6erspan11 type ip6erspan seq key 102 \
			local fc00:100::2 remote fc00:100::1 \
			erspan_ver 2 erspan_dir 1 erspan_hwid 17
	fi
	ip addr add dev ip6erspan11 fc00:200::2/96
	ip addr add dev ip6erspan11 10.10.200.2/24

	# namespace: ns0 
	ip netns exec ns0 ip addr add fc00:100::1/96 dev veth0

	if [ "$1" == "v1" ]; then
		ip netns exec ns0 \
		ip link add dev ip6erspan00 type ip6erspan seq key 102 \
			local fc00:100::1 remote fc00:100::2 \
			erspan 123 erspan_ver 1
	else
		ip netns exec ns0 \
		ip link add dev ip6erspan00 type ip6erspan seq key 102 \
			local fc00:100::1 remote fc00:100::2 \
			erspan_ver 2 erspan_dir 1 erspan_hwid 7
	fi

	ip netns exec ns0 ip addr add dev ip6erspan00 fc00:200::1/96
	ip netns exec ns0 ip addr add dev ip6erspan00 10.10.200.1/24

	ip link set dev veth1 up
	ip link set dev ip6erspan11 up
	ip netns exec ns0 ip link set dev ip6erspan00 up
	ip netns exec ns0 ip link set dev veth0 up
}

main $1

# Ping underlying
ping6 -c 1 fc00:100::1 || true

# ping overlay
ping -c 3 10.10.200.1
exit 0

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-12-15 17:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-14  0:38 [PATCH net-next 0/4] ERSPAN version 2 (type III) support William Tu
2017-12-14  0:38 ` [PATCH net-next 1/4] net: erspan: refactor existing erspan code William Tu
2017-12-14  0:38 ` [PATCH net-next 2/4] net: erspan: introduce erspan v2 for ip_gre William Tu
2017-12-14  0:38 ` [PATCH net-next 3/4] ip6_gre: add erspan v2 support William Tu
2017-12-14  0:38 ` [PATCH net-next 4/4] samples/bpf: add erspan v2 sample code William Tu
2017-12-14  1:54 ` [PATCH net-next 0/4] ERSPAN version 2 (type III) support Stephen Hemminger
2017-12-14  2:08   ` William Tu
2017-12-15 17:34 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.