Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216442/?format=api
{ "id": 2216442, "url": "http://patchwork.ozlabs.org/api/patches/2216442/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netfilter-devel/patch/20260326125153.685915-7-pablo@netfilter.org/", "project": { "id": 26, "url": "http://patchwork.ozlabs.org/api/projects/26/?format=api", "name": "Netfilter Development", "link_name": "netfilter-devel", "list_id": "netfilter-devel.vger.kernel.org", "list_email": "netfilter-devel@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260326125153.685915-7-pablo@netfilter.org>", "list_archive_url": null, "date": "2026-03-26T12:51:47", "name": "[net,06/12] netfilter: nf_conntrack_expect: honor expectation helper field", "commit_ref": null, "pull_url": null, "state": "handled-elsewhere", "archived": true, "hash": "efd0d77c5fd462390220945a4becb86bfa0f659b", "submitter": { "id": 1315, "url": "http://patchwork.ozlabs.org/api/people/1315/?format=api", "name": "Pablo Neira Ayuso", "email": "pablo@netfilter.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/netfilter-devel/patch/20260326125153.685915-7-pablo@netfilter.org/mbox/", "series": [ { "id": 497584, "url": "http://patchwork.ozlabs.org/api/series/497584/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=497584", "date": "2026-03-26T12:51:41", "name": "[net,01/12] netfilter: nft_set_pipapo_avx2: don't return non-matching entry on expiry", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/497584/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2216442/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2216442/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <netfilter-devel+bounces-11445-incoming=patchwork.ozlabs.org@vger.kernel.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "netfilter-devel@vger.kernel.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=netfilter.org header.i=@netfilter.org\n header.a=rsa-sha256 header.s=2025 header.b=SQB1EnZF;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=netfilter-devel+bounces-11445-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org\n header.b=\"SQB1EnZF\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=217.70.190.124", "smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=netfilter.org", "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=netfilter.org" ], "Received": [ "from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fhP3R45cFz1yGD\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 23:58:43 +1100 (AEDT)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 0101130FCB90\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 12:52:13 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id D892027A47F;\n\tThu, 26 Mar 2026 12:52:08 +0000 (UTC)", "from mail.netfilter.org (mail.netfilter.org [217.70.190.124])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id D45FF261B70;\n\tThu, 26 Mar 2026 12:52:06 +0000 (UTC)", "from localhost.localdomain (mail-agni [217.70.190.124])\n\tby mail.netfilter.org (Postfix) with ESMTPSA id 90668600B9;\n\tThu, 26 Mar 2026 13:52:04 +0100 (CET)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774529528; cv=none;\n b=WiV/CMtA0msnwrp1ZE/8BfeCz/7UJNOn6suAPZfUOPu53tFRgf6YaLmV2NUialmd+p6HpL1VuEjATh8tAtjuGF65OqYtaRSEqP0b8DLRaLIFH6EMxYIg0/ub99k3D/BRFZB8QCzMpR8+SsQr7wuinH4oEe5epG+nrLlnFApWlHs=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774529528; c=relaxed/simple;\n\tbh=w9FIUx0v0Qp3GBaguyz6w92Mv2UIgTtyGFsY3Imt3Ac=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=H+8oVRWQGa8z2xYsw/9UnQVEbLNTC61PCWJgJY/oY+A3d9rltpIOAl/jO6+Grq3BQJguIWAHIZPm+0Lk+KT7HLLVL4qm0yuOj4ghT1Y66oWv4AX9cbaIltVBIgtTETgrNQLFAwIE5Ub53s3d3UVUDIbyJe+HUPp7J725y5ifgDY=", "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=netfilter.org;\n spf=pass smtp.mailfrom=netfilter.org;\n dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org\n header.b=SQB1EnZF; arc=none smtp.client-ip=217.70.190.124", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org;\n\ts=2025; t=1774529525;\n\tbh=+NbN5O/uWXAdsBJq9nQa4A8E5k87OUZjnzdXlSAYu4I=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=SQB1EnZFGZNiFSlrsBYhclpbCcIpDlOL6rrkja+1cAvsx4IdKK/tYBnv0AXNa5Rsc\n\t dq01zi8Jq+7QdbO23/kisvveQIMNSjKq8f6UuVHxpXE/crj2i9zr0MBe3CMGMF3lhp\n\t RUZ93w3LPZuAnAt2fD8W8+DwLAPdNeGzHHQ6oL5DvwevWwdnpZTZVzvsabd8xZhIGh\n\t Jri8w1x33BHkYfIy5Ze5UD7ePSiuksyA6Ag7ClfhCkKGDt34f+PG/y0ptzTz7ZBWwZ\n\t o6+xJOR1n1/OsZWqDY8wkob+sjvdu184I9A8dItjCqj0FlRN8A35+2ub0ih65nc1fs\n\t GZ4EVKJ/5rbOg==", "From": "Pablo Neira Ayuso <pablo@netfilter.org>", "To": "netfilter-devel@vger.kernel.org", "Cc": "davem@davemloft.net,\n\tnetdev@vger.kernel.org,\n\tkuba@kernel.org,\n\tpabeni@redhat.com,\n\tedumazet@google.com,\n\tfw@strlen.de,\n\thorms@kernel.org", "Subject": "[PATCH net 06/12] netfilter: nf_conntrack_expect: honor expectation\n helper field", "Date": "Thu, 26 Mar 2026 13:51:47 +0100", "Message-ID": "<20260326125153.685915-7-pablo@netfilter.org>", "X-Mailer": "git-send-email 2.47.3", "In-Reply-To": "<20260326125153.685915-1-pablo@netfilter.org>", "References": "<20260326125153.685915-1-pablo@netfilter.org>", "Precedence": "bulk", "X-Mailing-List": "netfilter-devel@vger.kernel.org", "List-Id": "<netfilter-devel.vger.kernel.org>", "List-Subscribe": "<mailto:netfilter-devel+subscribe@vger.kernel.org>", "List-Unsubscribe": "<mailto:netfilter-devel+unsubscribe@vger.kernel.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit" }, "content": "The expectation helper field is mostly unused. As a result, the\nnetfilter codebase relies on accessing the helper through exp->master.\n\nAlways set on the expectation helper field so it can be used to reach\nthe helper.\n\nnf_ct_expect_init() is called from packet path where the skb owns\nthe ct object, therefore accessing exp->master for the newly created\nexpectation is safe. This saves a lot of updates in all callsites\nto pass the ct object as parameter to nf_ct_expect_init().\n\nThis is a preparation patches for follow up fixes.\n\nSigned-off-by: Florian Westphal <fw@strlen.de>\nSigned-off-by: Pablo Neira Ayuso <pablo@netfilter.org>\n---\n include/net/netfilter/nf_conntrack_expect.h | 2 +-\n net/netfilter/nf_conntrack_broadcast.c | 2 +-\n net/netfilter/nf_conntrack_expect.c | 14 +++++++++++++-\n net/netfilter/nf_conntrack_h323_main.c | 12 ++++++------\n net/netfilter/nf_conntrack_helper.c | 7 ++++++-\n net/netfilter/nf_conntrack_netlink.c | 2 +-\n net/netfilter/nf_conntrack_sip.c | 2 +-\n 7 files changed, 29 insertions(+), 12 deletions(-)", "diff": "diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h\nindex 165e7a03b8e9..1b01400b10bd 100644\n--- a/include/net/netfilter/nf_conntrack_expect.h\n+++ b/include/net/netfilter/nf_conntrack_expect.h\n@@ -40,7 +40,7 @@ struct nf_conntrack_expect {\n \t\t\t struct nf_conntrack_expect *this);\n \n \t/* Helper to assign to new connection */\n-\tstruct nf_conntrack_helper *helper;\n+\tstruct nf_conntrack_helper __rcu *helper;\n \n \t/* The conntrack of the master connection */\n \tstruct nf_conn *master;\ndiff --git a/net/netfilter/nf_conntrack_broadcast.c b/net/netfilter/nf_conntrack_broadcast.c\nindex a7552a46d6ac..1964c596c646 100644\n--- a/net/netfilter/nf_conntrack_broadcast.c\n+++ b/net/netfilter/nf_conntrack_broadcast.c\n@@ -70,7 +70,7 @@ int nf_conntrack_broadcast_help(struct sk_buff *skb,\n \texp->expectfn = NULL;\n \texp->flags = NF_CT_EXPECT_PERMANENT;\n \texp->class\t\t = NF_CT_EXPECT_CLASS_DEFAULT;\n-\texp->helper = NULL;\n+\trcu_assign_pointer(exp->helper, helper);\n \n \tnf_ct_expect_related(exp, 0);\n \tnf_ct_expect_put(exp);\ndiff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c\nindex cfc2daa3fc7f..841e316240da 100644\n--- a/net/netfilter/nf_conntrack_expect.c\n+++ b/net/netfilter/nf_conntrack_expect.c\n@@ -309,12 +309,19 @@ struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me)\n }\n EXPORT_SYMBOL_GPL(nf_ct_expect_alloc);\n \n+/* This function can only be used from packet path, where accessing\n+ * master's helper is safe, because the packet holds a reference on\n+ * the conntrack object. Never use it from control plane.\n+ */\n void nf_ct_expect_init(struct nf_conntrack_expect *exp, unsigned int class,\n \t\t u_int8_t family,\n \t\t const union nf_inet_addr *saddr,\n \t\t const union nf_inet_addr *daddr,\n \t\t u_int8_t proto, const __be16 *src, const __be16 *dst)\n {\n+\tstruct nf_conntrack_helper *helper = NULL;\n+\tstruct nf_conn *ct = exp->master;\n+\tstruct nf_conn_help *help;\n \tint len;\n \n \tif (family == AF_INET)\n@@ -325,7 +332,12 @@ void nf_ct_expect_init(struct nf_conntrack_expect *exp, unsigned int class,\n \texp->flags = 0;\n \texp->class = class;\n \texp->expectfn = NULL;\n-\texp->helper = NULL;\n+\n+\thelp = nfct_help(ct);\n+\tif (help)\n+\t\thelper = rcu_dereference(help->helper);\n+\n+\trcu_assign_pointer(exp->helper, helper);\n \texp->tuple.src.l3num = family;\n \texp->tuple.dst.protonum = proto;\n \ndiff --git a/net/netfilter/nf_conntrack_h323_main.c b/net/netfilter/nf_conntrack_h323_main.c\nindex a2a0e22ccee1..3f5c50455b71 100644\n--- a/net/netfilter/nf_conntrack_h323_main.c\n+++ b/net/netfilter/nf_conntrack_h323_main.c\n@@ -643,7 +643,7 @@ static int expect_h245(struct sk_buff *skb, struct nf_conn *ct,\n \t\t\t &ct->tuplehash[!dir].tuple.src.u3,\n \t\t\t &ct->tuplehash[!dir].tuple.dst.u3,\n \t\t\t IPPROTO_TCP, NULL, &port);\n-\texp->helper = &nf_conntrack_helper_h245;\n+\trcu_assign_pointer(exp->helper, &nf_conntrack_helper_h245);\n \n \tnathook = rcu_dereference(nfct_h323_nat_hook);\n \tif (memcmp(&ct->tuplehash[dir].tuple.src.u3,\n@@ -767,7 +767,7 @@ static int expect_callforwarding(struct sk_buff *skb,\n \tnf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),\n \t\t\t &ct->tuplehash[!dir].tuple.src.u3, &addr,\n \t\t\t IPPROTO_TCP, NULL, &port);\n-\texp->helper = nf_conntrack_helper_q931;\n+\trcu_assign_pointer(exp->helper, nf_conntrack_helper_q931);\n \n \tnathook = rcu_dereference(nfct_h323_nat_hook);\n \tif (memcmp(&ct->tuplehash[dir].tuple.src.u3,\n@@ -1234,7 +1234,7 @@ static int expect_q931(struct sk_buff *skb, struct nf_conn *ct,\n \t\t\t\t&ct->tuplehash[!dir].tuple.src.u3 : NULL,\n \t\t\t &ct->tuplehash[!dir].tuple.dst.u3,\n \t\t\t IPPROTO_TCP, NULL, &port);\n-\texp->helper = nf_conntrack_helper_q931;\n+\trcu_assign_pointer(exp->helper, nf_conntrack_helper_q931);\n \texp->flags = NF_CT_EXPECT_PERMANENT;\t/* Accept multiple calls */\n \n \tnathook = rcu_dereference(nfct_h323_nat_hook);\n@@ -1306,7 +1306,7 @@ static int process_gcf(struct sk_buff *skb, struct nf_conn *ct,\n \tnf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),\n \t\t\t &ct->tuplehash[!dir].tuple.src.u3, &addr,\n \t\t\t IPPROTO_UDP, NULL, &port);\n-\texp->helper = nf_conntrack_helper_ras;\n+\trcu_assign_pointer(exp->helper, nf_conntrack_helper_ras);\n \n \tif (nf_ct_expect_related(exp, 0) == 0) {\n \t\tpr_debug(\"nf_ct_ras: expect RAS \");\n@@ -1523,7 +1523,7 @@ static int process_acf(struct sk_buff *skb, struct nf_conn *ct,\n \t\t\t &ct->tuplehash[!dir].tuple.src.u3, &addr,\n \t\t\t IPPROTO_TCP, NULL, &port);\n \texp->flags = NF_CT_EXPECT_PERMANENT;\n-\texp->helper = nf_conntrack_helper_q931;\n+\trcu_assign_pointer(exp->helper, nf_conntrack_helper_q931);\n \n \tif (nf_ct_expect_related(exp, 0) == 0) {\n \t\tpr_debug(\"nf_ct_ras: expect Q.931 \");\n@@ -1577,7 +1577,7 @@ static int process_lcf(struct sk_buff *skb, struct nf_conn *ct,\n \t\t\t &ct->tuplehash[!dir].tuple.src.u3, &addr,\n \t\t\t IPPROTO_TCP, NULL, &port);\n \texp->flags = NF_CT_EXPECT_PERMANENT;\n-\texp->helper = nf_conntrack_helper_q931;\n+\trcu_assign_pointer(exp->helper, nf_conntrack_helper_q931);\n \n \tif (nf_ct_expect_related(exp, 0) == 0) {\n \t\tpr_debug(\"nf_ct_ras: expect Q.931 \");\ndiff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c\nindex ceb48c3ca0a4..294a6ffcbccd 100644\n--- a/net/netfilter/nf_conntrack_helper.c\n+++ b/net/netfilter/nf_conntrack_helper.c\n@@ -399,7 +399,7 @@ static bool expect_iter_me(struct nf_conntrack_expect *exp, void *data)\n \tconst struct nf_conntrack_helper *me = data;\n \tconst struct nf_conntrack_helper *this;\n \n-\tif (exp->helper == me)\n+\tif (rcu_access_pointer(exp->helper) == me)\n \t\treturn true;\n \n \tthis = rcu_dereference_protected(help->helper,\n@@ -421,6 +421,11 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)\n \n \tnf_ct_expect_iterate_destroy(expect_iter_me, NULL);\n \tnf_ct_iterate_destroy(unhelp, me);\n+\n+\t/* nf_ct_iterate_destroy() does an unconditional synchronize_rcu() as\n+\t * last step, this ensures rcu readers of exp->helper are done.\n+\t * No need for another synchronize_rcu() here.\n+\t */\n }\n EXPORT_SYMBOL_GPL(nf_conntrack_helper_unregister);\n \ndiff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c\nindex c156574e1273..a42d14290786 100644\n--- a/net/netfilter/nf_conntrack_netlink.c\n+++ b/net/netfilter/nf_conntrack_netlink.c\n@@ -3573,7 +3573,7 @@ ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct,\n \n \texp->class = class;\n \texp->master = ct;\n-\texp->helper = helper;\n+\trcu_assign_pointer(exp->helper, helper);\n \texp->tuple = *tuple;\n \texp->mask.src.u3 = mask->src.u3;\n \texp->mask.src.u.all = mask->src.u.all;\ndiff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c\nindex 4ab5ef71d96d..106b2f419e19 100644\n--- a/net/netfilter/nf_conntrack_sip.c\n+++ b/net/netfilter/nf_conntrack_sip.c\n@@ -1297,7 +1297,7 @@ static int process_register_request(struct sk_buff *skb, unsigned int protoff,\n \tnf_ct_expect_init(exp, SIP_EXPECT_SIGNALLING, nf_ct_l3num(ct),\n \t\t\t saddr, &daddr, proto, NULL, &port);\n \texp->timeout.expires = sip_timeout * HZ;\n-\texp->helper = helper;\n+\trcu_assign_pointer(exp->helper, helper);\n \texp->flags = NF_CT_EXPECT_PERMANENT | NF_CT_EXPECT_INACTIVE;\n \n \thooks = rcu_dereference(nf_nat_sip_hooks);\n", "prefixes": [ "net", "06/12" ] }