From: menglong8.dong@gmail.com
To: kuba@kernel.org, christian.brauner@ubuntu.com
Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org,
dong.menglong@zte.com.cn, daniel@iogearbox.net,
gnault@redhat.com, ast@kernel.org, nicolas.dichtel@6wind.com,
ap420073@gmail.com, edumazet@google.com, pabeni@redhat.com,
jakub@cloudflare.com, bjorn.topel@intel.com,
keescook@chromium.org, viro@zeniv.linux.org.uk, rdna@fb.com,
maheshb@google.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next 1/3] net: core: init every ctl_table in netns_core_table
Date: Mon, 18 Jan 2021 22:39:30 +0800 [thread overview]
Message-ID: <20210118143932.56069-2-dong.menglong@zte.com.cn> (raw)
In-Reply-To: <20210118143932.56069-1-dong.menglong@zte.com.cn>
From: Menglong Dong <dong.menglong@zte.com.cn>
For now, there is only one element in netns_core_table, and it is inited
directly in sysctl_core_net_init. To make it more flexible, we can init
every element at once, just like what ipv4_sysctl_init_net() did.
Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
---
net/core/sysctl_net_core.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index d86d8d11cfe4..966d976dee84 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -606,15 +606,19 @@ static __net_init int sysctl_core_net_init(struct net *net)
tbl = netns_core_table;
if (!net_eq(net, &init_net)) {
+ int i;
+
tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
if (tbl == NULL)
goto err_dup;
- tbl[0].data = &net->core.sysctl_somaxconn;
+ /* Update the variables to point into the current struct net */
+ for (i = 0; i < ARRAY_SIZE(netns_core_table) - 1; i++) {
+ tbl[i].data += (void *)net - (void *)&init_net;
- /* Don't export any sysctls to unprivileged users */
- if (net->user_ns != &init_user_ns) {
- tbl[0].procname = NULL;
+ /* Don't export any sysctls to unprivileged users */
+ if (net->user_ns != &init_user_ns)
+ tbl[i].procname = NULL;
}
}
--
2.30.0
next prev parent reply other threads:[~2021-01-18 14:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 14:39 [PATCH net-next 0/3] Namespace-ify some sysctl in net/core menglong8.dong
2021-01-18 14:39 ` menglong8.dong [this message]
2021-01-18 14:39 ` [PATCH net-next 2/3] net: core: Namespace-ify sysctl_wmem_default and sysctl_rmem_default menglong8.dong
2021-01-18 14:39 ` [PATCH net-next 3/3] net: core: Namespace-ify sysctl_rmem_max and sysctl_wmem_max menglong8.dong
2021-01-20 10:46 ` Florian Westphal
2021-01-20 13:28 ` Menglong Dong
2021-01-20 13:57 ` Nicolas Dichtel
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=20210118143932.56069-2-dong.menglong@zte.com.cn \
--to=menglong8.dong@gmail.com \
--cc=ap420073@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=christian.brauner@ubuntu.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dong.menglong@zte.com.cn \
--cc=edumazet@google.com \
--cc=gnault@redhat.com \
--cc=jakub@cloudflare.com \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maheshb@google.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=pabeni@redhat.com \
--cc=rdna@fb.com \
--cc=viro@zeniv.linux.org.uk \
--cc=yoshfuji@linux-ipv6.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).