From: Julius Bairaktaris <julius@bairaktaris.de>
To: pablo@netfilter.org, netfilter-devel@vger.kernel.org
Cc: kadlec@netfilter.org, fw@strlen.de, coreteam@netfilter.org,
netdev@vger.kernel.org, geldot@protonmail.com
Subject: [PATCH nf-next 1/4] netfilter: conntrack: pick up a TCP flow whose SYN was never answered
Date: Thu, 10 Sep 2026 11:00:49 +0200 [thread overview]
Message-ID: <20260910090052.2034970-2-julius@bairaktaris.de> (raw)
In-Reply-To: <20260910090052.2034970-1-julius@bairaktaris.de>
From: Gary Dotzler <geldot@protonmail.com>
When only one direction of a connection passes the host, the SYN is
seen, the answer to it is not, and the next packet is an ACK continuing
from where the SYN left off. The transition table has no entry for that,
so that ACK and every packet after it are invalid and the entry sits in
SYN_SENT [UNREPLIED] with one packet.
Treat the connection as a mid-stream pickup. Delete the entry and look
the packet up again, so it creates a new entry through the loose path.
That path fills in the unseen direction from the packet and stops
window checking in both directions.
Signed-off-by: Gary Dotzler <geldot@protonmail.com>
Tested-by: Julius Bairaktaris <julius@bairaktaris.de>
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
Assisted-by: Claude:claude-opus-5
---
net/netfilter/nf_conntrack_proto_tcp.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index ad6f1986d52a..335b11301a78 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -1173,6 +1173,25 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct,
return NF_ACCEPT;
}
+ /* The answer to the SYN never passed the host, as happens
+ * when the reply direction takes another path, and the client
+ * continues from where its SYN left off. Take the connection
+ * over as a mid-stream pickup: delete the entry so the packet
+ * creates a new one that seeds the unseen direction from the
+ * packet itself.
+ */
+ if (tn->tcp_loose && !nfct_synproxy(ct) &&
+ old_state == TCP_CONNTRACK_SYN_SENT &&
+ index == TCP_ACK_SET && dir == IP_CT_DIR_ORIGINAL &&
+ !test_bit(IPS_SEEN_REPLY_BIT, &ct->status) &&
+ ntohl(th->seq) == ct->proto.tcp.seen[dir].td_end) {
+ spin_unlock_bh(&ct->lock);
+
+ if (nf_ct_kill(ct))
+ return -NF_REPEAT;
+ return NF_DROP;
+ }
+
/* Invalid packet */
spin_unlock_bh(&ct->lock);
nf_ct_l4proto_log_invalid(skb, ct, state,
--
2.53.0
next prev parent reply other threads:[~2026-09-10 9:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 9:00 [PATCH nf-next 0/4] netfilter: offload a TCP flow whose reply is never seen Julius Bairaktaris
2026-09-10 9:00 ` Julius Bairaktaris [this message]
2026-09-10 9:00 ` [PATCH nf-next 2/4] netfilter: flowtable: promote a flow offloaded in one direction only Julius Bairaktaris
2026-09-10 9:00 ` [PATCH nf-next 3/4] netfilter: nft_flow_offload: offload a TCP flow that has no reply Julius Bairaktaris
2026-09-10 9:00 ` [PATCH nf-next 4/4] selftests: netfilter: cover a TCP flow whose reply is never seen Julius Bairaktaris
2026-09-11 11:41 ` [PATCH nf-next 0/4] netfilter: offload " Pablo Neira Ayuso
2026-09-11 12:10 ` Julius Bairaktaris
2026-09-11 14:09 ` Pablo Neira Ayuso
2026-09-11 14:16 ` Pablo Neira Ayuso
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=20260910090052.2034970-2-julius@bairaktaris.de \
--to=julius@bairaktaris.de \
--cc=coreteam@netfilter.org \
--cc=fw@strlen.de \
--cc=geldot@protonmail.com \
--cc=kadlec@netfilter.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--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