naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

Blame SOURCES/iproute2-3.10.0-bridge.patch

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