[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGnkfhxHvJicm7u1YtVxVSVxQbb2+xrxKdU-TZ8fGTBcz7vpQA@mail.gmail.com>
Date: Fri, 7 Jun 2019 18:38:07 +0200
From: Matteo Croce <mcroce@...hat.com>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev <netdev@...r.kernel.org>,
Andrea Claudi <aclaudi@...hat.com>,
David Ahern <dsahern@...nel.org>,
"Eric W . Biederman" <ebiederm@...ssion.com>
Subject: Re: [PATCH iproute2] ip: reset netns after each command in batch mode
On Fri, Jun 7, 2019 at 5:25 PM Stephen Hemminger
<stephen@...workplumber.org> wrote:
>
> On Fri, 7 Jun 2019 12:13:13 +0200
> Matteo Croce <mcroce@...hat.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?
>
saved_netns can be -1 if you execute a batch which doesn't never
change the current netns, e.g: only link, addr, route etc.
In this case netns_restore() will do nothing as there is nothing to restore
> > + 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.
Right. A failure in restoring a saved netns means that something bad
happened, so better stop.
Regards,
--
Matteo Croce
per aspera ad upstream
Powered by blists - more mailing lists