Subject: Re: iproute2: Run over all netns

From: Nicolas Dichtel <[email-masked]>
Date: Mon, 05 Jan 2015 17:40:51 +0100

Le 05/01/2015 13:23, Vadim Kochan a écrit :
> Hi All,
>
> I have some piece of code which allow 'ip cmd'
> on each netns, I found it useful for getting some info
> from all the netns in one shot, BUT I faced with one issue
> which mostly related to the user interface design. The problem
> is that it would be good to print netns name only when
> user uses "show" command, but not for updating/adding (IMHO),
> but its hard to find the good way to implement this.
>
> To run each netns the 'ip -net all CMD ...' construction can be used.
>
> I see the following options for this:
>
> #1 Add additional option ( -N ? ) for show netns label on each executing of CMD:
>
>      # ip -net all -N link
>
>      [test_net]
>      1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>
>      [home0]
>      1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>
>      [lan0]
>      1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>
>      [wan0]
>      1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>      2: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
>          link/ether 16:f7:cb:b6:7a:8e brd ff:ff:ff:ff:ff:ff
>
>      [vnet0]
>      1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>
>
>      and w/o:
>
>      # ip -net all link
>
>      1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>
>      1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>
>      1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>
>      1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>      2: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
>          link/ether 16:f7:cb:b6:7a:8e brd ff:ff:ff:ff:ff:ff
>
>      1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>
>      the last one is not so useful right ?
>
> #2 Prints netns name by default if "-net all" was specified
> (add option to prevent this ?), so it will be printed even on the
> add/del/change commands ...
I vote for this one (I don't think the option to prevent it is needed, it's
better to be explicit).

>
>      # ip -net all link add ...
>
>      [home0]
>      [lan0]
>      [wan0]
>      [vnet0]
>
>      but does it really useless to see that it will shows all the netns
>      on which cmd has been ran ?
I tend to say yes (another process may add/remove a netns in the same time).

Regards,
Nicolas