{"id":2231484,"url":"http://patchwork.ozlabs.org/api/patches/2231484/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/20260430182543.3931718-2-rc@rexion.ai/","project":{"id":26,"url":"http://patchwork.ozlabs.org/api/projects/26/?format=json","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":"<20260430182543.3931718-2-rc@rexion.ai>","list_archive_url":null,"date":"2026-04-30T18:25:41","name":"[net-next,v2,1/3] netfilter: conntrack: add shared port parser for helpers","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f6ce974cd4bf4cad33e7ddb939c091bcab113d99","submitter":{"id":93293,"url":"http://patchwork.ozlabs.org/api/people/93293/?format=json","name":"HACKE-RC","email":"rc@rexion.ai"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/20260430182543.3931718-2-rc@rexion.ai/mbox/","series":[{"id":502357,"url":"http://patchwork.ozlabs.org/api/series/502357/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=502357","date":"2026-04-30T18:25:41","name":"netfilter: conntrack: add shared port parser and use it in IRC and Amanda helpers","version":2,"mbox":"http://patchwork.ozlabs.org/series/502357/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231484/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231484/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <netfilter-devel+bounces-12348-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=fail reason=\"key not found in DNS\" header.d=rexion.ai\n header.i=@rexion.ai header.a=rsa-sha256 header.s=spacemail header.b=kpOLI+0V;\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-12348-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=fail reason=\"key not found in DNS\" (0-bit key) header.d=rexion.ai\n header.i=@rexion.ai header.b=\"kpOLI+0V\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=63.250.43.96","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=rexion.ai","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=rexion.ai"],"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 4g62kF3Snsz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 04:28:53 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 8EF6D306E5EC\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 18:26:08 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 9678047CC6F;\n\tThu, 30 Apr 2026 18:26:06 +0000 (UTC)","from out-13.smtp.spacemail.com (out-13.smtp.spacemail.com\n [63.250.43.96])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id DFCFD39D6DE;\n\tThu, 30 Apr 2026 18:26:04 +0000 (UTC)","from Kyren (unknown [49.207.224.37])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby mail.spacemail.com (Postfix) with ESMTPSA id 4g62ft5vZwz8sd8;\n\tThu, 30 Apr 2026 18:25:58 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777573566; cv=none;\n b=XY8JW1/FnqWtgBPM+IvbaILcNANVBnF5hpRwFVuLG5Si4vjLAw8CifrTaIyotsReMgFNE8IL2/8d/ibv8EFFDdy95Yr68LYoh51DGBRocib2hMr4RzPp7brnANMDdMkvoc9SW/S3vDhqz38MTtwdTVlDZaPARZYKkf1BEuEr3EI=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777573566; c=relaxed/simple;\n\tbh=AQd2sw1EZKQtxF/RoAKXgzvPNwc2JS7cbKhPcFoLW+I=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=ldEyxirZ9fwZMxpItRE+fvTGiBox1+1YWAqRB1bzm8ri7WwleJ0BybTt0y0LD+yx6ieUVPk9cYD+tbznbw33RPOfbrdKv85Hsh6omPOtGmYdB/Rll3OUq5meIsBMGz30HykejeurwHjBSd7sai2dlv+3L/UUmjNU9VNAvSPcrXE=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=rexion.ai;\n spf=pass smtp.mailfrom=rexion.ai;\n dkim=fail (0-bit key) header.d=rexion.ai header.i=@rexion.ai\n header.b=kpOLI+0V reason=\"key not found in DNS\";\n arc=none smtp.client-ip=63.250.43.96","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=rexion.ai;\n\ts=spacemail; t=1777573563;\n\tbh=ykvFs84X9ifnNLgl1nKjZZCGpsIMTr1LlOqri6Q6e/A=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=kpOLI+0VVSya8bQzyfaImZyg6+4oDmG63xnMd9DyNi6uzjE9lUkkaRt1mAoHZhfwz\n\t VAuZ/xE7i7h+Lge5xmZsmFVmnnihngd1dDH+INaTO7iZHB7vBjxkvBEqIU7VKjbLJ6\n\t kh8P0Z3hpjErc8C+rPN/kpL3Tucdiu+0rQWCigRt9K3nO1jToNEePFDnFinWPHi3vs\n\t XCfR9pdeV2unojl/m5YJCgP5EzhgmZkfpE/PgyUQZ/04ZuueTNiBLLGTuY6g4/sXJC\n\t Tqh/JfiUq4qeZXypVx9OftYZ6N2J/ctmedG/xHp23qPrUNFD2GQxA228PiYcFoGWRY\n\t bStee+cUngbZA==","From":"HACKE-RC <rc@rexion.ai>","To":"Pablo Neira Ayuso <pablo@netfilter.org>,\n\tFlorian Westphal <fw@strlen.de>","Cc":"Phil Sutter <phil@nwl.cc>,\n\t\"David S . Miller\" <davem@davemloft.net>,\n\tEric Dumazet <edumazet@google.com>,\n\tJakub Kicinski <kuba@kernel.org>,\n\tPaolo Abeni <pabeni@redhat.com>,\n\tSimon Horman <horms@kernel.org>,\n\tnetfilter-devel@vger.kernel.org,\n\tcoreteam@netfilter.org,\n\tnetdev@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tHACKE-RC <rc@rexion.ai>","Subject":"[PATCH net-next v2 1/3] netfilter: conntrack: add shared port parser\n for helpers","Date":"Thu, 30 Apr 2026 23:55:41 +0530","Message-ID":"<20260430182543.3931718-2-rc@rexion.ai>","X-Mailer":"git-send-email 2.54.0","In-Reply-To":"<20260430182543.3931718-1-rc@rexion.ai>","References":"<20260430182543.3931718-1-rc@rexion.ai>","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","X-Envelope-From":"rc@rexion.ai"},"content":"Add nf_ct_helper_parse_port() to the conntrack helper core. This\nprovides a port parser that does not rely on nul-terminated strings,\ntaking an explicit length parameter and validating the result fits\nin the 1-65535 range.\n\nModeled after the approach in 8cf6809cddcb (\"netfilter:\nnf_conntrack_sip: don't use simple_strtoul\") but as a shared\nfunction so IRC, Amanda, and other helpers can use it instead of\nopen-coding simple_strtoul calls with ad-hoc range checks.\n\nSigned-off-by: HACKE-RC <rc@rexion.ai>\n---\n include/net/netfilter/nf_conntrack_helper.h |  3 +++\n net/netfilter/nf_conntrack_helper.c         | 28 +++++++++++++++++++++\n 2 files changed, 31 insertions(+)","diff":"diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h\nindex de2f956ab..db19fe25f 100644\n--- a/include/net/netfilter/nf_conntrack_helper.h\n+++ b/include/net/netfilter/nf_conntrack_helper.h\n@@ -160,6 +160,9 @@ nf_ct_helper_expectfn_find_by_name(const char *name);\n struct nf_ct_helper_expectfn *\n nf_ct_helper_expectfn_find_by_symbol(const void *symbol);\n \n+int nf_ct_helper_parse_port(const char *cp, unsigned int len,\n+\t\t\t    u16 *port, char **endp);\n+\n extern struct hlist_head *nf_ct_helper_hash;\n extern unsigned int nf_ct_helper_hsize;\n \ndiff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c\nindex a715304a5..12f51670d 100644\n--- a/net/netfilter/nf_conntrack_helper.c\n+++ b/net/netfilter/nf_conntrack_helper.c\n@@ -499,6 +499,34 @@ void nf_nat_helper_unregister(struct nf_conntrack_nat_helper *nat)\n }\n EXPORT_SYMBOL_GPL(nf_nat_helper_unregister);\n \n+int nf_ct_helper_parse_port(const char *cp, unsigned int len,\n+\t\t\t    u16 *port, char **endp)\n+{\n+\tunsigned long result = 0;\n+\tconst char *start = cp;\n+\n+\twhile (len > 0 && *cp >= '0' && *cp <= '9') {\n+\t\tresult = result * 10 + (*cp - '0');\n+\t\tif (result > 65535)\n+\t\t\treturn -1;\n+\t\tcp++;\n+\t\tlen--;\n+\t}\n+\n+\tif (cp == start)\n+\t\treturn -1;\n+\n+\tif (result == 0)\n+\t\treturn -1;\n+\n+\t*port = result;\n+\tif (endp)\n+\t\t*endp = (char *)cp;\n+\n+\treturn 0;\n+}\n+EXPORT_SYMBOL_GPL(nf_ct_helper_parse_port);\n+\n int nf_conntrack_helper_init(void)\n {\n \tnf_ct_helper_hsize = 1; /* gets rounded up to use one page */\n","prefixes":["net-next","v2","1/3"]}