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, Andrea Claudi <aclaudi@redhat.com>,
	David Ahern <dsahern@kernel.org>,
	"Eric W . Biederman" <ebiederm@xmission.com>
Subject: Re: [PATCH iproute2] ip: reset netns after each command in batch mode
Date: Fri, 7 Jun 2019 08:25:17 -0700	[thread overview]
Message-ID: <20190607082517.5ebcceca@hermes.lan> (raw)
In-Reply-To: <20190607101313.8561-1-mcroce@redhat.com>

On Fri,  7 Jun 2019 12:13:13 +0200
Matteo Croce <mcroce@redhat.com> wrote:

> +void netns_restore(void)
> +{
> +	if (saved_netns != -1) {

If saved_netns is -1 then it is a program bug becase
no save was done? then do something?


> +		if (!setns(saved_netns, CLONE_NEWNET)) {
> +			close(saved_netns);
> +			saved_netns = -1;
> +		} else {
> +			perror("setns");

If you are going to look for errors. then you need to either
return the error or cause the program to exit.
You don't want later commands in the batch to be applied
to wrong namespace.

  reply	other threads:[~2019-06-07 15:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07 10:13 [PATCH iproute2] ip: reset netns after each command in batch mode Matteo Croce
2019-06-07 15:25 ` Stephen Hemminger [this message]
2019-06-07 16:38   ` Matteo Croce

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=20190607082517.5ebcceca@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=aclaudi@redhat.com \
    --cc=dsahern@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=mcroce@redhat.com \
    --cc=netdev@vger.kernel.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).