From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: 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: [PATCH net 10/11] ipvs: do not create conns from packets with port 0
Date: Mon, 16 Nov 2026 01:44:03 +0100 [thread overview]
Message-ID: <20261116004404.2821183-11-pablo@netfilter.org> (raw)
In-Reply-To: <20261116004404.2821183-1-pablo@netfilter.org>
From: Julian Anastasov <ja@ssi.bg>
We should disallow normal connections with cport 0 to be
created from packets by the scheduler (from clients) or
by ip_vs_new_conn_out (from real servers) because later
such traffic can not hit the connection due to the
NO_CPORT requirement. As result, it can lead to duplicate
connection for every packet. Do the same for vport 0.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
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
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/ipvs/ip_vs_core.c | 3 ++-
net/netfilter/ipvs/ip_vs_proto_sctp.c | 7 +++++++
net/netfilter/ipvs/ip_vs_proto_tcp.c | 7 +++++++
net/netfilter/ipvs/ip_vs_proto_udp.c | 6 ++++++
4 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index 8a3c880fdb26..f3eb72e95024 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1305,6 +1305,7 @@ static inline bool is_new_conn_expected(const struct ip_vs_conn *cp,
* In fwmark-VS actual vaddr and vport are unknown to IPVS
* 2) Real Server and Virtual Service were NOT configured without port:
* This is to allow match of different VS to the same RS ip-addr
+ * 3) Client port is not 0
*/
struct ip_vs_conn *ip_vs_new_conn_out(struct ip_vs_service *svc,
struct ip_vs_dest *dest,
@@ -1328,7 +1329,7 @@ struct ip_vs_conn *ip_vs_new_conn_out(struct ip_vs_service *svc,
/* check pre-requisites are satisfied */
if (svc->fwmark)
return NULL;
- if (!vport || !dport)
+ if (!vport || !dport || !cport)
return NULL;
/* for persistent service first create connection template */
diff --git a/net/netfilter/ipvs/ip_vs_proto_sctp.c b/net/netfilter/ipvs/ip_vs_proto_sctp.c
index fb8af6b15a39..cb34bcceb4f6 100644
--- a/net/netfilter/ipvs/ip_vs_proto_sctp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_sctp.c
@@ -30,6 +30,7 @@ sctp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
sch = skb_header_pointer(skb, iph->len + sizeof(_sctph),
sizeof(_schunkh), &_schunkh);
if (sch) {
+ /* Accept packet without scheduling? */
if (sch->type == SCTP_CID_ABORT ||
!(sysctl_sloppy_sctp(ipvs) ||
sch->type == SCTP_CID_INIT))
@@ -56,6 +57,12 @@ sctp_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;
+ }
+
if (ip_vs_todrop(ipvs)) {
/*
* It seems that we are very loaded.
diff --git a/net/netfilter/ipvs/ip_vs_proto_tcp.c b/net/netfilter/ipvs/ip_vs_proto_tcp.c
index fec0e8b47b71..25d4576d0e12 100644
--- a/net/netfilter/ipvs/ip_vs_proto_tcp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_tcp.c
@@ -48,6 +48,7 @@ tcp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
if (likely(!ip_vs_iph_icmp(iph))) {
th = skb_header_pointer(skb, iph->len, sizeof(_tcph), &_tcph);
if (th) {
+ /* Accept packet without scheduling? */
if (th->rst || !(sysctl_sloppy_tcp(ipvs) || th->syn))
return 1;
ports = &th->source;
@@ -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;
+ }
+
if (ip_vs_todrop(ipvs)) {
/*
* It seems that we are very loaded.
diff --git a/net/netfilter/ipvs/ip_vs_proto_udp.c b/net/netfilter/ipvs/ip_vs_proto_udp.c
index f32785682402..ab3ab9524168 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;
+ }
+
if (ip_vs_todrop(ipvs)) {
/*
* It seems that we are very loaded.
--
2.47.3
next prev parent reply other threads:[~2026-11-16 0:44 UTC|newest]
Thread overview: 23+ 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-17 11:50 ` patchwork-bot+netdevbpf
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-17 4:58 ` Julian Anastasov
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 ` Pablo Neira Ayuso [this message]
2026-11-17 1:40 ` [PATCH net 10/11] ipvs: do not create conns from packets with port 0 netdev-bot+sashiko
2026-11-17 10:00 ` Paolo Abeni
2026-11-17 10:50 ` Julian Anastasov
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=20261116004404.2821183-11-pablo@netfilter.org \
--to=pablo@netfilter.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 \
/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.