* [patch net] sefltests: netdevsim: wait for devlink instance after netns removal
@ 2023-02-20 13:23 Jiri Pirko
2023-02-20 14:26 ` Pavan Chebbi
2023-02-21 14:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jiri Pirko @ 2023-02-20 13:23 UTC (permalink / raw)
To: netdev; +Cc: davem, kuba, linux-kselftest, shuah, amirtz
From: Jiri Pirko <jiri@nvidia.com>
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: b74c37fd35a2 ("selftests: netdevsim: add tests for devlink reload with resources")
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
.../selftests/drivers/net/netdevsim/devlink.sh | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
index a08c02abde12..7f7d20f22207 100755
--- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
+++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
@@ -17,6 +17,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
@@ -256,6 +268,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"
}
@@ -348,6 +363,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"
}
--
2.39.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch net] sefltests: netdevsim: wait for devlink instance after netns removal
2023-02-20 13:23 [patch net] sefltests: netdevsim: wait for devlink instance after netns removal Jiri Pirko
@ 2023-02-20 14:26 ` Pavan Chebbi
2023-02-21 14:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Pavan Chebbi @ 2023-02-20 14:26 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, kuba, linux-kselftest, shuah, amirtz
[-- Attachment #1: Type: text/plain, Size: 2121 bytes --]
On Mon, Feb 20, 2023 at 6:54 PM Jiri Pirko <jiri@resnulli.us> wrote:
>
> From: Jiri Pirko <jiri@nvidia.com>
>
> 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: b74c37fd35a2 ("selftests: netdevsim: add tests for devlink reload with resources")
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> ---
> .../selftests/drivers/net/netdevsim/devlink.sh | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
> index a08c02abde12..7f7d20f22207 100755
> --- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
> +++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
> @@ -17,6 +17,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
> @@ -256,6 +268,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"
> }
>
> @@ -348,6 +363,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"
> }
>
> --
> 2.39.0
>
Looks good to me.
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch net] sefltests: netdevsim: wait for devlink instance after netns removal
2023-02-20 13:23 [patch net] sefltests: netdevsim: wait for devlink instance after netns removal Jiri Pirko
2023-02-20 14:26 ` Pavan Chebbi
@ 2023-02-21 14:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-21 14:40 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, kuba, linux-kselftest, shuah, amirtz
Hello:
This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:
On Mon, 20 Feb 2023 14:23:36 +0100 you wrote:
> From: Jiri Pirko <jiri@nvidia.com>
>
> 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.
>
> [...]
Here is the summary with links:
- [net] sefltests: netdevsim: wait for devlink instance after netns removal
https://git.kernel.org/netdev/net/c/f922c7b1c1c4
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-21 14:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-20 13:23 [patch net] sefltests: netdevsim: wait for devlink instance after netns removal Jiri Pirko
2023-02-20 14:26 ` Pavan Chebbi
2023-02-21 14:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).