From: David Ahern <dsahern@kernel.org>
To: me@black-desk.cn, Stephen Hemminger <stephen@networkplumber.org>
Cc: David Ahern <dsahern@kernel.org>,
netdev@vger.kernel.org,
"Eric W. Biederman" <ebiederm@xmission.com>,
Lennart Poettering <lennart@poettering.net>,
Luca Boccassi <bluca@debian.org>
Subject: Re: [PATCH iproute2] ip/netns: avoid redundant mounts
Date: Tue, 17 Feb 2026 20:24:08 -0700 [thread overview]
Message-ID: <a9197cec-d406-4201-98d4-a06820b220f3@kernel.org> (raw)
In-Reply-To: <20260210-netns-redundant-mount-v1-1-0b1ebfc1c79f@black-desk.cn>
On 2/9/26 9:11 PM, Chen Linxuan via B4 Relay wrote:
> From: Chen Linxuan <me@black-desk.cn>
>
> On Ubuntu 24.04, I observed redundant mounts after adding a netns with
> the commands below:
>
> sudo ip netns add xxx
> cat /proc/self/mountinfo | grep /run
>
> Output:
>
> 29 31 0:26 / /run rw,nosuid,nodev,noexec,relatime shared:5 - tmpfs tmpfs ...
> ...
> 203 29 0:26 /netns /run/netns rw,nosuid,nodev,noexec,relatime shared:5 - tmpfs tmpfs ...
> 6443 203 0:4 net:[4026533578] /run/netns/xxx rw shared:917 - nsfs nsfs rw
> 6444 29 0:4 net:[4026533578] /run/netns/xxx rw shared:917 - nsfs nsfs rw
with this patch I am still seeing 2 entries:
$ sudo ./ip netns add blah
$ cat /proc/self/mountinfo | grep blah
337 92 0:4 net:[4026532418] /run/netns/blah rw shared:344 - nsfs nsfs rw
338 28 0:4 net:[4026532418] /run/netns/blah rw shared:344 - nsfs nsfs rw
...
> diff --git a/ip/ipnetns.c b/ip/ipnetns.c
> index a20cd8bc7cb8..3a33a3adacee 100644
> --- a/ip/ipnetns.c
> +++ b/ip/ipnetns.c
> @@ -846,6 +846,20 @@ static int netns_add(int argc, char **argv, bool create)
> }
> return -1;
> }
> +
> + /* Reconfigure NETNS_RUN_DIR to MS_PRIVATE recursively and later
> + * MS_SAHRED again to make sure it is placed in a new peer group
> + */
> + if (mount(NETNS_RUN_DIR, NETNS_RUN_DIR, "none", MS_PRIVATE | MS_REC, NULL)) {
line is rather long. please limit line length to about 80 columns except
for print strings like the next line.
> + fprintf(stderr, "mount --make-private %s failed: %s\n",
> + NETNS_RUN_DIR, strerror(errno));
> + if (lock != -1) {
> + flock(lock, LOCK_UN);
> + close(lock);
> + }
> + return -1;
> + }
> +
> made_netns_run_dir_mount = 1;
> }
> if (lock != -1) {
>
> ---
> base-commit: 72f679c0d07629fe9e462c2c52bbe48aaeaa7f83
> change-id: 20260210-netns-redundant-mount-aa2db50eac7d
>
> Best regards,
next prev parent reply other threads:[~2026-02-18 3:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 4:11 [PATCH iproute2] ip/netns: avoid redundant mounts Chen Linxuan via B4 Relay
2026-02-18 3:24 ` David Ahern [this message]
2026-02-25 1:21 ` Chen Linxuan
2026-02-27 20:30 ` David Ahern
2026-02-28 1:36 ` Chen Linxuan
2026-02-28 16:34 ` David Ahern
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=a9197cec-d406-4201-98d4-a06820b220f3@kernel.org \
--to=dsahern@kernel.org \
--cc=bluca@debian.org \
--cc=ebiederm@xmission.com \
--cc=lennart@poettering.net \
--cc=me@black-desk.cn \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.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