From: Florian Westphal <fw@strlen.de>
To: xietangxin <xietangxin@h-partners.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
Phil Sutter <phil@nwl.cc>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
gaoxingwang <gaoxingwang1@huawei.com>,
huyizhen <huyizhen2@huawei.com>,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH net] netfilter: nf_nat_masquerade: recalculate TCP TS offset when port is randomized
Date: Wed, 8 Jul 2026 17:23:52 +0200 [thread overview]
Message-ID: <ak5riPx5d3rSG6MG@strlen.de> (raw)
In-Reply-To: <3620a5a9-9ced-4825-9bc4-6950be205749@h-partners.com>
xietangxin <xietangxin@h-partners.com> wrote:
> Thanks for your guidance. I’ve successfully fix the helper location
> as you suggested, and it works fine for local traffic.
>
> However, I realized that I had completely overlooked the forwarding scenario
> (where SNAT acts as a middlebox gateway, e.g. Host A -> Gateway B -> Server C).
> In this gateway scenario, when random-fully is enabled, the test results show
> a massive performance degradation: the QPS drops from ~19000 down to ~10000.
I don't think the forwarding case is fixable.
Host S could be another NAT gateway, so it could be possible that
the connections originate from different physical machines and
timestamps differ due to different clocks, not per-connection
randomisation.
> Since skb->sk is NULL on the forwarding gateway, my current approach of
> updating tp->tsoffset in struct tcp_sock cannot be applied here.
Yes. I think the tp->tsoffset recalc is fine to handle local case.
For local case we do know that we're the end host and ts recalc is fine.
> To be honest, I am currently stuck on how to handle this forwarding scenario
> within the netfilter architecture without adding redundant overhead to the fast path.
>
> Could you please give some advice on how the community would prefer to resolve this?
> For instance, should we look into extending the Conntrack NAT extension to
> track and adjust the TCP timestamps?
If we have some guarantee that internal network isn't doing any
snat at all, then yes, one could implement some TS adjustment
scheme similar to seqadj extension we already have to deal with
tcp sequence number adjustments.
We'd have to keep state and subtract the offset to get back the
right tsecr again on reverse direction.
I'm not keen to have something like this, it would breaks PAWS
as soon as the originating host is itself a nat gateway.
Is this really a problem to begin with?
next prev parent reply other threads:[~2026-07-08 15:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 9:34 [PATCH net] netfilter: nf_nat_masquerade: recalculate TCP TS offset when port is randomized xietangxin
2026-06-29 13:09 ` Victor Nogueira
2026-06-29 15:23 ` Florian Westphal
2026-07-01 14:09 ` xietangxin
2026-07-01 14:17 ` Florian Westphal
2026-07-06 12:08 ` xietangxin
2026-07-08 15:23 ` Florian Westphal [this message]
2026-07-09 3:37 ` xietangxin
2026-07-09 7:19 ` Florian Westphal
2026-06-29 21:10 ` kernel test robot
2026-07-01 1:44 ` Jiayuan Chen
2026-07-01 14:11 ` xietangxin
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=ak5riPx5d3rSG6MG@strlen.de \
--to=fw@strlen.de \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gaoxingwang1@huawei.com \
--cc=horms@kernel.org \
--cc=huyizhen2@huawei.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
--cc=stable@vger.kernel.org \
--cc=xietangxin@h-partners.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox