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

From: Stephen Hemminger <[email-masked]>
Date: Fri, 7 Jun 2019 08:25:17 -0700

On Fri,  7 Jun 2019 12:13:13 +0200
Matteo Croce <[email-masked]> 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.