Article View: linux.kernel.netdev
Article #21035[PATCH net-next 05/15] netfilter: conntrack: replace open-coded helper invocation
From: Pablo Neira Ayuso
Date: Mon, 23 Nov 2026 13:54
Date: Mon, 23 Nov 2026 13:54
92 lines
10841 bytes
10841 bytes
From: Florian Westphal <fw@strlen.de>
Replace duplicated logic with the new nf_ct_call_helper() helper.
No functional changes intended, except the additional checks to
ensure the helper can process the given packet.
LLM complains about the existing early !helper-return in
nf_ct_helper(), but I prefer to keep this as-is.
Fixes: 9fb9cbb1082d ("[NETFILTER]: Add nf_conntrack subsystem.")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_ovs.c | 53 +-------------------------------
1 file changed, 1 insertion(+), 52 deletions(-)
diff --git a/net/netfilter/nf_conntrack_ovs.c b/net/netfilter/nf_conntrack_ovs.c
index fe525b324af4..2a80eaf05186 100644
--- a/net/netfilter/nf_conntrack_ovs.c
+++ b/net/netfilter/nf_conntrack_ovs.c
@@ -12,16 +12,8 @@
int nf_ct_helper(struct sk_buff *skb, struct nf_conn *ct,
enum ip_conntrack_info ctinfo, u16 proto)
{
- int (*helper_cb)(struct sk_buff *skb, unsigned int protoff,
- struct nf_conn *ct,
- enum ip_conntrack_info conntrackinfo);
const struct nf_conntrack_helper *helper;
const struct nf_conn_help *help;
- unsigned int protoff;
- int err;
-
- if (ctinfo == IP_CT_RELATED_REPLY)
- return NF_ACCEPT;
help = nfct_help(ct);
if (!help)
@@ -35,50 +27,7 @@ int nf_ct_helper(struct sk_buff *skb, struct nf_conn *ct,
helper->nfproto != proto)
return NF_ACCEPT;
- switch (proto) {
- case NFPROTO_IPV4:
- protoff = ip_hdrlen(skb);
- proto = ip_hdr(skb)->protocol;
- break;
- case NFPROTO_IPV6: {
- u8 nexthdr = ipv6_hdr(skb)->nexthdr;
- __be16 frag_off;
- int ofs;
-
- ofs = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr,
- &frag_off);
- if (ofs < 0 || (frag_off & htons(~0x7)) != 0) {
- pr_debug("proto header not found\n");
- return NF_ACCEPT;
- }
- protoff = ofs;
- proto = nexthdr;
- break;
- }
- default:
- WARN_ONCE(1, "helper invoked on non-IP family!");
- return NF_DROP;
- }
-
- if (helper->l4proto != proto)
- return NF_ACCEPT;
-
- helper_cb = rcu_dereference(helper->help);
- if (!helper_cb)
- return NF_ACCEPT;
-
- err = helper_cb(skb, protoff, ct, ctinfo);
- if (err != NF_ACCEPT)
- return err;
-
- /* Adjust seqs after helper. This is needed due to some helpers (e.g.,
- * FTP with NAT) adusting the TCP payload size when mangling IP
- * addresses and/or port numbers in the text-based control connection.
- */
- if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) &&
- !nf_ct_seq_adjust(skb, ct, ctinfo, protoff))
- return NF_DROP;
- return NF_ACCEPT;
+ return nf_ct_call_helper(skb, ct, ctinfo);
}
EXPORT_SYMBOL_GPL(nf_ct_helper);
--
2.47.3
Technical Details
Message-ID:
<20261123135442.3940372-6-pablo@netfilter.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369426-linux-kernel-netdev=dewy.ruReferences:
<20261123135442.3940372-1-pablo@netfilter.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369426-linux-kernel-netdev=dewy.ru From: pablo@netfilter.org (Pablo Neira Ayuso) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next 05/15] netfilter: conntrack: replace open-coded helper invocation Date: Mon, 23 Nov 2026 14:54:32 +0100 Organization: Usenet Network Message-ID: <20261123135442.3940372-6-pablo@netfilter.org> References: <20261123135442.3940372-1-pablo@netfilter.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3893668"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:AIf2Rnsec5K3t33mQ9oCnS13Ygg= sha256:PlyWqFk43vjUq7io2VwviIFsugVOpr8VH5qCtzRLnlQ= sha1:zjSGCHiVp5q0ls6MXiKY0c9tgEk= sha256:T5hgCSVxFagXP9XcKKRuRJ5NbcSL2XUH2/CxYIpFAdw= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 5E480125DB9; Mon, 23 Nov 2026 16:56:18 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=netfilter.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cwa6G0L8gYIs; Mon, 23 Nov 2026 16:56:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369426-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=netfilter.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 53132125DB8; Mon, 23 Nov 2026 16:56:07 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 62E16373FB; Mon, 23 Nov 2026 13:55:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1795442100; b=kkt6LyiL43XfgW3vKSRCdfEujZmFR6+lWsyYMGlrkPgOP5T2Dq8CkHczViQY5+g0l7z7 kWfBr1wRLFhTj/uxOvGNiUKQuC8uU9udSlbx0rYeJF4CigDnbvT13ohSlSlmv1N1NE/WU vb6mqUbHHfrg2cOJKyymasQprjO3T8tvF+fGlW0YWgSrfDepPHfCGKp6oKx9ZHSK/IWjA sizy6byI14VBu3IHJWlVS9INS3LhfaXARyjwGc4KsSZKAp7+MJak7Q6a1dRqlgdM31626 KT2QfnPKBBgmS+uqynU1Gp+tE6FFt+2e3thJfP1asGX88gErdf7azp6mAicZHaD/HYQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795442100; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=yOW9YNJL9sjA3bJFgWWxixTU2xU4gwJYXG8cgx+Z8Hw=; b=1JYjSthvSjENwLN7TRQm1iyiDPCfDWkKsHUewJPyspsWcyu8ttmZi9T7yO1cmYkgVm+d ofl87EnNOHnl26BO8tlrR7MHvjM/Ccyrb21FXTKAUVBIFH6H84C+9+2yQpcnnwfdW1avu ijcGYveZhO7xoiOtkwMabS//PeC9x+ndVqdABqur+KBv+zcEH9DD/JggIjwHB/G44AxUc dpRd6tr2QPn7M5AahphPZZV0u1XdzabZ9rtvS6j8oEFRQoiPo0WuKo34KRJixEC0spbzI KFyk2BOJ0Z+cvKlg8xa8+cGHYaJD1HfgWJR2dNOTBT4YoJZXNUIbjzIfvVvcvS/YuaA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=FzRmfzqh; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; arc=fail smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD84A606A32D; Mon, 23 Nov 2026 13:54:59 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=FzRmfzqh X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795442099; b=2aaeF6AASGBB5nXhyjH793q5xygTFvmChauwd+tW9DxAeD+HcRAYKJD6B2x2fvkeDR2e fCyYYppQwUcl4aZfjVdCvfgGEtxZtMctcLLdMbktWXESRWBb7VicDFb8fFzya0xSVhS/z lD2Nm8uaQ0lYKR5NQ/92ouJGRq1nXrtpYLPf4/uMSbwtpEdBOUZyql+2+5hbjpI9R7hMg 7NZ4NyhVcpGrdmHkdZn6+tCdT8sc6NhfHyaL104bYpN+Smd/8+Ou3gYarxCuqwsXBjaEx 0qTWWsNvPzAS2acEujFUrlxsW91BUU34z36d+GRa0QyQGYZTHav0NSW5OCtCikns+Ew== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795442099; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Spam-Status:X-Spam-Checker-Version; bh=yOW9YNJL9sjA3bJFgWWxixTU2xU4gwJYXG8cgx+Z8Hw=; b=2EAczMB1Tz6TJrPXZPYxD0OIIV5YKJyZJ6b/EH7YIsJjPpo4i2a0FodaYHM8Jb8f2x35 jQlK/fjRC1vM0WB2+Fup7wZeUzjFbe4ZkUqToZmJpL/mLezhZ2o/dO/gSLzAdJS1/yP8b 8xaFtqamI6xCSfj8awNrGlsb2nvuGgxIjFObDT67EoW/OmbkAGPwNBwNVrNaAiX7sqh2q Gybzbdd7OOA0fcqNEAumTG/4p3s+cMp58EeYCMdUEyhWpm0nfwG3xR96q9Mnyc7y+ZGOm CXf4YmN/fuqfx6bW2l7EQnilsDsEq4/PHBpEG/tY/RgOnJ3y911TQ8sE2g5PfQiyWGA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=FzRmfzqh; arc=none smtp.remote-ip=217.70.190.124 X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90907606A31A; Mon, 23 Nov 2026 13:54:58 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 90907606A31A X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1795442095; bh=yOW9YNJL9sjA3bJFgWWxixTU2xU4gwJYXG8cgx+Z8Hw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FzRmfzqh5R3+ED64nC+Vppd23kRGVavR4SEhLbw/oZckQqfQpnrGAbejB1D9VzAV5 Rc49wXbvHQAyAoV8Nh/La6ugC8Mosy01ecPGj85n8fW+h/lbbtcz08J+bNwCa7Ga9i fIlvjoS2jSBHRbvvJb3pdjiSWtktbm2vJ+Weh06Uz1zVkjho3u5Ggn8ANqqsUwhy6L fq1RHIpdEPgAXUNultDi3+OQX9PeJS6bJPY5M3hw39dOPD7pKNYo6ki9/c4bzjFG5F uaZFnypeLb+RYeh83tIGy/8Ho2+EI6F5scbuPT7XhEKXJUHX+suo2GrZgq0ftXHwsV czo8vQF/J1VQw== X-Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id 1B052602D1; Mon, 23 Nov 2026 14:54:55 +0100 (CET) X-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 X-Mailer: git-send-email 2.47.3 X-In-Reply-To: <20261123135442.3940372-1-pablo@netfilter.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list