From: netdev-bot+sashiko@kernel.org
To: sigefriedhyy@gmail.com
Cc: davem@davemloft.net, dsahern@kernel.org, donald.hunter@gmail.com,
edumazet@google.com, idosch@nvidia.com, kuba@kernel.org,
kuniyu@google.com, nickgarlis@gmail.com, pabeni@redhat.com,
sd@queasysnail.net, shuah@kernel.org, horms@kernel.org,
sdf.kernel@gmail.com, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 3/3] selftests: net: test AF_PACKET multicast dumps
Date: Thu, 10 Sep 2026 03:41:34 +0000 [thread overview]
Message-ID: <178901169484.219967.3624591832079760064@kernel.org> (raw)
In-Reply-To: <20260905093932.43726-4-sigefriedhyy@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 0 · Low: 1
- [Low] dump_mcaddr_l2_check() in
tools/testing/selftests/net/rtnetlink.py dereferences dictionary keys…
--
selftests: net: test AF_PACKET multicast dumps
This adds dump_mcaddr_l2_check() to the rtnetlink.py selftest, dumping the
link-layer multicast addresses of a dummy device over AF_PACKET and
checking the ifa-index filter, the all-hosts entry flags and the
SIOCADDMULTI entry flags plus mc-users. The case skips when the kernel
answers the dump with EOPNOTSUPP.
> diff --git a/tools/testing/selftests/net/rtnetlink.py b/tools/testing/selftests/net/rtnetlink.py
> index 5cc3ebdcf08de..94340dac0e217 100755
> --- a/tools/testing/selftests/net/rtnetlink.py
> +++ b/tools/testing/selftests/net/rtnetlink.py
[ ... ]
> @@ -105,6 +109,53 @@ def dump_mcaddr6_check() -> None:
> s2.close()
>
>
> +def dump_mcaddr_l2_check() -> None:
> + """
> + Verify link-layer multicast addresses in an AF_PACKET RTM_GETMULTICAST
> + dump: the ifa-index filter, mc-users and the permanent flag.
> + """
> +
> + with NetNS() as ns:
> + with NetNSEnter(str(ns)):
> + for ifname in ("dummy1", "dummy2"):
> + ip(f"link add name {ifname} type dummy")
> + ip(f"link set {ifname} up")
> + dev_idx = socket.if_nametoindex("dummy1")
> + ip(f"maddr add {ETH_TEST_MULTICAST_STR} dev dummy1")
> +
> + rtnl = RtnlAddrFamily()
> + try:
> + addresses = rtnl.getmulticast(
> + {"ifa-family": socket.AF_PACKET, "ifa-index": dev_idx},
> + dump=True)
> + except NlError as e:
> + if e.error == errno.EOPNOTSUPP:
> + raise KsftSkipEx(
> + "kernel does not support AF_PACKET multicast dump")
> + raise
> +
> + # dummy2 has entries as well, only dummy1 may be listed
> + ksft_eq({addr['ifa-index'] for addr in addresses}, {dev_idx},
> + "AF_PACKET multicast dump ignored ifa-index filter")
> +
> + entries = {addr['multicast']: addr for addr in addresses}
> +
> + # Bringing an Ethernet device up joins 224.0.0.1, which maps
> + # to 01:00:5e:00:00:01 in the device multicast list.
> + ksft_in(ETH_ALL_HOSTS_MULTICAST, entries,
> + "dummy1 does not have the all-hosts link-layer address")
> + ksft_not_in('permanent',
> + entries[ETH_ALL_HOSTS_MULTICAST]['ifa-flags'],
> + "protocol entry is permanent")
> +
> + ksft_in(ETH_TEST_MULTICAST, entries,
> + "dummy1 does not have the SIOCADDMULTI address")
> + ksft_eq(entries[ETH_TEST_MULTICAST]['mc-users'], 1,
> + "unexpected mc-users for the SIOCADDMULTI address")
> + ksft_in('permanent', entries[ETH_TEST_MULTICAST]['ifa-flags'],
> + "SIOCADDMULTI entry is not permanent")
[Severity: Low]
Can the entries[] lookups here raise KeyError in exactly the case the
preceding checks are meant to report?
ksft_in() in tools/testing/selftests/net/lib/py/ksft.py only records the
failure and returns:
def ksft_in(a, b, comment=""):
if a not in b:
_fail("Check failed", a, "not in", b, comment)
So when the dump does not contain 01:00:5e:00:00:01, execution continues
into:
entries[ETH_ALL_HOSTS_MULTICAST]['ifa-flags']
and the same applies to entries[ETH_TEST_MULTICAST] for the mc-users and
permanent checks if the SIOCADDMULTI address is missing.
ksft_run() catches this with "except BaseException" and prints a
traceback, so the case is reported as a failure, but the remaining
independent checks (mc-users == 1 and the permanent flag on the
SIOCADDMULTI entry) are never executed. Note also that the earlier
ksft_eq() on the ifa-index set does not stop the case either, so
addresses may legitimately be empty at this point.
Would it be worth following the convention already used elsewhere in this
file, where _users_for() and dump_mcaddr_check() test membership before
dereferencing:
if 'mc-users' not in matches[0]:
raise KsftSkipEx(...)
and ipv6_route_del_reason_expired() guards with ksft_not_none(attrs)
before touching attrs?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260905093932.43726-1-sigefriedhyy%40gmail.com
next prev parent reply other threads:[~2026-09-10 3:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-05 9:39 [PATCH net-next 0/3] rtnetlink: dump link-layer multicast addresses Yuyang Huang
2026-09-05 9:39 ` [PATCH net-next 1/3] rtnetlink: add AF_PACKET multicast dumps Yuyang Huang
2026-09-08 15:56 ` David Ahern
2026-09-09 1:15 ` Yuyang Huang
2026-09-10 3:41 ` netdev-bot+sashiko
2026-09-10 4:04 ` Yuyang Huang
2026-09-05 9:39 ` [PATCH net-next 2/3] netlink: specs: rt-addr: document " Yuyang Huang
2026-09-05 9:39 ` [PATCH net-next 3/3] selftests: net: test " Yuyang Huang
2026-09-10 3:41 ` netdev-bot+sashiko [this message]
2026-09-10 4:05 ` Yuyang Huang
2026-09-07 12:51 ` [PATCH net-next 0/3] rtnetlink: dump link-layer multicast addresses Nicolas Dichtel
2026-09-08 2:56 ` Yuyang Huang
2026-09-08 9:23 ` Nicolas Dichtel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178901169484.219967.3624591832079760064@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nickgarlis@gmail.com \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=sdf.kernel@gmail.com \
--cc=shuah@kernel.org \
--cc=sigefriedhyy@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.