Commit c2a4d274 authored by Po-Hsu Lin's avatar Po-Hsu Lin Committed by David S. Miller

selftests: rtnetlink: correct the final return value for the test

The return value "ret" will be reset to 0 from the beginning of each
sub-test in rtnetlink.sh, therefore this test will always pass if the
last sub-test has passed:
    $ sudo ./rtnetlink.sh
    PASS: policy routing
    PASS: route get
    PASS: preferred_lft addresses have expired
    PASS: promote_secondaries complete
    PASS: tc htb hierarchy
    PASS: gre tunnel endpoint
    PASS: gretap
    PASS: ip6gretap
    PASS: erspan
    PASS: ip6erspan
    PASS: bridge setup
    PASS: ipv6 addrlabel
    PASS: set ifalias a39ee707-e36b-41d3-802f-63179ed4d580 for test-dummy0
    PASS: vrf
    PASS: vxlan
    FAIL: can't add fou port 7777, skipping test
    PASS: macsec
    PASS: ipsec
    3,7c3,7
    < sa[0]    spi=0x00000009 proto=0x32 salt=0x64636261 crypt=1
    < sa[0]    key=0x31323334 35363738 39303132 33343536
    < sa[1] rx ipaddr=0x00000000 00000000 00000000 c0a87b03
    < sa[1]    spi=0x00000009 proto=0x32 salt=0x64636261 crypt=1
    < sa[1]    key=0x31323334 35363738 39303132 33343536
    ---
    > sa[0]    spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1
    > sa[0]    key=0x34333231 38373635 32313039 36353433
    > sa[1] rx ipaddr=0x00000000 00000000 00000000 037ba8c0
    > sa[1]    spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1
    > sa[1]    key=0x34333231 38373635 32313039 36353433
    FAIL: ipsec_offload incorrect driver data
    FAIL: ipsec_offload
    PASS: bridge fdb get
    PASS: neigh get
    $ echo $?
    0

Make "ret" become a local variable for all sub-tests.
Also, check the sub-test results in kci_test_rtnl() and return the
final result for this test.
Signed-off-by: default avatarPo-Hsu Lin <po-hsu.lin@canonical.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0b0e2997
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
# set -e # set -e
devdummy="test-dummy0" devdummy="test-dummy0"
ret=0
# Kselftest framework requirement - SKIP code is 4. # Kselftest framework requirement - SKIP code is 4.
ksft_skip=4 ksft_skip=4
...@@ -66,7 +65,7 @@ kci_test_bridge() ...@@ -66,7 +65,7 @@ kci_test_bridge()
devbr="test-br0" devbr="test-br0"
vlandev="testbr-vlan1" vlandev="testbr-vlan1"
ret=0 local ret=0
ip link add name "$devbr" type bridge ip link add name "$devbr" type bridge
check_err $? check_err $?
...@@ -113,7 +112,7 @@ kci_test_gre() ...@@ -113,7 +112,7 @@ kci_test_gre()
rem=10.42.42.1 rem=10.42.42.1
loc=10.0.0.1 loc=10.0.0.1
ret=0 local ret=0
ip tunnel add $gredev mode gre remote $rem local $loc ttl 1 ip tunnel add $gredev mode gre remote $rem local $loc ttl 1
check_err $? check_err $?
ip link set $gredev up ip link set $gredev up
...@@ -149,7 +148,7 @@ kci_test_gre() ...@@ -149,7 +148,7 @@ kci_test_gre()
kci_test_tc() kci_test_tc()
{ {
dev=lo dev=lo
ret=0 local ret=0
tc qdisc add dev "$dev" root handle 1: htb tc qdisc add dev "$dev" root handle 1: htb
check_err $? check_err $?
...@@ -184,7 +183,7 @@ kci_test_tc() ...@@ -184,7 +183,7 @@ kci_test_tc()
kci_test_polrouting() kci_test_polrouting()
{ {
ret=0 local ret=0
ip rule add fwmark 1 lookup 100 ip rule add fwmark 1 lookup 100
check_err $? check_err $?
ip route add local 0.0.0.0/0 dev lo table 100 ip route add local 0.0.0.0/0 dev lo table 100
...@@ -207,7 +206,7 @@ kci_test_route_get() ...@@ -207,7 +206,7 @@ kci_test_route_get()
{ {
local hash_policy=$(sysctl -n net.ipv4.fib_multipath_hash_policy) local hash_policy=$(sysctl -n net.ipv4.fib_multipath_hash_policy)
ret=0 local ret=0
ip route get 127.0.0.1 > /dev/null ip route get 127.0.0.1 > /dev/null
check_err $? check_err $?
...@@ -290,7 +289,7 @@ kci_test_promote_secondaries() ...@@ -290,7 +289,7 @@ kci_test_promote_secondaries()
kci_test_addrlabel() kci_test_addrlabel()
{ {
ret=0 local ret=0
ip addrlabel add prefix dead::/64 dev lo label 1 ip addrlabel add prefix dead::/64 dev lo label 1
check_err $? check_err $?
...@@ -330,7 +329,7 @@ kci_test_addrlabel() ...@@ -330,7 +329,7 @@ kci_test_addrlabel()
kci_test_ifalias() kci_test_ifalias()
{ {
ret=0 local ret=0
namewant=$(uuidgen) namewant=$(uuidgen)
syspathname="/sys/class/net/$devdummy/ifalias" syspathname="/sys/class/net/$devdummy/ifalias"
...@@ -385,7 +384,7 @@ kci_test_ifalias() ...@@ -385,7 +384,7 @@ kci_test_ifalias()
kci_test_vrf() kci_test_vrf()
{ {
vrfname="test-vrf" vrfname="test-vrf"
ret=0 local ret=0
ip link show type vrf 2>/dev/null ip link show type vrf 2>/dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
...@@ -425,7 +424,7 @@ kci_test_vrf() ...@@ -425,7 +424,7 @@ kci_test_vrf()
kci_test_encap_vxlan() kci_test_encap_vxlan()
{ {
ret=0 local ret=0
vxlan="test-vxlan0" vxlan="test-vxlan0"
vlan="test-vlan0" vlan="test-vlan0"
testns="$1" testns="$1"
...@@ -511,7 +510,7 @@ kci_test_encap_vxlan() ...@@ -511,7 +510,7 @@ kci_test_encap_vxlan()
kci_test_encap_fou() kci_test_encap_fou()
{ {
ret=0 local ret=0
name="test-fou" name="test-fou"
testns="$1" testns="$1"
...@@ -548,7 +547,7 @@ kci_test_encap_fou() ...@@ -548,7 +547,7 @@ kci_test_encap_fou()
kci_test_encap() kci_test_encap()
{ {
testns="testns" testns="testns"
ret=0 local ret=0
ip netns add "$testns" ip netns add "$testns"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
...@@ -573,7 +572,7 @@ kci_test_encap() ...@@ -573,7 +572,7 @@ kci_test_encap()
kci_test_macsec() kci_test_macsec()
{ {
msname="test_macsec0" msname="test_macsec0"
ret=0 local ret=0
ip macsec help 2>&1 | grep -q "^Usage: ip macsec" ip macsec help 2>&1 | grep -q "^Usage: ip macsec"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
...@@ -631,7 +630,7 @@ kci_test_macsec() ...@@ -631,7 +630,7 @@ kci_test_macsec()
#------------------------------------------------------------------- #-------------------------------------------------------------------
kci_test_ipsec() kci_test_ipsec()
{ {
ret=0 local ret=0
algo="aead rfc4106(gcm(aes)) 0x3132333435363738393031323334353664636261 128" algo="aead rfc4106(gcm(aes)) 0x3132333435363738393031323334353664636261 128"
srcip=192.168.123.1 srcip=192.168.123.1
dstip=192.168.123.2 dstip=192.168.123.2
...@@ -731,7 +730,7 @@ kci_test_ipsec() ...@@ -731,7 +730,7 @@ kci_test_ipsec()
#------------------------------------------------------------------- #-------------------------------------------------------------------
kci_test_ipsec_offload() kci_test_ipsec_offload()
{ {
ret=0 local ret=0
algo="aead rfc4106(gcm(aes)) 0x3132333435363738393031323334353664636261 128" algo="aead rfc4106(gcm(aes)) 0x3132333435363738393031323334353664636261 128"
srcip=192.168.123.3 srcip=192.168.123.3
dstip=192.168.123.4 dstip=192.168.123.4
...@@ -841,7 +840,7 @@ kci_test_gretap() ...@@ -841,7 +840,7 @@ kci_test_gretap()
{ {
testns="testns" testns="testns"
DEV_NS=gretap00 DEV_NS=gretap00
ret=0 local ret=0
ip netns add "$testns" ip netns add "$testns"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
...@@ -891,7 +890,7 @@ kci_test_ip6gretap() ...@@ -891,7 +890,7 @@ kci_test_ip6gretap()
{ {
testns="testns" testns="testns"
DEV_NS=ip6gretap00 DEV_NS=ip6gretap00
ret=0 local ret=0
ip netns add "$testns" ip netns add "$testns"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
...@@ -941,7 +940,7 @@ kci_test_erspan() ...@@ -941,7 +940,7 @@ kci_test_erspan()
{ {
testns="testns" testns="testns"
DEV_NS=erspan00 DEV_NS=erspan00
ret=0 local ret=0
ip link help erspan 2>&1 | grep -q "^Usage:" ip link help erspan 2>&1 | grep -q "^Usage:"
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
...@@ -1006,7 +1005,7 @@ kci_test_ip6erspan() ...@@ -1006,7 +1005,7 @@ kci_test_ip6erspan()
{ {
testns="testns" testns="testns"
DEV_NS=ip6erspan00 DEV_NS=ip6erspan00
ret=0 local ret=0
ip link help ip6erspan 2>&1 | grep -q "^Usage:" ip link help ip6erspan 2>&1 | grep -q "^Usage:"
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
...@@ -1077,7 +1076,7 @@ kci_test_fdb_get() ...@@ -1077,7 +1076,7 @@ kci_test_fdb_get()
test_mac=de:ad:be:ef:13:37 test_mac=de:ad:be:ef:13:37
localip="10.0.2.2" localip="10.0.2.2"
dstip="10.0.2.3" dstip="10.0.2.3"
ret=0 local ret=0
bridge fdb help 2>&1 |grep -q 'bridge fdb get' bridge fdb help 2>&1 |grep -q 'bridge fdb get'
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
...@@ -1125,7 +1124,7 @@ kci_test_neigh_get() ...@@ -1125,7 +1124,7 @@ kci_test_neigh_get()
dstmac=de:ad:be:ef:13:37 dstmac=de:ad:be:ef:13:37
dstip=10.0.2.4 dstip=10.0.2.4
dstip6=dead::2 dstip6=dead::2
ret=0 local ret=0
ip neigh help 2>&1 |grep -q 'ip neigh get' ip neigh help 2>&1 |grep -q 'ip neigh get'
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
...@@ -1175,6 +1174,7 @@ kci_test_neigh_get() ...@@ -1175,6 +1174,7 @@ kci_test_neigh_get()
kci_test_rtnl() kci_test_rtnl()
{ {
local ret=0
kci_add_dummy kci_add_dummy
if [ $ret -ne 0 ];then if [ $ret -ne 0 ];then
echo "FAIL: cannot add dummy interface" echo "FAIL: cannot add dummy interface"
...@@ -1182,27 +1182,48 @@ kci_test_rtnl() ...@@ -1182,27 +1182,48 @@ kci_test_rtnl()
fi fi
kci_test_polrouting kci_test_polrouting
check_err $?
kci_test_route_get kci_test_route_get
check_err $?
kci_test_addrlft kci_test_addrlft
check_err $?
kci_test_promote_secondaries kci_test_promote_secondaries
check_err $?
kci_test_tc kci_test_tc
check_err $?
kci_test_gre kci_test_gre
check_err $?
kci_test_gretap kci_test_gretap
check_err $?
kci_test_ip6gretap kci_test_ip6gretap
check_err $?
kci_test_erspan kci_test_erspan
check_err $?
kci_test_ip6erspan kci_test_ip6erspan
check_err $?
kci_test_bridge kci_test_bridge
check_err $?
kci_test_addrlabel kci_test_addrlabel
check_err $?
kci_test_ifalias kci_test_ifalias
check_err $?
kci_test_vrf kci_test_vrf
check_err $?
kci_test_encap kci_test_encap
check_err $?
kci_test_macsec kci_test_macsec
check_err $?
kci_test_ipsec kci_test_ipsec
check_err $?
kci_test_ipsec_offload kci_test_ipsec_offload
check_err $?
kci_test_fdb_get kci_test_fdb_get
check_err $?
kci_test_neigh_get kci_test_neigh_get
check_err $?
kci_del_dummy kci_del_dummy
return $ret
} }
#check for needed privileges #check for needed privileges
...@@ -1221,4 +1242,4 @@ done ...@@ -1221,4 +1242,4 @@ done
kci_test_rtnl kci_test_rtnl
exit $ret exit $?
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