Re: [PATCH iproute2 1/2] netns: switch netns in the child when executing commands

2019-06-10 Thread Stephen Hemminger
On Tue, 11 Jun 2019 01:03:57 +0200 Matteo Croce wrote: > On Tue, Jun 11, 2019 at 12:52 AM Matteo Croce wrote: > > > > On Tue, Jun 11, 2019 at 12:46 AM Stephen Hemminger > > wrote: > > > > > > On Tue, 11 Jun 2019 00:16:12 +0200 > > > Matteo Croce wrote: > > > > > > > + printf("\nnetns:

Re: [PATCH iproute2 1/2] netns: switch netns in the child when executing commands

2019-06-10 Thread Matteo Croce
On Tue, Jun 11, 2019 at 12:52 AM Matteo Croce wrote: > > On Tue, Jun 11, 2019 at 12:46 AM Stephen Hemminger > wrote: > > > > On Tue, 11 Jun 2019 00:16:12 +0200 > > Matteo Croce wrote: > > > > > + printf("\nnetns: %s\n", nsname); > > > + cmd_exec(argv[0], argv, true, nsname); > > >

Re: [PATCH iproute2 1/2] netns: switch netns in the child when executing commands

2019-06-10 Thread Matteo Croce
On Tue, Jun 11, 2019 at 12:46 AM Stephen Hemminger wrote: > > On Tue, 11 Jun 2019 00:16:12 +0200 > Matteo Croce wrote: > > > + printf("\nnetns: %s\n", nsname); > > + cmd_exec(argv[0], argv, true, nsname); > > return 0; > > simple printf breaks JSON output. It was just moved from on

Re: [PATCH iproute2 1/2] netns: switch netns in the child when executing commands

2019-06-10 Thread Stephen Hemminger
On Tue, 11 Jun 2019 00:16:12 +0200 Matteo Croce wrote: > + printf("\nnetns: %s\n", nsname); > + cmd_exec(argv[0], argv, true, nsname); > return 0; simple printf breaks JSON output.

[PATCH iproute2 1/2] netns: switch netns in the child when executing commands

2019-06-10 Thread Matteo Croce
'ip netns exec' changes the current netns just before executing a child process, and restores it after forking. This is needed if we're running in batch or do_all mode, as well as other cleanup things like VRF associations. Add an argument to cmd_exec() which allows to switch the current netns dire