netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] selftest: Add selftest for multicast address notifications
@ 2025-05-27  9:18 Yuyang Huang
  2025-05-28 15:49 ` Simon Horman
  0 siblings, 1 reply; 3+ messages in thread
From: Yuyang Huang @ 2025-05-27  9:18 UTC (permalink / raw)
  To: Yuyang Huang
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Shuah Khan, netdev, linux-kselftest, linux-kernel,
	Maciej Żenczykowski, Lorenzo Colitti

This commit adds a new kernel selftest to verify RTNLGRP_IPV4_MCADDR
and RTNLGRP_IPV6_MCADDR notifications. The test works by adding and
removing a dummy interface and then confirming that the system
correctly receives join and removal notifications for the 224.0.0.1
and ff02::1 multicast addresses.

The test relies on the iproute2 version to be 6.13+.

Tested by the following command:
$ vng -v --user root --cpus 16 -- \
make -C tools/testing/selftests TARGETS=net TEST_PROGS=rtnetlink.sh \
TEST_GEN_PROGS="" run_tests

Cc: Maciej Żenczykowski <maze@google.com>
Cc: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Yuyang Huang <yuyanghuang@google.com>
---
 tools/testing/selftests/net/rtnetlink.sh | 34 ++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index 2e8243a65b50..9dbcaaeaf8cd 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -21,6 +21,7 @@ ALL_TESTS="
 	kci_test_vrf
 	kci_test_encap
 	kci_test_macsec
+	kci_test_mcast_addr_notification
 	kci_test_ipsec
 	kci_test_ipsec_offload
 	kci_test_fdb_get
@@ -1334,6 +1335,39 @@ kci_test_mngtmpaddr()
 	return $ret
 }
 
+kci_test_mcast_addr_notification()
+{
+	local tmpfile
+	local monitor_pid
+	local match_result
+
+	tmpfile=$(mktemp)
+
+	ip monitor maddr > $tmpfile &
+	monitor_pid=$!
+	sleep 1
+
+	run_cmd ip link add name test-dummy1 type dummy
+	run_cmd ip link set test-dummy1 up
+	run_cmd ip link del dev test-dummy1
+	sleep 1
+
+	match_result=$(grep -cE "test-dummy1.*(224.0.0.1|ff02::1)" $tmpfile)
+
+	kill $monitor_pid
+	rm $tmpfile
+	# There should be 4 line matches as follows.
+	# 13: test-dummy1    inet6 mcast ff02::1 scope global 
+	# 13: test-dummy1    inet mcast 224.0.0.1 scope global 
+	# Deleted 13: test-dummy1    inet mcast 224.0.0.1 scope global 
+	# Deleted 13: test-dummy1    inet6 mcast ff02::1 scope global 
+	if [ $match_result -ne 4 ];then
+		end_test "FAIL: mcast addr notification"
+		return 1
+	fi
+	end_test "PASS: mcast addr notification"
+}
+
 kci_test_rtnl()
 {
 	local current_test
-- 
2.49.0.1204.g71687c7c1d-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] selftest: Add selftest for multicast address notifications
  2025-05-27  9:18 [PATCH net-next] selftest: Add selftest for multicast address notifications Yuyang Huang
@ 2025-05-28 15:49 ` Simon Horman
  2025-05-29  1:52   ` Yuyang Huang
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2025-05-28 15:49 UTC (permalink / raw)
  To: Yuyang Huang
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Shuah Khan, netdev, linux-kselftest, linux-kernel,
	Maciej Żenczykowski, Lorenzo Colitti

On Tue, May 27, 2025 at 06:18:55PM +0900, Yuyang Huang wrote:
> This commit adds a new kernel selftest to verify RTNLGRP_IPV4_MCADDR
> and RTNLGRP_IPV6_MCADDR notifications. The test works by adding and
> removing a dummy interface and then confirming that the system
> correctly receives join and removal notifications for the 224.0.0.1
> and ff02::1 multicast addresses.
> 
> The test relies on the iproute2 version to be 6.13+.
> 
> Tested by the following command:
> $ vng -v --user root --cpus 16 -- \
> make -C tools/testing/selftests TARGETS=net TEST_PROGS=rtnetlink.sh \
> TEST_GEN_PROGS="" run_tests
> 
> Cc: Maciej Żenczykowski <maze@google.com>
> Cc: Lorenzo Colitti <lorenzo@google.com>
> Signed-off-by: Yuyang Huang <yuyanghuang@google.com>

...

> +kci_test_mcast_addr_notification()
> +{
> +	local tmpfile
> +	local monitor_pid
> +	local match_result
> +
> +	tmpfile=$(mktemp)
> +
> +	ip monitor maddr > $tmpfile &
> +	monitor_pid=$!

Hi Yuyang Huang,

Other tests in this file seem to warn if the ip command is too old
to support the test. Perhaps we can achieve that here something like this
(completely untested!):

	if [ ! -e "/proc/$monitor_pid" ]; then
		end_test "SKIP: mcast addr notification: iproute2 too old"
		rm $tmpfile
		return $ksft_skip
	fi

> +	sleep 1
> +
> +	run_cmd ip link add name test-dummy1 type dummy
> +	run_cmd ip link set test-dummy1 up
> +	run_cmd ip link del dev test-dummy1
> +	sleep 1
> +
> +	match_result=$(grep -cE "test-dummy1.*(224.0.0.1|ff02::1)" $tmpfile)
> +
> +	kill $monitor_pid
> +	rm $tmpfile
> +	# There should be 4 line matches as follows.
> +	# 13: test-dummy1    inet6 mcast ff02::1 scope global 
> +	# 13: test-dummy1    inet mcast 224.0.0.1 scope global 
> +	# Deleted 13: test-dummy1    inet mcast 224.0.0.1 scope global 
> +	# Deleted 13: test-dummy1    inet6 mcast ff02::1 scope global 
> +	if [ $match_result -ne 4 ];then
> +		end_test "FAIL: mcast addr notification"
> +		return 1
> +	fi
> +	end_test "PASS: mcast addr notification"
> +}
> +

...

## Form letter - net-next-closed

The merge window for v6.16 has begun and therefore net-next is closed
for new drivers, features, code refactoring and optimizations. We are
currently accepting bug fixes only.

Please repost when net-next reopens after June 8th.

RFC patches sent for review only are obviously welcome at any time.

pw-bot: deffer

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] selftest: Add selftest for multicast address notifications
  2025-05-28 15:49 ` Simon Horman
@ 2025-05-29  1:52   ` Yuyang Huang
  0 siblings, 0 replies; 3+ messages in thread
From: Yuyang Huang @ 2025-05-29  1:52 UTC (permalink / raw)
  To: Simon Horman
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Shuah Khan, netdev, linux-kselftest, linux-kernel,
	Maciej Żenczykowski, Lorenzo Colitti

Hi Simon

>Other tests in this file seem to warn if the ip command is too old
>to support the test. Perhaps we can achieve that here something like this
>(completely untested!):

Thanks for the advice. I will modify the test to make sure it skips on
old iproute2 versions. I will send the patch after net-next reopens.

Thanks,

Yuyang


On Thu, May 29, 2025 at 12:49 AM Simon Horman <horms@kernel.org> wrote:
>
> On Tue, May 27, 2025 at 06:18:55PM +0900, Yuyang Huang wrote:
> > This commit adds a new kernel selftest to verify RTNLGRP_IPV4_MCADDR
> > and RTNLGRP_IPV6_MCADDR notifications. The test works by adding and
> > removing a dummy interface and then confirming that the system
> > correctly receives join and removal notifications for the 224.0.0.1
> > and ff02::1 multicast addresses.
> >
> > The test relies on the iproute2 version to be 6.13+.
> >
> > Tested by the following command:
> > $ vng -v --user root --cpus 16 -- \
> > make -C tools/testing/selftests TARGETS=net TEST_PROGS=rtnetlink.sh \
> > TEST_GEN_PROGS="" run_tests
> >
> > Cc: Maciej Żenczykowski <maze@google.com>
> > Cc: Lorenzo Colitti <lorenzo@google.com>
> > Signed-off-by: Yuyang Huang <yuyanghuang@google.com>
>
> ...
>
> > +kci_test_mcast_addr_notification()
> > +{
> > +     local tmpfile
> > +     local monitor_pid
> > +     local match_result
> > +
> > +     tmpfile=$(mktemp)
> > +
> > +     ip monitor maddr > $tmpfile &
> > +     monitor_pid=$!
>
> Hi Yuyang Huang,
>
> Other tests in this file seem to warn if the ip command is too old
> to support the test. Perhaps we can achieve that here something like this
> (completely untested!):
>
>         if [ ! -e "/proc/$monitor_pid" ]; then
>                 end_test "SKIP: mcast addr notification: iproute2 too old"
>                 rm $tmpfile
>                 return $ksft_skip
>         fi
>
> > +     sleep 1
> > +
> > +     run_cmd ip link add name test-dummy1 type dummy
> > +     run_cmd ip link set test-dummy1 up
> > +     run_cmd ip link del dev test-dummy1
> > +     sleep 1
> > +
> > +     match_result=$(grep -cE "test-dummy1.*(224.0.0.1|ff02::1)" $tmpfile)
> > +
> > +     kill $monitor_pid
> > +     rm $tmpfile
> > +     # There should be 4 line matches as follows.
> > +     # 13: test-dummy1    inet6 mcast ff02::1 scope global
> > +     # 13: test-dummy1    inet mcast 224.0.0.1 scope global
> > +     # Deleted 13: test-dummy1    inet mcast 224.0.0.1 scope global
> > +     # Deleted 13: test-dummy1    inet6 mcast ff02::1 scope global
> > +     if [ $match_result -ne 4 ];then
> > +             end_test "FAIL: mcast addr notification"
> > +             return 1
> > +     fi
> > +     end_test "PASS: mcast addr notification"
> > +}
> > +
>
> ...
>
> ## Form letter - net-next-closed
>
> The merge window for v6.16 has begun and therefore net-next is closed
> for new drivers, features, code refactoring and optimizations. We are
> currently accepting bug fixes only.
>
> Please repost when net-next reopens after June 8th.
>
> RFC patches sent for review only are obviously welcome at any time.
>
> pw-bot: deffer

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-29  1:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27  9:18 [PATCH net-next] selftest: Add selftest for multicast address notifications Yuyang Huang
2025-05-28 15:49 ` Simon Horman
2025-05-29  1:52   ` Yuyang Huang

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).