Skip to content

Commit 25250f4

Browse files
idoschkuba-moo
authored andcommitted
selftests: rtnetlink: Add operational state test
Virtual devices (e.g., VXLAN) that do not have a notion of a carrier are created with an "UNKNOWN" operational state which some users find confusing [1]. It is possible to set the operational state from user space either during device creation or afterwards and some applications will start doing that in order to avoid the above problem. Add a test for this functionality to ensure it does not regress. [1] https://lore.kernel.org/netdev/[email protected]/ Reviewed-by: Petr Machata <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e7ce59d commit 25250f4

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tools/testing/selftests/net/rtnetlink.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ ALL_TESTS="
3030
kci_test_address_proto
3131
kci_test_enslave_bonding
3232
kci_test_mngtmpaddr
33+
kci_test_operstate
3334
"
3435

3536
devdummy="test-dummy0"
@@ -1344,6 +1345,39 @@ kci_test_mngtmpaddr()
13441345
return $ret
13451346
}
13461347

1348+
kci_test_operstate()
1349+
{
1350+
local ret=0
1351+
1352+
# Check that it is possible to set operational state during device
1353+
# creation and that it is preserved when the administrative state of
1354+
# the device is toggled.
1355+
run_cmd ip link add name vx0 up state up type vxlan id 10010 dstport 4789
1356+
run_cmd_grep "state UP" ip link show dev vx0
1357+
run_cmd ip link set dev vx0 down
1358+
run_cmd_grep "state DOWN" ip link show dev vx0
1359+
run_cmd ip link set dev vx0 up
1360+
run_cmd_grep "state UP" ip link show dev vx0
1361+
1362+
run_cmd ip link del dev vx0
1363+
1364+
# Check that it is possible to set the operational state of the device
1365+
# after creation.
1366+
run_cmd ip link add name vx0 up type vxlan id 10010 dstport 4789
1367+
run_cmd_grep "state UNKNOWN" ip link show dev vx0
1368+
run_cmd ip link set dev vx0 state up
1369+
run_cmd_grep "state UP" ip link show dev vx0
1370+
1371+
run_cmd ip link del dev vx0
1372+
1373+
if [ "$ret" -ne 0 ]; then
1374+
end_test "FAIL: operstate"
1375+
return 1
1376+
fi
1377+
1378+
end_test "PASS: operstate"
1379+
}
1380+
13471381
kci_test_rtnl()
13481382
{
13491383
local current_test

0 commit comments

Comments
 (0)