Commit d3b6b111 authored by Hangbin Liu's avatar Hangbin Liu Committed by David S. Miller

selftests/net: convert rtnetlink.sh to run it in unique namespace

When running the test in namespace, the debugfs may not load automatically.
So add a checking to make sure debugfs loaded. Here is the test result
after conversion.

 # ./rtnetlink.sh
 PASS: policy routing
 PASS: route get
 ...
 PASS: address proto IPv4
 PASS: address proto IPv6
Acked-by: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f6476ded
...@@ -35,8 +35,7 @@ VERBOSE=0 ...@@ -35,8 +35,7 @@ VERBOSE=0
PAUSE=no PAUSE=no
PAUSE_ON_FAIL=no PAUSE_ON_FAIL=no
# Kselftest framework requirement - SKIP code is 4. source lib.sh
ksft_skip=4
# set global exit status, but never reset nonzero one. # set global exit status, but never reset nonzero one.
check_err() check_err()
...@@ -517,9 +516,8 @@ kci_test_encap_fou() ...@@ -517,9 +516,8 @@ kci_test_encap_fou()
# test various encap methods, use netns to avoid unwanted interference # test various encap methods, use netns to avoid unwanted interference
kci_test_encap() kci_test_encap()
{ {
testns="testns"
local ret=0 local ret=0
run_cmd ip netns add "$testns" setup_ns testns
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
end_test "SKIP encap tests: cannot add net namespace $testns" end_test "SKIP encap tests: cannot add net namespace $testns"
return $ksft_skip return $ksft_skip
...@@ -574,6 +572,10 @@ kci_test_macsec_offload() ...@@ -574,6 +572,10 @@ kci_test_macsec_offload()
return $ksft_skip return $ksft_skip
fi fi
if ! mount | grep -q debugfs; then
mount -t debugfs none /sys/kernel/debug/ &> /dev/null
fi
# setup netdevsim since dummydev doesn't have offload support # setup netdevsim since dummydev doesn't have offload support
if [ ! -w /sys/bus/netdevsim/new_device ] ; then if [ ! -w /sys/bus/netdevsim/new_device ] ; then
run_cmd modprobe -q netdevsim run_cmd modprobe -q netdevsim
...@@ -738,6 +740,10 @@ kci_test_ipsec_offload() ...@@ -738,6 +740,10 @@ kci_test_ipsec_offload()
sysfsnet=/sys/bus/netdevsim/devices/netdevsim0/net/ sysfsnet=/sys/bus/netdevsim/devices/netdevsim0/net/
probed=false probed=false
if ! mount | grep -q debugfs; then
mount -t debugfs none /sys/kernel/debug/ &> /dev/null
fi
# setup netdevsim since dummydev doesn't have offload support # setup netdevsim since dummydev doesn't have offload support
if [ ! -w /sys/bus/netdevsim/new_device ] ; then if [ ! -w /sys/bus/netdevsim/new_device ] ; then
run_cmd modprobe -q netdevsim run_cmd modprobe -q netdevsim
...@@ -836,11 +842,10 @@ EOF ...@@ -836,11 +842,10 @@ EOF
kci_test_gretap() kci_test_gretap()
{ {
testns="testns"
DEV_NS=gretap00 DEV_NS=gretap00
local ret=0 local ret=0
run_cmd ip netns add "$testns" setup_ns testns
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
end_test "SKIP gretap tests: cannot add net namespace $testns" end_test "SKIP gretap tests: cannot add net namespace $testns"
return $ksft_skip return $ksft_skip
...@@ -878,11 +883,10 @@ kci_test_gretap() ...@@ -878,11 +883,10 @@ kci_test_gretap()
kci_test_ip6gretap() kci_test_ip6gretap()
{ {
testns="testns"
DEV_NS=ip6gretap00 DEV_NS=ip6gretap00
local ret=0 local ret=0
run_cmd ip netns add "$testns" setup_ns testns
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
end_test "SKIP ip6gretap tests: cannot add net namespace $testns" end_test "SKIP ip6gretap tests: cannot add net namespace $testns"
return $ksft_skip return $ksft_skip
...@@ -920,7 +924,6 @@ kci_test_ip6gretap() ...@@ -920,7 +924,6 @@ kci_test_ip6gretap()
kci_test_erspan() kci_test_erspan()
{ {
testns="testns"
DEV_NS=erspan00 DEV_NS=erspan00
local ret=0 local ret=0
run_cmd_grep "^Usage:" ip link help erspan run_cmd_grep "^Usage:" ip link help erspan
...@@ -928,7 +931,7 @@ kci_test_erspan() ...@@ -928,7 +931,7 @@ kci_test_erspan()
end_test "SKIP: erspan: iproute2 too old" end_test "SKIP: erspan: iproute2 too old"
return $ksft_skip return $ksft_skip
fi fi
run_cmd ip netns add "$testns" setup_ns testns
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
end_test "SKIP erspan tests: cannot add net namespace $testns" end_test "SKIP erspan tests: cannot add net namespace $testns"
return $ksft_skip return $ksft_skip
...@@ -970,7 +973,6 @@ kci_test_erspan() ...@@ -970,7 +973,6 @@ kci_test_erspan()
kci_test_ip6erspan() kci_test_ip6erspan()
{ {
testns="testns"
DEV_NS=ip6erspan00 DEV_NS=ip6erspan00
local ret=0 local ret=0
run_cmd_grep "^Usage:" ip link help ip6erspan run_cmd_grep "^Usage:" ip link help ip6erspan
...@@ -978,7 +980,7 @@ kci_test_ip6erspan() ...@@ -978,7 +980,7 @@ kci_test_ip6erspan()
end_test "SKIP: ip6erspan: iproute2 too old" end_test "SKIP: ip6erspan: iproute2 too old"
return $ksft_skip return $ksft_skip
fi fi
run_cmd ip netns add "$testns" setup_ns testns
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
end_test "SKIP ip6erspan tests: cannot add net namespace $testns" end_test "SKIP ip6erspan tests: cannot add net namespace $testns"
return $ksft_skip return $ksft_skip
...@@ -1022,8 +1024,6 @@ kci_test_ip6erspan() ...@@ -1022,8 +1024,6 @@ kci_test_ip6erspan()
kci_test_fdb_get() kci_test_fdb_get()
{ {
IP="ip -netns testns"
BRIDGE="bridge -netns testns"
brdev="test-br0" brdev="test-br0"
vxlandev="vxlan10" vxlandev="vxlan10"
test_mac=de:ad:be:ef:13:37 test_mac=de:ad:be:ef:13:37
...@@ -1037,11 +1037,13 @@ kci_test_fdb_get() ...@@ -1037,11 +1037,13 @@ kci_test_fdb_get()
return $ksft_skip return $ksft_skip
fi fi
run_cmd ip netns add testns setup_ns testns
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
end_test "SKIP fdb get tests: cannot add net namespace $testns" end_test "SKIP fdb get tests: cannot add net namespace $testns"
return $ksft_skip return $ksft_skip
fi fi
IP="ip -netns $testns"
BRIDGE="bridge -netns $testns"
run_cmd $IP link add "$vxlandev" type vxlan id 10 local $localip \ run_cmd $IP link add "$vxlandev" type vxlan id 10 local $localip \
dstport 4789 dstport 4789
run_cmd $IP link add name "$brdev" type bridge run_cmd $IP link add name "$brdev" type bridge
...@@ -1052,7 +1054,7 @@ kci_test_fdb_get() ...@@ -1052,7 +1054,7 @@ kci_test_fdb_get()
run_cmd_grep "dev $vxlandev master $brdev" $BRIDGE fdb get $test_mac br "$brdev" run_cmd_grep "dev $vxlandev master $brdev" $BRIDGE fdb get $test_mac br "$brdev"
run_cmd_grep "dev $vxlandev dst $dstip" $BRIDGE fdb get $test_mac dev "$vxlandev" self run_cmd_grep "dev $vxlandev dst $dstip" $BRIDGE fdb get $test_mac dev "$vxlandev" self
ip netns del testns &>/dev/null ip netns del $testns &>/dev/null
if [ $ret -ne 0 ]; then if [ $ret -ne 0 ]; then
end_test "FAIL: bridge fdb get" end_test "FAIL: bridge fdb get"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment