99# local 172.16.1.200 remote 172.16.1.100
1010# veth1 IP: 172.16.1.200, tunnel dev <type>11
1111
12- set -e
13-
1412function config_device {
1513 ip netns add at_ns0
1614 ip link add veth0 type veth peer name veth1
1715 ip link set veth0 netns at_ns0
1816 ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0
1917 ip netns exec at_ns0 ip link set dev veth0 up
20- ip link set dev veth1 up
18+ ip link set dev veth1 up mtu 1500
2119 ip addr add dev veth1 172.16.1.200/24
2220}
2321
@@ -67,6 +65,19 @@ function add_geneve_tunnel {
6765 ip addr add dev $DEV 10.1.1.200/24
6866}
6967
68+ function add_ipip_tunnel {
69+ # in namespace
70+ ip netns exec at_ns0 \
71+ ip link add dev $DEV_NS type $TYPE local 172.16.1.100 remote 172.16.1.200
72+ ip netns exec at_ns0 ip link set dev $DEV_NS up
73+ ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
74+
75+ # out of namespace
76+ ip link add dev $DEV type $TYPE external
77+ ip link set dev $DEV up
78+ ip addr add dev $DEV 10.1.1.200/24
79+ }
80+
7081function attach_bpf {
7182 DEV=$1
7283 SET_TUNNEL=$2
@@ -85,6 +96,7 @@ function test_gre {
8596 attach_bpf $DEV gre_set_tunnel gre_get_tunnel
8697 ping -c 1 10.1.1.100
8798 ip netns exec at_ns0 ping -c 1 10.1.1.200
99+ cleanup
88100}
89101
90102function test_vxlan {
@@ -96,6 +108,7 @@ function test_vxlan {
96108 attach_bpf $DEV vxlan_set_tunnel vxlan_get_tunnel
97109 ping -c 1 10.1.1.100
98110 ip netns exec at_ns0 ping -c 1 10.1.1.200
111+ cleanup
99112}
100113
101114function test_geneve {
@@ -107,21 +120,48 @@ function test_geneve {
107120 attach_bpf $DEV geneve_set_tunnel geneve_get_tunnel
108121 ping -c 1 10.1.1.100
109122 ip netns exec at_ns0 ping -c 1 10.1.1.200
123+ cleanup
124+ }
125+
126+ function test_ipip {
127+ TYPE=ipip
128+ DEV_NS=ipip00
129+ DEV=ipip11
130+ config_device
131+ tcpdump -nei veth1 &
132+ cat /sys/kernel/debug/tracing/trace_pipe &
133+ add_ipip_tunnel
134+ ethtool -K veth1 gso off gro off rx off tx off
135+ ip link set dev veth1 mtu 1500
136+ attach_bpf $DEV ipip_set_tunnel ipip_get_tunnel
137+ ping -c 1 10.1.1.100
138+ ip netns exec at_ns0 ping -c 1 10.1.1.200
139+ ip netns exec at_ns0 iperf -sD -p 5200 > /dev/null
140+ sleep 0.2
141+ iperf -c 10.1.1.100 -n 5k -p 5200
142+ cleanup
110143}
111144
112145function cleanup {
146+ set +ex
147+ pkill iperf
113148 ip netns delete at_ns0
114149 ip link del veth1
115- ip link del $DEV
150+ ip link del ipip11
151+ ip link del gretap11
152+ ip link del geneve11
153+ pkill tcpdump
154+ pkill cat
155+ set -ex
116156}
117157
158+ cleanup
118159echo " Testing GRE tunnel..."
119160test_gre
120- cleanup
121161echo " Testing VXLAN tunnel..."
122162test_vxlan
123- cleanup
124163echo " Testing GENEVE tunnel..."
125164test_geneve
126- cleanup
127- echo " Success"
165+ echo " Testing IPIP tunnel..."
166+ test_ipip
167+ echo " *** PASS ***"
0 commit comments