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@google.com, horms@kernel.org,
fw@strlen.de, ja@ssi.bg
Subject: [PATCH net-next 1/8] netfilter: seqadj: do not take ct lock if seqadj is NULL
Date: Fri, 11 Sep 2026 10:44:30 +0200 [thread overview]
Message-ID: <20260911084437.1838161-2-pablo@netfilter.org> (raw)
In-Reply-To: <20260911084437.1838161-1-pablo@netfilter.org>
From: Fernando Fernandez Mancera <fmancera@suse.de>
This is a small optimization, only take ct lock if seqadj is present. In
the unlikely case seqadj isn't present we can return immediately. This
is consistent with the behavior of other functions that checks seqadj.
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_seqadj.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/net/netfilter/nf_conntrack_seqadj.c b/net/netfilter/nf_conntrack_seqadj.c
index 220216a4edc5..d75e8dafb189 100644
--- a/net/netfilter/nf_conntrack_seqadj.c
+++ b/net/netfilter/nf_conntrack_seqadj.c
@@ -10,20 +10,19 @@
int nf_ct_seqadj_init(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
s32 off)
{
+ struct nf_conn_seqadj *seqadj = nfct_seqadj(ct);
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
- struct nf_conn_seqadj *seqadj;
struct nf_ct_seqadj *this_way;
if (off == 0)
return 0;
- spin_lock_bh(&ct->lock);
- seqadj = nfct_seqadj(ct);
- if (!seqadj) {
- spin_unlock_bh(&ct->lock);
+ if (unlikely(!seqadj))
return 0;
- }
+
set_bit(IPS_SEQ_ADJUST_BIT, &ct->status);
+
+ spin_lock_bh(&ct->lock);
this_way = &seqadj->seq[dir];
this_way->offset_before = off;
this_way->offset_after = off;
--
2.47.3
next prev parent reply other threads:[~2026-09-11 8:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 8:44 [PATCH net-next 0/8] Netfilter updates for net-next Pablo Neira Ayuso
2026-09-11 8:44 ` Pablo Neira Ayuso [this message]
2026-09-15 0:20 ` [PATCH net-next 1/8] netfilter: seqadj: do not take ct lock if seqadj is NULL patchwork-bot+netdevbpf
2026-09-11 8:44 ` [PATCH net-next 2/8] netfilter: x_tables: use GFP_KERNEL_ACCOUNT in match/target Pablo Neira Ayuso
2026-09-11 8:44 ` [PATCH net-next 3/8] netfilter: nfnetlink: use GFP_KERNEL_ACCOUNT Pablo Neira Ayuso
2026-09-11 8:44 ` [PATCH net-next 4/8] netfilter: nf_tables: " Pablo Neira Ayuso
2026-09-11 8:44 ` [PATCH net-next 5/8] netfilter: synproxy: " Pablo Neira Ayuso
2026-09-11 8:44 ` [PATCH net-next 6/8] netfilter: sysctl: " Pablo Neira Ayuso
2026-09-11 8:44 ` [PATCH net-next 7/8] netfilter: nat: " Pablo Neira Ayuso
2026-09-11 8:44 ` [PATCH net-next 8/8] netfilter: conncount: " 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=20260911084437.1838161-2-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).