Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] The new selftest tools/testing/selftests/net/udp_bind_conflict.c does not run several kernel paths added by the two fixes it is meant… -- selftests: net: Add UDP bind conflict tests This adds a new kselftest, udp_bind_conflict, that checks how bind() handles UDP conflicts in three cases: SO_REUSEPORT sockets, disconnect via connect(AF_UNSPEC), and devices set by connect(). It also adds the test to the net selftests Makefile and .gitignore.
> diff --git a/tools/testing/selftests/net/udp_bind_conflict.c b/tools/testing/selftests/net/udp_bind_conflict.c > new file mode 100644 > index 0000000000000..9a67f58c348ab > --- /dev/null > +++ b/tools/testing/selftests/net/udp_bind_conflict.c > @@ -0,0 +1,228 @@
[ ... ]
> +/* A device that connect() set used to count in the conflict check, so a > + * socket on another device could bind next to [::]:PORT and overlap it > + * once it disconnected. > + */ > +TEST_F(udp_bind_conflict, connect_device_ignored) > +{ > + int fd; > + > + fd = udp_bind(self, "::", 0, false); > + ASSERT_LE(0, fd); > + ASSERT_EQ(0, connect_link_local(fd, self->d0)); > + ASSERT_EQ(-EADDRINUSE, udp_bind(self, "::", self->lo, false)); > +}
[Severity: Low] This isn't a bug, but does this test reach the secondary hash half of the connect() device fix? Both sockets are bound to the wildcard "::", and there are only two sockets on the port. inet_use_hash2_on_bind() returns false for in6addr_any, and hslot->count stays well below 10. That means udp_lib_get_port() only goes through udp_lib_lport_inuse(): net/ipv4/udp.c:udp_lib_get_port() { ... if (inet_use_hash2_on_bind(sk) && hslot->count > 10) { ... } So no socket whose device was set by connect() ever reaches the udp_bound_dev_if() call in udp_lib_lport_inuse2(). The same goes for the dif2 comparison in udp_sk_reuseport_match() on that path. reuseport_scan_hash2 does scan hash2, but its devices are all set through SO_BINDTOIFINDEX. The clearing of SOCK_CONNECT_DEV in sock_bindtoindex_locked() doesn't seem to be covered either: net/core/sock.c:sock_bindtoindex_locked() { ... WRITE_ONCE(sk->sk_userlocks, sk->sk_userlocks & ~SOCK_CONNECT_DEV); ... } The series' disconnect commit describes this as "SO_BINDTODEVICE and SO_BINDTOIFINDEX drop the record". The only sequence that runs it is connect() to a link-local peer, then SO_BINDTOIFINDEX, then disconnect. None of the tests does that: - disconnect_keeps_device uses an IPv4 socket that never connects, so it never has SOCK_CONNECT_DEV set. - disconnect_keeps_scoped_device gets its device from bind(). - disconnect_clears_connect_device and connect_device_ignored never call SO_BINDTOIFINDEX after connect_link_local(). If the line above were removed, wouldn't every test here still pass? Two branches in __ip6_datagram_connect() are also not reached. The first is the rollback when ip6_datagram_dst_update() fails: err = ip6_datagram_dst_update(sk, true); if (err) { ... WRITE_ONCE(sk->sk_bound_dev_if, old_bound_dev_if); if (!old_bound_dev_if) { ... WRITE_ONCE(sk->sk_userlocks, sk->sk_userlocks & ~SOCK_CONNECT_DEV); } The second is the multicast branch that takes the device from mcast_oif: if (!sk->sk_bound_dev_if && (addr_type & IPV6_ADDR_MULTICAST)) ip6_datagram_connect_dev(sk, old_bound_dev_if, READ_ONCE(np->mcast_oif)); The commit message says these tests cover "the two bind conflict fixes in this series". Could the test add cases for these paths? For example: - a specific address with more than 10 sockets on the port, where one socket's device was set by connect() - connect(), then SO_BINDTOIFINDEX, then disconnect - a connect() that fails - a connect() to a multicast peer [ ... ]
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40gmail.com