Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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/20241119153703.71f97b76@hermes.local/

Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250717125151.466882-1-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ido Schimmel and committed by
Jakub Kicinski
25250f40 e7ce59d9

+34
+34
tools/testing/selftests/net/rtnetlink.sh
··· 30 30 kci_test_address_proto 31 31 kci_test_enslave_bonding 32 32 kci_test_mngtmpaddr 33 + kci_test_operstate 33 34 " 34 35 35 36 devdummy="test-dummy0" ··· 1343 1342 1344 1343 ip netns del "$testns" 1345 1344 return $ret 1345 + } 1346 + 1347 + kci_test_operstate() 1348 + { 1349 + local ret=0 1350 + 1351 + # Check that it is possible to set operational state during device 1352 + # creation and that it is preserved when the administrative state of 1353 + # the device is toggled. 1354 + run_cmd ip link add name vx0 up state up type vxlan id 10010 dstport 4789 1355 + run_cmd_grep "state UP" ip link show dev vx0 1356 + run_cmd ip link set dev vx0 down 1357 + run_cmd_grep "state DOWN" ip link show dev vx0 1358 + run_cmd ip link set dev vx0 up 1359 + run_cmd_grep "state UP" ip link show dev vx0 1360 + 1361 + run_cmd ip link del dev vx0 1362 + 1363 + # Check that it is possible to set the operational state of the device 1364 + # after creation. 1365 + run_cmd ip link add name vx0 up type vxlan id 10010 dstport 4789 1366 + run_cmd_grep "state UNKNOWN" ip link show dev vx0 1367 + run_cmd ip link set dev vx0 state up 1368 + run_cmd_grep "state UP" ip link show dev vx0 1369 + 1370 + run_cmd ip link del dev vx0 1371 + 1372 + if [ "$ret" -ne 0 ]; then 1373 + end_test "FAIL: operstate" 1374 + return 1 1375 + fi 1376 + 1377 + end_test "PASS: operstate" 1346 1378 } 1347 1379 1348 1380 kci_test_rtnl()