Skip to content

Commit 176a520

Browse files
Haishuang Yanhorms
authored andcommitted
selftests: netfilter: add ipvs tunnel test case
Test virtual server via ipip tunnel. Tested: # selftests: netfilter: ipvs.sh # Testing DR mode... # Testing NAT mode... # Testing Tunnel mode... # ipvs.sh: PASS ok 6 selftests: netfilter: ipvs.sh Signed-off-by: Haishuang Yan <[email protected]> Signed-off-by: Simon Horman <[email protected]>
1 parent 0ed1546 commit 176a520

File tree

1 file changed

+30
-0
lines changed
  • tools/testing/selftests/netfilter

1 file changed

+30
-0
lines changed

tools/testing/selftests/netfilter/ipvs.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,30 @@ test_nat() {
168168
test_service
169169
}
170170

171+
test_tun() {
172+
ip netns exec ns0 ip route add ${vip_v4} via ${gip_v4} dev br0
173+
174+
ip netns exec ns1 modprobe ipip
175+
ip netns exec ns1 ip link set tunl0 up
176+
ip netns exec ns1 sysctl -qw net.ipv4.ip_forward=0
177+
ip netns exec ns1 sysctl -qw net.ipv4.conf.all.send_redirects=0
178+
ip netns exec ns1 sysctl -qw net.ipv4.conf.default.send_redirects=0
179+
ip netns exec ns1 ipvsadm -A -t ${vip_v4}:${port} -s rr
180+
ip netns exec ns1 ipvsadm -a -i -t ${vip_v4}:${port} -r ${rip_v4}:${port}
181+
ip netns exec ns1 ip addr add ${vip_v4}/32 dev lo:1
182+
183+
ip netns exec ns2 modprobe ipip
184+
ip netns exec ns2 ip link set tunl0 up
185+
ip netns exec ns2 sysctl -qw net.ipv4.conf.all.arp_ignore=1
186+
ip netns exec ns2 sysctl -qw net.ipv4.conf.all.arp_announce=2
187+
ip netns exec ns2 sysctl -qw net.ipv4.conf.all.rp_filter=0
188+
ip netns exec ns2 sysctl -qw net.ipv4.conf.tunl0.rp_filter=0
189+
ip netns exec ns2 sysctl -qw net.ipv4.conf.veth21.rp_filter=0
190+
ip netns exec ns2 ip addr add ${vip_v4}/32 dev lo:1
191+
192+
test_service
193+
}
194+
171195
run_tests() {
172196
local errors=
173197

@@ -183,6 +207,12 @@ run_tests() {
183207
test_nat
184208
errors=$(( $errors + $? ))
185209

210+
echo "Testing Tunnel mode..."
211+
cleanup
212+
setup
213+
test_tun
214+
errors=$(( $errors + $? ))
215+
186216
return $errors
187217
}
188218

0 commit comments

Comments
 (0)