From: netdev-bot+sashiko@kernel.org
To: kalash@nexthop.ai
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, corbet@lwn.net,
skhan@linuxfoundation.org, rdunlap@infradead.org,
dsahern@kernel.org, idosch@nvidia.com, ncardwell@google.com,
kuniyu@google.com, shuah@kernel.org, joel.granados@kernel.org,
netdev@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/2] tcp: add net.ipv4.tcp_l3mdev_exempt_ports sysctl
Date: Thu, 26 Nov 2026 21:20:25 +0000 [thread overview]
Message-ID: <179572802536.3135.6305865608768923950@kernel.org> (raw)
In-Reply-To: <20261125-tcp-l3mdev-exempt-ports-v2-1-b920f3ff8f5e@nexthop.ai>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit message names the real cause of the misselection:
the lookup returns whichever reuseport listener is first in the listen…
- [Low] The new net_cachelines documentation row lists
sysctl_tcp_l3mdev_exempt_ports as an RX fast-path field:…
--
tcp: add net.ipv4.tcp_l3mdev_exempt_ports sysctl
This commit adds a per-netns port bitmap sysctl,
net.ipv4.tcp_l3mdev_exempt_ports. For listed ports, an unbound listener
does not match connections that arrive through an L3 master device
(sdif != 0) during listener lookup, even with tcp_l3mdev_accept=1. The
goal is for VRF connections to reach the VRF-bound listener when both
listeners use SO_REUSEPORT.
> diff --git a/Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst b/Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst
> index 2833ce6cba1d4..062153c2793c7 100644
> --- a/Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst
> +++ b/Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst
> @@ -150,6 +150,7 @@ struct_ping_group_range ping_group_range
> atomic_t dev_addr_genid
> unsigned_int sysctl_udp_child_hash_entries
> unsigned_long* sysctl_local_reserved_ports
> +unsigned_long* sysctl_tcp_l3mdev_exempt_ports read_mostly __inet_lookup_listener/inet6_lookup_listener
[Severity: Low]
This row marks sysctl_tcp_l3mdev_exempt_ports as read_mostly on the RX
fast path. In struct netns_ipv4, though, the field is added to the
CONFIG_SYSCTL area next to sysctl_local_reserved_ports. That is outside
the netns_ipv4_read_rx group:
include/net/netns/ipv4.h:
__cacheline_group_begin(netns_ipv4_read_rx);
u8 sysctl_tcp_moderate_rcvbuf;
u8 sysctl_ip_early_demux;
u8 sysctl_tcp_early_demux;
u8 sysctl_tcp_l3mdev_accept;
...
__cacheline_group_end(netns_ipv4_read_rx);
netns_ipv4_struct_check() in net/core/net_namespace.c also has no
CACHELINE_ASSERT_GROUP_MEMBER() for it. Other read_mostly RX fields,
such as sysctl_tcp_l3mdev_accept, do have one.
Should the document leave the fast path columns empty for this field?
Or should the field move into netns_ipv4_read_rx with a matching
assertion?
> int sysctl_ip_prot_sock
> struct_mr_table* mrt
> struct_list_head mr_tables
[ ... ]
> diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
> index 860145d810ed4..063f6dd00a64d 100644
> --- a/net/ipv4/inet_hashtables.c
> +++ b/net/ipv4/inet_hashtables.c
> @@ -362,6 +362,11 @@ static inline int compute_score(struct sock *sk, const struct net *net,
>
> if (!inet_sk_bound_dev_eq(net, sk->sk_bound_dev_if, dif, sdif))
> return -1;
> +
> + if (!sk->sk_bound_dev_if && sdif &&
> + tcp_port_l3mdev_exempt(net, hnum))
> + return -1;
> +
> score = sk->sk_bound_dev_if ? 2 : 1;
[Severity: Medium]
The commit message gives the cause of the misselection: "the lookup
returns whichever is first in the listen bucket, not the VRF-bound one".
Is a per-port opt-in sysctl the right fix for that, rather than a change
to the lookup itself?
The early return is in inet_lhash2_lookup():
sk_nulls_for_each_rcu(sk, node, &ilb2->nulls_head) {
score = compute_score(sk, net, hnum, daddr, dif, sdif);
if (score > hiscore) {
result = inet_lookup_reuseport(net, sk, skb, doff,
saddr, sport, daddr, hnum, inet_ehashfn);
if (result)
return result;
The first reuseport socket that scores above zero is returned at once,
and the rest of the bucket is never scored. So the higher score for a
device-bound listener (sk->sk_bound_dev_if ? 2 : 1) has no effect.
inet6_lhash2_lookup() has the same early return.
inet_reuseport_add_sock() requires sk2->sk_bound_dev_if ==
sk->sk_bound_dev_if, so the unbound and bound listeners are always in
separate reuseport groups.
inet_hash() puts AF_INET6 reuseport sockets at the tail of the bucket
and all other sockets at the head. That explains the IPv4/IPv6
difference.
With this patch the default list is empty. For every port that is not
listed, the IPv4/IPv6 inconsistency and the TCP-MD5/AO bypass from the
commit message still happen.
The new check is also gated on sdif. What about the same setup without
a VRF? For example:
- an unbound SO_REUSEPORT listener and an SO_BINDTODEVICE(eth0)
SO_REUSEPORT listener on the same port
- a SYN arrives on eth0, so sdif == 0
inet_bound_dev_eq() matches both sockets. The unbound listener can still
win when it is first in the bucket, whatever the sysctl is set to.
Selecting purely by score has caveats of its own. The sk_incoming_cpu
bonus can raise an unbound IPv6 listener to the score of a bound one
(1+1 vs 2). Changing the default lookup behavior could also affect
existing deployments.
Could the commit message explain why a new UAPI knob was chosen instead
of fixing the selection order in inet_lhash2_lookup() and
inet6_lhash2_lookup()?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125-tcp-l3mdev-exempt-ports-v2-0-b920f3ff8f5e%40nexthop.ai
next prev parent reply other threads:[~2026-11-26 21:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 21:17 [PATCH net-next v2 0/2] tcp: add net.ipv4.tcp_l3mdev_exempt_ports sysctl Kalash Nainwal via B4 Relay
2026-11-25 21:17 ` [PATCH net-next v2 1/2] " Kalash Nainwal via B4 Relay
2026-11-26 21:20 ` netdev-bot+sashiko [this message]
2026-11-25 21:17 ` [PATCH net-next v2 2/2] selftests: net: add tcp_l3mdev_exempt_ports test Kalash Nainwal via B4 Relay
2026-11-26 21:20 ` netdev-bot+sashiko
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=179572802536.3135.6305865608768923950@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=joel.granados@kernel.org \
--cc=kalash@nexthop.ai \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox