Skip to content

Commit 643086a

Browse files
Jiri Pirkogregkh
authored andcommitted
sefltests: netdevsim: wait for devlink instance after netns removal
[ Upstream commit f922c7b ] When devlink instance is put into network namespace and that network namespace gets deleted, devlink instance is moved back into init_ns. This is done as a part of cleanup_net() routine. Since cleanup_net() is called asynchronously from workqueue, there is no guarantee that the devlink instance move is done after "ip netns del" returns. So fix this race by making sure that the devlink instance is present before any other operation. Reported-by: Amir Tzin <[email protected]> Fixes: b74c37f ("selftests: netdevsim: add tests for devlink reload with resources") Signed-off-by: Jiri Pirko <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 94d263f commit 643086a

File tree

1 file changed

+18
-0
lines changed
  • tools/testing/selftests/drivers/net/netdevsim

1 file changed

+18
-0
lines changed

tools/testing/selftests/drivers/net/netdevsim/devlink.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV_NAME/net/
1616
DEBUGFS_DIR=/sys/kernel/debug/netdevsim/$DEV_NAME/
1717
DL_HANDLE=netdevsim/$DEV_NAME
1818

19+
wait_for_devlink()
20+
{
21+
"$@" | grep -q $DL_HANDLE
22+
}
23+
24+
devlink_wait()
25+
{
26+
local timeout=$1
27+
28+
busywait "$timeout" wait_for_devlink devlink dev
29+
}
30+
1931
fw_flash_test()
2032
{
2133
RET=0
@@ -255,6 +267,9 @@ netns_reload_test()
255267
ip netns del testns2
256268
ip netns del testns1
257269

270+
# Wait until netns async cleanup is done.
271+
devlink_wait 2000
272+
258273
log_test "netns reload test"
259274
}
260275

@@ -347,6 +362,9 @@ resource_test()
347362
ip netns del testns2
348363
ip netns del testns1
349364

365+
# Wait until netns async cleanup is done.
366+
devlink_wait 2000
367+
350368
log_test "resource test"
351369
}
352370

0 commit comments

Comments
 (0)