From: Mauricio Faria de Oliveira <mfo@igalia.com>
To: Kees Cook <kees@kernel.org>,
Joel Granados <joel.granados@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>
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 <mfo@igalia.com>
Subject: [PATCH RFC v2 09/13] sysctl, ipv6: update register_net_sysctl{_sz}() callers with template arguments
Date: Tue, 18 Aug 2026 23:28:08 -0300 [thread overview]
Message-ID: <20260818-sysctl-module-aliases-v2-9-d5a69dae5798@igalia.com> (raw)
In-Reply-To: <20260818-sysctl-module-aliases-v2-0-d5a69dae5798@igalia.com>
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 <mfo@igalia.com>
---
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
WARNING: multiple messages have this Message-ID (diff)
From: Mauricio Faria de Oliveira <mfo@igalia.com>
To: Kees Cook <kees@kernel.org>,
Joel Granados <joel.granados@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>
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 <mfo@igalia.com>
Subject: [PATCH RFC v2 09/13] sysctl, ipv6: update register_net_sysctl{_sz}() callers with template arguments
Date: Tue, 18 Aug 2026 23:28:08 -0300 [thread overview]
Message-ID: <20260818-sysctl-module-aliases-v2-9-d5a69dae5798@igalia.com> (raw)
In-Reply-To: <20260818-sysctl-module-aliases-v2-0-d5a69dae5798@igalia.com>
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 <mfo@igalia.com>
---
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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-08-19 2:30 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 2:27 [PATCH RFC v2 00/13] sysctl: add module aliases Mauricio Faria de Oliveira
2026-08-19 2:27 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 01/13] keys, pidns, fs/verity, riscv/vector: reorder '#include <linux/sysctl.h>' Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:33 ` sashiko-bot
2026-08-19 2:28 ` [PATCH RFC v2 02/13] proc: add config option SYSCTL_MODULE_ALIASES Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:37 ` sashiko-bot
2026-08-19 16:24 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 03/13] sysctl, mod_devicetable: add macro MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:40 ` sashiko-bot
2026-08-19 16:26 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 04/13] sysctl: add register_sysctl() wrapper for MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:44 ` sashiko-bot
2026-08-19 16:25 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 05/13] sysctl, parport: update register_sysctl() callers with template arguments Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:44 ` sashiko-bot
2026-08-19 16:25 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 06/13] sysctl, net: add register_net_sysctl{_sz}() wrappers for MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:40 ` sashiko-bot
2026-08-19 16:25 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 07/13] sysctl, net: update register_net_sysctl{_sz}() callers with template arguments Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:48 ` sashiko-bot
2026-08-19 16:25 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 08/13] sysctl, net: update register_net_sysctl_sz(ARRAY_SIZE(table_tmpl)) " Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:36 ` sashiko-bot
2026-08-19 2:28 ` Mauricio Faria de Oliveira [this message]
2026-08-19 2:28 ` [PATCH RFC v2 09/13] sysctl, ipv6: update register_net_sysctl{_sz}() callers " Mauricio Faria de Oliveira
2026-08-19 2:36 ` sashiko-bot
2026-08-19 2:28 ` [PATCH RFC v2 10/13] sysctl, net: update register_net_sysctl_sz() edge case Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:39 ` sashiko-bot
2026-08-19 2:28 ` [PATCH RFC v2 11/13] sysctl: unrandomize struct ctl_table.procname Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:38 ` sashiko-bot
2026-08-19 2:28 ` [PATCH RFC v2 12/13] modpost: move addend_*_rel() calls into addend_rel() Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:39 ` sashiko-bot
2026-08-19 2:28 ` [PATCH RFC v2 13/13] modpost: handle MODULE_SYSCTL_TABLE symbols Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:48 ` sashiko-bot
2026-08-19 16:29 ` Mauricio Faria de Oliveira
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=20260818-sysctl-module-aliases-v2-9-d5a69dae5798@igalia.com \
--to=mfo@igalia.com \
--cc=bpf@vger.kernel.org \
--cc=bridge@lists.linux.dev \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fsverity@lists.linux.dev \
--cc=horms@kernel.org \
--cc=joel.granados@kernel.org \
--cc=kees@kernel.org \
--cc=kernel-dev@igalia.com \
--cc=keyrings@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=lvs-devel@vger.kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=nsc@kernel.org \
--cc=pabeni@redhat.com \
--cc=rds-devel@oss.oracle.com \
--cc=virtualization@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.