netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Matteo Croce <mcroce@redhat.com>
Cc: netdev@vger.kernel.org, Alexander Aring <aring@mojatatu.com>,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>
Subject: Re: [RFC iproute2] netns: add mounting state file for each netns
Date: Tue, 2 Jul 2019 17:41:06 -0700	[thread overview]
Message-ID: <20190702174106.01f9266d@hermes.lan> (raw)
In-Reply-To: <20190630192933.30743-1-mcroce@redhat.com>

On Sun, 30 Jun 2019 21:29:33 +0200
Matteo Croce <mcroce@redhat.com> wrote:

> @@ -737,6 +746,14 @@ static int netns_add(int argc, char **argv, bool create)
>  	}
>  	close(fd);
>  
> +	fd = open(tmp_path, O_RDONLY|O_CREAT|O_EXCL, 0);
> +	if (fd < 0) {
> +		fprintf(stderr, "Cannot create namespace file \"%s\": %s\n",
> +			tmp_path, strerror(errno));
> +		goto out_delete;
> +	}
> +	close(fd);
> +
>  	if (create) {
>  		netns_save();
>  		if (unshare(CLONE_NEWNET) < 0) {
> @@ -757,6 +774,7 @@ static int netns_add(int argc, char **argv, bool create)
>  		goto out_delete;
>  	}
>  	netns_restore();
> +	unlink(tmp_path);

This looks like yet another source of potential errors and races.
What if the program is killed or other issues.

Maybe using abstract unix domain socket (which doesn't exist in filesystem
and auto-deletes on exit) would be better.

      parent reply	other threads:[~2019-07-03  0:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-30 19:29 [RFC iproute2] netns: add mounting state file for each netns Matteo Croce
2019-07-01 12:38 ` Nicolas Dichtel
2019-07-01 13:50   ` Matteo Croce
2019-07-01 14:17     ` Nicolas Dichtel
2019-07-02  5:36 ` Alexander Aring
2019-07-03  0:41 ` Stephen Hemminger [this message]

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=20190702174106.01f9266d@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=aring@mojatatu.com \
    --cc=mcroce@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    /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).