Skip to content

Commit

Permalink
sefltests: netdevsim: wait for devlink instance after netns removal
Browse files Browse the repository at this point in the history
[ 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 <amirtz@nvidia.com>
Fixes: b74c37f ("selftests: netdevsim: add tests for devlink reload with resources")
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Link: https://lore.kernel.org/r/20230220132336.198597-1-jiri@resnulli.us
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Jiri Pirko authored and Sasha Levin committed Mar 10, 2023
1 parent 255ec1f commit 812baac
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tools/testing/selftests/drivers/net/netdevsim/devlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV_NAME/net/
DEBUGFS_DIR=/sys/kernel/debug/netdevsim/$DEV_NAME/
DL_HANDLE=netdevsim/$DEV_NAME

wait_for_devlink()
{
"$@" | grep -q $DL_HANDLE
}

devlink_wait()
{
local timeout=$1

busywait "$timeout" wait_for_devlink devlink dev
}

fw_flash_test()
{
RET=0
Expand Down Expand Up @@ -255,6 +267,9 @@ netns_reload_test()
ip netns del testns2
ip netns del testns1

# Wait until netns async cleanup is done.
devlink_wait 2000

log_test "netns reload test"
}

Expand Down Expand Up @@ -347,6 +362,9 @@ resource_test()
ip netns del testns2
ip netns del testns1

# Wait until netns async cleanup is done.
devlink_wait 2000

log_test "resource test"
}

Expand Down

0 comments on commit 812baac

Please sign in to comment.