]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
bridge: Allow to easy change network namespace
authorVadim Kochan <vadim4j@gmail.com>
Wed, 24 Dec 2014 21:04:10 +0000 (23:04 +0200)
committerStephen Hemminger <shemming@brocade.com>
Sat, 27 Dec 2014 18:22:32 +0000 (10:22 -0800)
Added new '-netns' option to simplify executing following cmd:

    ip netns exec NETNS bridge OPTIONS COMMAND OBJECT

    to

    bridge -n[etns] NETNS OPTIONS COMMAND OBJECT

e.g.:

    bridge -net vnet0 fdb

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
bridge/Makefile
bridge/bridge.c
man/man8/bridge.8

index 1fb8320d8019ce08bbe62901f0a62ff718ec0cd4..98007530240afe6f5cda19c503ec9a9f8a130021 100644 (file)
@@ -2,6 +2,10 @@ BROBJ = bridge.o fdb.o monitor.o link.o mdb.o vlan.o
 
 include ../Config
 
+ifeq ($(IP_CONFIG_SETNS),y)
+       CFLAGS += -DHAVE_SETNS
+endif
+
 all: bridge
 
 bridge: $(BROBJ) $(LIBNETLINK) 
index ee08f90af987fab659f5685fc096172189310aa4..5fcc552b1f5dee21d04909c422e294868d189072 100644 (file)
@@ -13,6 +13,7 @@
 #include "SNAPSHOT.h"
 #include "utils.h"
 #include "br_common.h"
+#include "namespace.h"
 
 struct rtnl_handle rth = { .fd = -1 };
 int preferred_family = AF_UNSPEC;
@@ -31,7 +32,7 @@ static void usage(void)
 "Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
 "where  OBJECT := { link | fdb | mdb | vlan | monitor }\n"
 "       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
-"                    -o[neline] | -t[imestamp] \n");
+"                    -o[neline] | -t[imestamp] | -n[etns] name }\n");
        exit(-1);
 }
 
@@ -112,6 +113,10 @@ main(int argc, char **argv)
                        preferred_family = AF_INET;
                } else if (strcmp(opt, "-6") == 0) {
                        preferred_family = AF_INET6;
+               } else if (matches(opt, "-netns") == 0) {
+                       NEXT_ARG();
+                       if (netns_switch(argv[1]))
+                               exit(-1);
                } else {
                        fprintf(stderr, "Option \"%s\" is unknown, try \"bridge help\".\n", opt);
                        exit(-1);
index af31d410ca0a9849dc908330b920ba2f934ff57d..cb3fb46e7063659c6ba8edb21658b40a0789d57d 100644 (file)
@@ -19,7 +19,8 @@ bridge \- show / manipulate bridge addresses and devices
 .ti -8
 .IR OPTIONS " := { "
 \fB\-V\fR[\fIersion\fR] |
-\fB\-s\fR[\fItatistics\fR] }
+\fB\-s\fR[\fItatistics\fR] |
+\fB\-n\fR[\fIetns\fR] name }
 
 .ti -8
 .BR "bridge link set"
@@ -112,6 +113,26 @@ output more information.  If this option
 is given multiple times, the amount of information increases.
 As a rule, the information is statistics or some time values.
 
+.TP
+.BR "\-n" , " \-net" , " \-netns " <NETNS>
+switches
+.B bridge
+to the specified network namespace
+.IR NETNS .
+Actually it just simplifies executing of:
+
+.B ip netns exec
+.IR NETNS
+.B bridge
+.RI "[ " OPTIONS " ] " OBJECT " { " COMMAND " | "
+.BR help " }"
+
+to
+
+.B bridge
+.RI "-n[etns] " NETNS " [ " OPTIONS " ] " OBJECT " { " COMMAND " | "
+.BR help " }"
+
 
 .SH BRIDGE - COMMAND SYNTAX