From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 469DB3C1400; Wed, 19 Aug 2026 02:30:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787106608; cv=none; b=YDcgu4OipCdh+wJ+g1Gbl3b67R9snSygzDqukm8y2RaLqTvq+XJAXrMzBODpxDsFqBucZ1p4l7psBHijNVCUV26jui5meVtY9aZwpYmOv2cAG6vUQTx6a5A6LD72C9UtwK8i/zNoBRLtXYl3SvRIvsO6VzFRsSXvgbTA73ijsYo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787106608; c=relaxed/simple; bh=wRLwCiuqMttYVsCHPxBkzo19GaoHrSC1wLITrsCEBiI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GfRC/e5hccSnGnit8X28mfWTS9UUWAFi/Lsd7wpex/gHwpxB254vVw0HF2dW193y12UjD8le5/nvxfJwK0W/VnV5NR+mTeZUk5IZLBI/o9IaJ8UctRjS7Lcf33CWzmadbCfkdaZjk7qp4i/ttFSJHmQnVVz5FhcqSpS1ZKafOXE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=KCSNnzlH; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="KCSNnzlH" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=JxjRhJ2z8K0GvxyVrmaAYfCElgRxeZGrAv21+ElqaE4=; b=KCSNnzlH7WW2uHebELEkI9D3mx wmFxgNFJZaGBJMPOJonDX3s8XGQCgmdDpBs3uNMTurfuP8O0TY6cyF5jHYPfJm5mcwDHJeyY+hi0s ikJ07LGeBqEPE85gz4EDS/ffIRUssPl1h5WP+ReKkx+XWTSSOBtTcS8Edc92vzF4zp6LEIgu2+OPW QmXnydsWCWxKtBzAxiGD7xDhU6Pb6J57WDSlLMdD6Z8avCevz2f1qbu1CtT5i9Z5pDgwumD9gVmfu xlgdUvKkMqozthYYuugheU5F42FKImsBBcwSJ5teKqAY0qaPtNWolcu0bFXJwUCepaFAc5dJERxfC Aerc4tdw==; Received: from 186-249-144-28.shared.desktop.com.br ([186.249.144.28] helo=[127.0.1.1]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wwW43-005tfG-Ti; Wed, 19 Aug 2026 04:30:04 +0200 From: Mauricio Faria de Oliveira Date: Tue, 18 Aug 2026 23:28:08 -0300 Subject: [PATCH RFC v2 09/13] sysctl, ipv6: update register_net_sysctl{_sz}() callers with template arguments Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260818-sysctl-module-aliases-v2-9-d5a69dae5798@igalia.com> References: <20260818-sysctl-module-aliases-v2-0-d5a69dae5798@igalia.com> In-Reply-To: <20260818-sysctl-module-aliases-v2-0-d5a69dae5798@igalia.com> To: Kees Cook , Joel Granados , Nathan Chancellor , Nicolas Schier , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: kernel-dev@igalia.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, fsverity@lists.linux.dev, keyrings@vger.kernel.org, bpf@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kbuild@vger.kernel.org, netdev@vger.kernel.org, linux-wpan@vger.kernel.org, lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, bridge@lists.linux.dev, mptcp@lists.linux.dev, rds-devel@oss.oracle.com, virtualization@lists.linux.dev, Mauricio Faria de Oliveira X-Mailer: b4 0.14.2 The sysctl table definition and registration must be in the same file, in order for the macro to work. Add plumbing to register ipv6_{route,icmp}_table in their own files. With this, ipv6_{route,icmp}_sysctl_table_size() can be removed. Signed-off-by: Mauricio Faria de Oliveira --- include/net/ipv6.h | 6 ++++-- net/ipv6/icmp.c | 6 ++++-- net/ipv6/route.c | 10 +++++++--- net/ipv6/sysctl_net_ipv6.c | 10 ++-------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 3de07e738538f783e0fb4628c92ce50a7e36f9f5..29a095798abe8f5730ab0a046931ebf78f481bdf 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -1220,9 +1220,11 @@ static inline int snmp6_unregister_dev(struct inet6_dev *idev) { return 0; } #ifdef CONFIG_SYSCTL struct ctl_table *ipv6_icmp_sysctl_init(struct net *net); -size_t ipv6_icmp_sysctl_table_size(void); +struct ctl_table_header *ipv6_icmp_sysctl_register(struct net *net, + const struct ctl_table *table); struct ctl_table *ipv6_route_sysctl_init(struct net *net); -size_t ipv6_route_sysctl_table_size(struct net *net); +struct ctl_table_header *ipv6_route_sysctl_register(struct net *net, + const struct ctl_table *table); int ipv6_sysctl_register(void); void ipv6_sysctl_unregister(void); #endif diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index a95b0351824f3237815e43bf8448110070955884..bb170b8c867c3c6eaccc41aab8ab1c65eb0aa24b 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -1450,8 +1450,10 @@ struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net) return table; } -size_t ipv6_icmp_sysctl_table_size(void) +struct ctl_table_header *ipv6_icmp_sysctl_register(struct net *net, + const struct ctl_table *table) { - return ARRAY_SIZE(ipv6_icmp_table_template); + return register_net_sysctl(net, "net/ipv6/icmp", table, + ipv6_icmp_table_template); } #endif diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 16dfac54a259a11410ba736535f0462070979276..9e3f849d3564f4312d7b64157471f50c8168aafd 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -6698,13 +6698,17 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net) return table; } -size_t ipv6_route_sysctl_table_size(struct net *net) +struct ctl_table_header *ipv6_route_sysctl_register(struct net *net, + const struct ctl_table *table) { + size_t table_size = ARRAY_SIZE(ipv6_route_table_template); + /* Don't export sysctls to unprivileged users */ if (net->user_ns != &init_user_ns) - return 1; + table_size = 1; - return ARRAY_SIZE(ipv6_route_table_template); + return register_net_sysctl_sz(net, "net/ipv6/route", table, + table_size, ipv6_route_table_template); } #endif diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c index 75ba17cb7c0ccb4769d61e74220c75d0b3e2bcd9..88138fbd42b85d54d00cd15dfd7d6848ebabd607 100644 --- a/net/ipv6/sysctl_net_ipv6.c +++ b/net/ipv6/sysctl_net_ipv6.c @@ -280,17 +280,11 @@ static int __net_init ipv6_sysctl_net_init(struct net *net) if (!net->ipv6.sysctl.hdr) goto out_ipv6_icmp_table; - net->ipv6.sysctl.route_hdr = register_net_sysctl_sz(net, - "net/ipv6/route", - ipv6_route_table, - ipv6_route_sysctl_table_size(net)); + net->ipv6.sysctl.route_hdr = ipv6_route_sysctl_register(net, ipv6_route_table); if (!net->ipv6.sysctl.route_hdr) goto out_unregister_ipv6_table; - net->ipv6.sysctl.icmp_hdr = register_net_sysctl_sz(net, - "net/ipv6/icmp", - ipv6_icmp_table, - ipv6_icmp_sysctl_table_size()); + net->ipv6.sysctl.icmp_hdr = ipv6_icmp_sysctl_register(net, ipv6_icmp_table); if (!net->ipv6.sysctl.icmp_hdr) goto out_unregister_route_table; -- 2.47.3