Subject: Re: [PATCH v2] selftests/net: team: add team unregister test

From: Ido Schimmel <[email-masked]>
Date: Sun, 22 Feb 2026 17:32:09 +0200

On Sun, Feb 22, 2026 at 10:17:42PM +0900, Tetsuo Handa wrote:
> Add selftest for "team: avoid NETDEV_CHANGEMTU event when unregistering
> slave" patch.

1. Repost the entire series (fix + selftest).
2. Tag as "[PATCH net vX]".
3. Wait 24h before reposting.
4. Post as a new thread instead of as a reply to an existing thread.

See more info here:

https://docs.kernel.org/process/maintainer-netdev.html

> 
> Signed-off-by: Tetsuo Handa <[email-masked]>
> ---
> v2:
>  - Removed unexpectedly-copied Copyright line.
> 
>  tools/testing/selftests/net/team/Makefile     |  7 ++++++
>  .../selftests/net/team/team_unregister.sh     | 23 +++++++++++++++++++
>  2 files changed, 30 insertions(+)
>  create mode 100644 tools/testing/selftests/net/team/Makefile
>  create mode 100755 tools/testing/selftests/net/team/team_unregister.sh

The team selftests are under tools/testing/selftests/drivers/net/team/,
so this one should be added there as well

> 
> diff --git a/tools/testing/selftests/net/team/Makefile b/tools/testing/selftests/net/team/Makefile
> new file mode 100644
> index 000000000000..aa8ef0590022
> --- /dev/null
> +++ b/tools/testing/selftests/net/team/Makefile
> @@ -0,0 +1,7 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +top_srcdir = ../../../../..
> +
> +TEST_PROGS := team_unregister.sh
> +
> +include ../../lib.mk
> diff --git a/tools/testing/selftests/net/team/team_unregister.sh b/tools/testing/selftests/net/team/team_unregister.sh
> new file mode 100755
> index 000000000000..cfa710237d8b
> --- /dev/null
> +++ b/tools/testing/selftests/net/team/team_unregister.sh
> @@ -0,0 +1,23 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +source ../lib.sh
> +
> +NS_NAME="ns-"$RANDOM
> +TEAM_NAME="team-"$RANDOM
> +DUMMY_NAME="dummy-"$RANDOM

No need for "$RANDOM" if you use setup_ns() to create namespaces with a
randomized name.

> +
> +cleanup() {
> +    cleanup_ns $NS_NAME

Quote variables to avoid shellcheck warnings

> +    ip link del $TEAM_NAME
> +}
> +
> +trap cleanup EXIT
> +ip link add name $TEAM_NAME type team
> +ip link add name $DUMMY_NAME mtu 1499 master $TEAM_NAME type dummy
> +ip netns add $NS_NAME
> +echo "Setting $DUMMY_NAME to $NS_NAME"
> +ip link set dev $DUMMY_NAME netns $NS_NAME
> +echo "Deleting $DUMMY_NAME from $NS_NAME"
> +ip -n $NS_NAME link del dev $DUMMY_NAME
> +echo "Test completed successfully."

This patch [1] works for me (hangs without the fix):

# make -C tools/testing/selftests TARGETS="drivers/net/team" TEST_PROGS=refleak.sh TEST_GEN_PROGS="" run_tests
make: Entering directory '/home/idosch/code/linux/tools/testing/selftests'
make[1]: Nothing to be done for 'all'.
TAP version 13
1..1
# timeout set to 45
# selftests: drivers/net/team: refleak.sh
ok 1 selftests: drivers/net/team: refleak.sh

[1]
diff --git a/tools/testing/selftests/drivers/net/team/Makefile b/tools/testing/selftests/drivers/net/team/Makefile
index 1340b3df9c31..45a3e7ad3dcb 100644
--- a/tools/testing/selftests/drivers/net/team/Makefile
+++ b/tools/testing/selftests/drivers/net/team/Makefile
@@ -5,6 +5,7 @@ TEST_PROGS := \
 	dev_addr_lists.sh \
 	options.sh \
 	propagation.sh \
+	refleak.sh \
 # end of TEST_PROGS
 
 TEST_INCLUDES := \
diff --git a/tools/testing/selftests/drivers/net/team/refleak.sh b/tools/testing/selftests/drivers/net/team/refleak.sh
new file mode 100755
index 000000000000..53675be04965
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/team/refleak.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+lib_dir=$(dirname "$0")
+source "$lib_dir"/../../../net/lib.sh
+
+trap cleanup_all_ns EXIT
+
+# Test that there is no reference count leak and that dummy1 can be deleted.
+# https://lore.kernel.org/netdev/[email-masked]/
+setup_ns ns1 ns2
+ip -n "$ns1" link add name team1 type team
+ip -n "$ns1" link add name dummy1 mtu 1499 type dummy
+ip -n "$ns1" link set dev dummy1 master team1
+ip -n "$ns1" link set dev dummy1 netns "$ns2"
+ip -n "$ns2" link del dev dummy1