Re: [PATCH iproute2] ip: reset netns after each command in batch mode

2019-06-07 Thread Matteo Croce
On Fri, Jun 7, 2019 at 5:25 PM Stephen Hemminger wrote: > > On Fri, 7 Jun 2019 12:13:13 +0200 > Matteo Croce 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_n

Re: [PATCH iproute2] ip: reset netns after each command in batch mode

2019-06-07 Thread Stephen Hemminger
On Fri, 7 Jun 2019 12:13:13 +0200 Matteo Croce 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)) { > + cl

[PATCH iproute2] ip: reset netns after each command in batch mode

2019-06-07 Thread Matteo Croce
When creating a new netns or executing a program into an existing one, the unshare() or setns() calls will change the current netns. In batch mode, this can run commands on the wrong interfaces, as the ifindex value is meaningful only in the current netns. For example, this command fails because ve