• Vadim Kochan's avatar
    ip netns: Allow exec on each netns · b13ba03f
    Vadim Kochan authored
    This change allows to exec some cmd on each
    named netns (except default) by specifying '-all' option:
    
        # ip -all netns exec ip link
    
    Each command executes synchronously.
    
    Exit status is not considered, so there might be a case
    that some CMD can fail on some netns but success on the other.
    
    EXAMPLES:
    
    1) Show link info on all netns:
    
    $ ip -all netns exec ip link
    
    netns: test_net
    1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    4: tap0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 500
        link/ether 1a:19:6f:25:eb:85 brd ff:ff:ff:ff:ff:ff
    
    netns: home0
    1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    4: tap0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 500
        link/ether ea:1a:59:40:d3:29 brd ff:ff:ff:ff:ff:ff
    
    netns: lan0
    1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    4: tap0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 500
        link/ether ce:49:d5:46:81:ea brd ff:ff:ff:ff:ff:ff
    
    2) Set UP tap0 device for the all netns:
    
    $ ip -all netns exec ip link set dev tap0 up
    
    netns: test_net
    
    netns: home0
    
    netns: lan0
    Signed-off-by: default avatarVadim Kochan <vadim4j@gmail.com>
    b13ba03f
ip.8 5.43 KB