Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net,
	netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
	edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg
Subject: Re: [PATCH net 10/11] ipvs: do not create conns from packets with port 0
Date: Tue, 17 Nov 2026 01:40:33 +0000	[thread overview]
Message-ID: <179487963329.3136.11227226787276094605@kernel.org> (raw)
In-Reply-To: <20261116004404.2821183-11-pablo@netfilter.org>

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] udp_conn_schedule() (net/netfilter/ipvs/ip_vs_proto_udp.c) now
  drops every UDP packet with source or destination port 0 that matches…
- [Low] The commit message explains rejecting cport 0 (the NO_CPORT
  lookup requirement makes such connections impossible to find again),…

--

ipvs: do not create conns from packets with port 0

This commit makes tcp_conn_schedule(), udp_conn_schedule() and
sctp_conn_schedule() drop new packets that match a virtual service when
either the source or the destination port is 0. It also makes
ip_vs_new_conn_out() refuse to create connections for client port 0. The
stated reason is that cport 0 connections cannot be found again because
of the NO_CPORT lookup requirement, so a new connection gets created for
every packet.

Link: https://sashiko.dev/#/patchset/20261104201530.147292-1-ja%40ssi.bg
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261103140308.591690-3-pablo%40netfilter.org
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260925141115.16126-1-axel.mierczuk%401password.com

> diff --git a/net/netfilter/ipvs/ip_vs_proto_tcp.c b/net/netfilter/ipvs/ip_vs_proto_tcp.c
> index fec0e8b47b716..25d4576d0e129 100644
> --- a/net/netfilter/ipvs/ip_vs_proto_tcp.c
> +++ b/net/netfilter/ipvs/ip_vs_proto_tcp.c

[ ... ]

> @@ -74,6 +75,12 @@ tcp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
>  	if (svc) {
>  		int ignored;
>  
> +		/* Do not create connection for port 0 */
> +		if (!ports[0] || !ports[1]) {
> +			*verdict = NF_DROP;
> +			return 0;
> +		}

[Severity: Low]
The commit message gives a reason for rejecting cport 0, then says "Do
the same for vport 0." without giving one. Does the duplicate connection
problem apply to the virtual port at all?

__ip_vs_conn_in_get() compares vport with plain equality. Only p->cport
takes part in the XOR:

	if (p->cport == cp->cport &&
	    p->vport == cp->vport && cp->af == p->af &&
	    ...
	    (!p->cport ^
	     (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) &&

ip_vs_conn_out_get() also matches the server side port with plain
equality. Its XOR uses p->vport, which in the out direction is the client
port:

	if (p->cport == sport && cp->af == p->af &&
	    ...
	    (!p->vport ^
	     (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) &&

So a hashed connection with vport 0 and a non-zero cport looks like it
can still be found, and would not be duplicated on every packet.

Before this patch, packets to destination port 0 that hit fwmark services
or persistent port-zero services were scheduled and forwarded. The
!ports[1] check (or !ports[0] in the inverse case) now drops them. The
same check is in udp_conn_schedule() and sctp_conn_schedule().

If this is meant as a policy change, for example because port 0 is not
valid on the wire, could the commit message say so? That would help
reviewers and stable backporters judge it.

[ ... ]

> diff --git a/net/netfilter/ipvs/ip_vs_proto_udp.c b/net/netfilter/ipvs/ip_vs_proto_udp.c
> index f32785682402d..ab3ab95241687 100644
> --- a/net/netfilter/ipvs/ip_vs_proto_udp.c
> +++ b/net/netfilter/ipvs/ip_vs_proto_udp.c
> @@ -62,6 +62,12 @@ udp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
>  	if (svc) {
>  		int ignored;
>  
> +		/* Do not create connection for port 0 */
> +		if (!ports[0] || !ports[1]) {
> +			*verdict = NF_DROP;
> +			return 0;
> +		}

[Severity: Medium]
Should one-packet scheduling (OPS) UDP services be excluded from this
check?

The check runs before ip_vs_schedule() sets IP_VS_CONN_F_ONE_PACKET, so
it also drops port 0 traffic for services with IP_VS_SVC_F_ONEPACKET.
OPS connections are never inserted into the connection table:

net/netfilter/ipvs/ip_vs_conn.c:ip_vs_conn_hash() {
    ...
	if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
		return 0;
    ...
}

They are also freed right after use. So the NO_CPORT mismatch in
__ip_vs_conn_in_get() cannot cause duplicate connections for them:

	(!p->cport ^
	 (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) &&

Before this patch, OPS UDP traffic from client port 0 was scheduled and
forwarded. RFC 768 allows source port 0 for one-way UDP, and that is the
traffic OPS is meant for. With this patch those packets are dropped.

The new !cport check in ip_vs_new_conn_out() has the same scope:

	if (!vport || !dport || !cport)
		return NULL;

It returns before the IP_VS_CONN_F_ONE_PACKET flags are computed. As a
result, OPS UDP initiated by a real server toward client port 0 gets no
connection, and leaves the director without SNAT.

The commit message says it will "disallow normal connections ... to be
created". It doesn't mention that matching packets are now dropped, or
that OPS services are affected too.

Could OPS services be exempted here and in ip_vs_new_conn_out()? If not,
could the commit message describe the dropping?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116004404.2821183-2-pablo%40netfilter.org

  reply	other threads:[~2026-11-17  1:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  0:43 [PATCH net,v2 00/11] IPVS fixes for net Pablo Neira Ayuso
2026-11-16  0:43 ` [PATCH net 01/11] ipvs: fix problems during connection deletion Pablo Neira Ayuso
2026-11-16  0:47   ` netdev-bot+sinfo
2026-11-16  0:48     ` Pablo Neira Ayuso
2026-11-16  0:43 ` [PATCH net 02/11] ipvs: avoid stack overflow from recursive connection expiration Pablo Neira Ayuso
2026-11-16  0:43 ` [PATCH net 03/11] ipvs: reject FTP control ports as data ports Pablo Neira Ayuso
2026-11-17  1:40   ` netdev-bot+sashiko
2026-11-16  0:43 ` [PATCH net 04/11] ipvs: ftp: skip conntrack templates in ip_vs_ftp_out Pablo Neira Ayuso
2026-11-16  0:43 ` [PATCH net 05/11] ipvs: update flags and seqs in backup server under lock Pablo Neira Ayuso
2026-11-17  1:40   ` netdev-bot+sashiko
2026-11-16  0:43 ` [PATCH net 06/11] ipvs: read flags and seqs in master atomically Pablo Neira Ayuso
2026-11-16  0:44 ` [PATCH net 07/11] ipvs: honor the overload state and do not enter it forever Pablo Neira Ayuso
2026-11-16  0:44 ` [PATCH net 08/11] ipvs: validate cport in received sync records Pablo Neira Ayuso
2026-11-16  0:44 ` [PATCH net 09/11] ipvs: skip cport 0 connections in ip_vs_conn_out_get() Pablo Neira Ayuso
2026-11-17  1:40   ` netdev-bot+sashiko
2026-11-16  0:44 ` [PATCH net 10/11] ipvs: do not create conns from packets with port 0 Pablo Neira Ayuso
2026-11-17  1:40   ` netdev-bot+sashiko [this message]
2026-11-16  0:44 ` [PATCH net 11/11] ipvs: wait grace period before reusing destinations Pablo Neira Ayuso
2026-11-17  1:40   ` 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=179487963329.3136.11227226787276094605@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=ja@ssi.bg \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.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