2 # In Namespace 0 (at_ns0) using native tunnel
3 # Overlay IP: 10.1.1.100
4 # local 192.16.1.100 remote 192.16.1.200
5 # veth0 IP: 172.16.1.100, tunnel dev <type>00
7 # Out of Namespace using BPF set/get on lwtunnel
8 # Overlay IP: 10.1.1.200
9 # local 172.16.1.200 remote 172.16.1.100
10 # veth1 IP: 172.16.1.200, tunnel dev <type>11
14 function config_device
{
16 ip link add veth0
type veth peer name veth1
17 ip link
set veth0 netns at_ns0
18 ip netns
exec at_ns0 ip addr add
172.16.1.100/24 dev veth0
19 ip netns
exec at_ns0 ip link
set dev veth0 up
20 ip link
set dev veth1 up
21 ip addr add dev veth1
172.16.1.200/24
24 function add_gre_tunnel
{
26 ip netns
exec at_ns0 \
27 ip link add dev
$DEV_NS type $TYPE key
2 local 172.16.1.100 remote
172.16.1.200
28 ip netns
exec at_ns0 ip link
set dev
$DEV_NS up
29 ip netns
exec at_ns0 ip addr add dev
$DEV_NS 10.1.1.100/24
32 ip link add dev
$DEV type $TYPE key
2 external
33 ip link
set dev
$DEV up
34 ip addr add dev
$DEV 10.1.1.200/24
37 function add_vxlan_tunnel
{
38 # Set static ARP entry here because iptables set-mark works
39 # on L3 packet, as a result not applying to ARP packets,
40 # causing errors at get_tunnel_{key/opt}.
43 ip netns
exec at_ns0 \
44 ip link add dev
$DEV_NS type $TYPE id
2 dstport
4789 gbp remote
172.16.1.200
45 ip netns
exec at_ns0 ip link
set dev
$DEV_NS address
52:54:00:d9
:01:00 up
46 ip netns
exec at_ns0 ip addr add dev
$DEV_NS 10.1.1.100/24
47 ip netns
exec at_ns0 arp
-s 10.1.1.200 52:54:00:d9
:02:00
48 ip netns
exec at_ns0 iptables
-A OUTPUT
-j MARK
--set-mark 0x800FF
51 ip link add dev
$DEV type $TYPE external gbp dstport
4789
52 ip link
set dev
$DEV address
52:54:00:d9
:02:00 up
53 ip addr add dev
$DEV 10.1.1.200/24
54 arp
-s 10.1.1.100 52:54:00:d9
:01:00
57 function add_geneve_tunnel
{
59 ip netns
exec at_ns0 \
60 ip link add dev
$DEV_NS type $TYPE id
2 dstport
6081 remote
172.16.1.200
61 ip netns
exec at_ns0 ip link
set dev
$DEV_NS up
62 ip netns
exec at_ns0 ip addr add dev
$DEV_NS 10.1.1.100/24
65 ip link add dev
$DEV type $TYPE dstport
6081 external
66 ip link
set dev
$DEV up
67 ip addr add dev
$DEV 10.1.1.200/24
74 tc qdisc add dev
$DEV clsact
75 tc filter add dev
$DEV egress bpf da obj tcbpf2_kern.o sec
$SET_TUNNEL
76 tc filter add dev
$DEV ingress bpf da obj tcbpf2_kern.o sec
$GET_TUNNEL
85 attach_bpf
$DEV gre_set_tunnel gre_get_tunnel
87 ip netns
exec at_ns0
ping -c 1 10.1.1.200
96 attach_bpf
$DEV vxlan_set_tunnel vxlan_get_tunnel
98 ip netns
exec at_ns0
ping -c 1 10.1.1.200
101 function test_geneve
{
107 attach_bpf
$DEV geneve_set_tunnel geneve_get_tunnel
109 ip netns
exec at_ns0
ping -c 1 10.1.1.200
113 ip netns delete at_ns0
118 echo "Testing GRE tunnel..."
121 echo "Testing VXLAN tunnel..."
124 echo "Testing GENEVE tunnel..."