Skip to content

Commit 0ed1546

Browse files
Haishuang Yanhorms
authored andcommitted
selftests: netfilter: add ipvs nat test case
Test virtual server via NAT. Tested: # selftests: netfilter: ipvs.sh # Testing DR mode... # Testing NAT mode... # ipvs.sh: PASS Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com> Signed-off-by: Simon Horman <horms@verge.net.au>
1 parent 867d219 commit 0ed1546

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

  • tools/testing/selftests/netfilter

‎tools/testing/selftests/netfilter/ipvs.sh‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,40 @@ test_dr() {
154154
test_service
155155
}
156156

157+
test_nat() {
158+
ip netns exec ns0 ip route add ${vip_v4} via ${gip_v4} dev br0
159+
160+
ip netns exec ns1 sysctl -qw net.ipv4.ip_forward=1
161+
ip netns exec ns1 ipvsadm -A -t ${vip_v4}:${port} -s rr
162+
ip netns exec ns1 ipvsadm -a -m -t ${vip_v4}:${port} -r ${rip_v4}:${port}
163+
ip netns exec ns1 ip addr add ${vip_v4}/32 dev lo:1
164+
165+
ip netns exec ns2 ip link del veth20
166+
ip netns exec ns2 ip route add default via ${dip_v4} dev veth21
167+
168+
test_service
169+
}
170+
157171
run_tests() {
158172
local errors=
159173

160174
echo "Testing DR mode..."
175+
cleanup
161176
setup
162177
test_dr
163178
errors=$(( $errors + $? ))
164179

180+
echo "Testing NAT mode..."
181+
cleanup
182+
setup
183+
test_nat
184+
errors=$(( $errors + $? ))
185+
165186
return $errors
166187
}
167188

168189
trap cleanup EXIT
169190

170-
cleanup
171191
run_tests
172192

173193
if [ $? -ne 0 ]; then

0 commit comments

Comments
 (0)