commit 2a9f06affaf089608a8137decaa17c5aee71ed6f
Author: Pavel Šimerda <psimerda@redhat.com>
Date: Thu May 28 12:17:38 2015 +0200
backport selected bridge features and documentation
diff --git a/bridge/Makefile b/bridge/Makefile
index 1fb8320..9800753 100644
--- a/bridge/Makefile
+++ b/bridge/Makefile
@@ -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)
diff --git a/bridge/bridge.c b/bridge/bridge.c
index ee08f90..5fcc552 100644
--- a/bridge/bridge.c
+++ b/bridge/bridge.c
@@ -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);
diff --git a/bridge/fdb.c b/bridge/fdb.c
index 591fbbe..f725012 100644
--- a/bridge/fdb.c
+++ b/bridge/fdb.c
@@ -30,7 +30,7 @@ int filter_index;
static void usage(void)
{
- fprintf(stderr, "Usage: bridge fdb { add | append | del } ADDR dev DEV {self|master} [ temp ]\n"
+ fprintf(stderr, "Usage: bridge fdb { add | append | del | replace } ADDR dev DEV {self|master} [ temp ]\n"
" [router] [ dst IPADDR] [ vlan VID ]\n"
" [ port PORT] [ vni VNI ] [via DEV]\n");
fprintf(stderr, " bridge fdb {show} [ dev DEV ]\n");
@@ -125,12 +125,16 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (ifindex) {
char ifname[IF_NAMESIZE];
- if (if_indextoname(ifindex, ifname))
+ if (!tb[NDA_LINK_NETNSID] &&
+ if_indextoname(ifindex, ifname))
fprintf(fp, "via %s ", ifname);
else
fprintf(fp, "via ifindex %u ", ifindex);
}
}
+ if (tb[NDA_LINK_NETNSID])
+ fprintf(fp, "link-netnsid %d ",
+ rta_getattr_u32(tb[NDA_LINK_NETNSID]));
if (show_stats && tb[NDA_CACHEINFO]) {
struct nda_cacheinfo *ci = RTA_DATA(tb[NDA_CACHEINFO]);
@@ -334,6 +338,8 @@ int do_fdb(int argc, char **argv)
return fdb_modify(RTM_NEWNEIGH, NLM_F_CREATE|NLM_F_EXCL, argc-1, argv+1);
if (matches(*argv, "append") == 0)
return fdb_modify(RTM_NEWNEIGH, NLM_F_CREATE|NLM_F_APPEND, argc-1, argv+1);
+ if (matches(*argv, "replace") == 0)
+ return fdb_modify(RTM_NEWNEIGH, NLM_F_CREATE|NLM_F_REPLACE, argc-1, argv+1);
if (matches(*argv, "delete") == 0)
return fdb_modify(RTM_DELNEIGH, 0, argc-1, argv+1);
if (matches(*argv, "show") == 0 ||
diff --git a/bridge/monitor.c b/bridge/monitor.c
index e96fcaf..76e7d47 100644
--- a/bridge/monitor.c
+++ b/bridge/monitor.c
@@ -132,12 +132,15 @@ int do_monitor(int argc, char **argv)
if (file) {
FILE *fp;
+ int err;
fp = fopen(file, "r");
if (fp == NULL) {
perror("Cannot fopen");
exit(-1);
}
- return rtnl_from_file(fp, accept_msg, stdout);
+ err = rtnl_from_file(fp, accept_msg, stdout);
+ fclose(fp);
+ return err;
}
if (rtnl_open(&rth, groups) < 0)
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 66678b5..9db2aec 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -13,13 +13,14 @@ bridge \- show / manipulate bridge addresses and devices
.ti -8
.IR OBJECT " := { "
-.BR link " | " fdb " | " vlan " | " monitor " }"
+.BR link " | " fdb " | " mdb " | " vlan " | " monitor " }"
.sp
.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"
@@ -44,12 +45,12 @@ bridge \- show / manipulate bridge addresses and devices
.IR DEV " ]"
.ti -8
-.BR "bridge fdb" " { " add " | " append " | " del " } "
+.BR "bridge fdb" " { " add " | " append " | " del " | " replace " } "
.I LLADDR
.B dev
.IR DEV " { "
.BR local " | " temp " } { "
-.BR self " } { " embedded " } { " router " } [ "
+.BR self " } { " router " } [ "
.B dst
.IR IPADDR " ] [ "
.B vni
@@ -65,6 +66,21 @@ bridge \- show / manipulate bridge addresses and devices
.IR DEV " ]"
.ti -8
+.BR "bridge mdb" " { " add " | " del " } "
+.B dev
+.IR DEV
+.B port
+.IR PORT
+.B grp
+.IR GROUP " [ "
+.BR permanent " | " temp " ]"
+
+.ti -8
+.BR "bridge mdb show " [ "
+.B dev
+.IR DEV " ]"
+
+.ti -8
.BR "bridge vlan" " { " add " | " del " } "
.B dev
.IR DEV
@@ -79,7 +95,7 @@ bridge \- show / manipulate bridge addresses and devices
.IR DEV " ]"
.ti -8
-.BR "bridge monitor" " [ " all " | " neigh " | " link " ]"
+.BR "bridge monitor" " [ " all " | " neigh " | " link " | " mdb " ]"
.SH OPTIONS
@@ -95,6 +111,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
@@ -110,6 +146,10 @@ As a rule, the information is statistics or some time values.
- Forwarding Database entry.
.TP
+.B mdb
+- Multicast group database entry.
+
+.TP
.B vlan
- VLAN filter list.
@@ -256,10 +296,6 @@ the interface to which this address is associated.
- the address is associated with a software fdb (default)
.sp
-.B embedded
-- the address is associated with an offloaded fdb
-.sp
-
.B router
- the destination address is associated with a router.
Valid if the referenced device is a VXLAN type device and has
@@ -314,6 +350,13 @@ This command removes an existing fdb entry.
.PP
The arguments are the same as with
+.BR "bridge fdb add" .
+
+.SS bridge fdb replace - replace a forwarding database entry
+This command replaces an already present fdb entry.
+
+.PP
+The arguments are the same as with
.BR "bridge fdb add" ,
.SS bridge fdb show - list forwarding entries.
@@ -326,6 +369,69 @@ With the
option, the command becomes verbose. It prints out the last updated
and last used time for each entry.
+.SH bridge mdb - multicast group database management
+
+.B mdb
+objects contain known IP multicast group addresses on a link.
+
+.P
+The corresponding commands display mdb entries, add new entries,
+and delete old ones.
+
+.SS bridge mdb add - add a new multicast group database entry
+
+This command creates a new mdb entry.
+
+.TP
+.BI dev " DEV"
+the interface where this group address is associated.
+
+.TP
+.BI port " PORT"
+the port whose link is known to have members of this multicast group.
+
+.TP
+.BI grp " GROUP"
+the IP multicast group address whose members reside on the link connected to
+the port.
+
+.B permanent
+- the mdb entry is permanent
+.sp
+
+.B temp
+- the mdb entry is temporary (default)
+.sp
+
+.in -8
+.SS bridge mdb delete - delete a multicast group database entry
+This command removes an existing mdb entry.
+
+.PP
+The arguments are the same as with
+.BR "bridge mdb add" .
+
+.SS bridge mdb show - list multicast group database entries
+
+This command displays the current multicast group membership table. The table
+is populated by IGMP and MLD snooping in the bridge driver automatically. It
+can be altered by
+.B bridge mdb add
+and
+.B bridge mdb del
+commands manually too.
+
+.TP
+.BI dev " DEV"
+the interface only whose entries should be listed. Default is to list all
+bridge interfaces.
+
+.PP
+With the
+.B -details
+option, the command becomes verbose. It prints out the ports known to have
+a connected router.
+
.SH bridge vlan - VLAN filter list
.B vlan
@@ -395,7 +501,7 @@ command is the first in the command line and then the object list follows:
.I OBJECT-LIST
is the list of object types that we want to monitor.
It may contain
-.BR link ", and " fdb "."
+.BR link ", " fdb ", and " mdb "."
If no
.B file
argument is given,