Skip to contentSkip to conversation

bridge: export multicast database via netlink

PATCH Applied Cong Wang 4 participants 5 messages Dec 7, 2012 – Dec 12, 2012

Subsystems (4)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH v5 1/1 bridge: export multicast database via netlink

From: Cong Wang <[email protected]>

V5: fix two bugs pointed out by Thomas
remove seq check for now, mark it as TODO

V4: remove some useless #include
some coding style fix

V3: drop debugging printk's
update selinux perm table as well

V2: drop patch 1/2, export ifindex directly
Redesign netlink attributes
Improve netlink seq check
Handle IPv6 addr as well

This patch exports bridge multicast database via netlink message type RTM_GETMDB. Similar to fdb, but currently bridge-specific. We may need to support modify multicast database too (RTM_{ADD,DEL}MDB).

(Thanks to Thomas for patient reviews)

Cc Herbert Xu <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Thomas Graf <[email protected]>
Cc Jesper Dangaard Brouer <[email protected]>
---
 include/uapi/linux/if_bridge.h |   55 ++++++++++++++
 include/uapi/linux/rtnetlink.h |    3 +
 net/bridge/Makefile            |    2 +-
 net/bridge/br_mdb.c            |  163 ++++++++++++++++++++++++++++++++++++++++
 net/bridge/br_multicast.c      |    1 +
 net/bridge/br_private.h        |    1 +
 security/selinux/nlmsgtab.c    |    1 +
 7 files changed, 225 insertions(+), 1 deletions(-)
include/uapi/linux/if_bridge.h +55 -0
index b388579..9a0f6ff 100644
@@ -116,4 +116,59 @@ enum {
 	__IFLA_BRIDGE_MAX,
 };
 #define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
+
+/* Bridge multicast database attributes
+ * [MDBA_MDB] = {
+ *     [MDBA_MDB_ENTRY] = {
+ *         [MDBA_MDB_ENTRY_INFO]
+ *     }
+ * }
+ * [MDBA_ROUTER] = {
+ *    [MDBA_ROUTER_PORT]
+ * }
+ */
+enum {
+	MDBA_UNSPEC,
+	MDBA_MDB,
+	MDBA_ROUTER,
+	__MDBA_MAX,
+};
+#define MDBA_MAX (__MDBA_MAX - 1)
+
+enum {
+	MDBA_MDB_UNSPEC,
+	MDBA_MDB_ENTRY,
+	__MDBA_MDB_MAX,
+};
+#define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1)
+
+enum {
+	MDBA_MDB_ENTRY_UNSPEC,
+	MDBA_MDB_ENTRY_INFO,
+	__MDBA_MDB_ENTRY_MAX,
+};
+#define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1)
+
+enum {
+	MDBA_ROUTER_UNSPEC,
+	MDBA_ROUTER_PORT,
+	__MDBA_ROUTER_MAX,
+};
+#define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1)
+
+struct br_port_msg {
+	__u32 ifindex;
+};
+
+struct br_mdb_entry {
+	__u32 ifindex;
+	struct {
+		union {
+			__be32	ip4;
+			struct in6_addr ip6;
+		} u;
+		__be16		proto;
+	} addr;
+};
+
 #endif /* _UAPI_LINUX_IF_BRIDGE_H */
include/uapi/linux/rtnetlink.h +3 -0
index 33d29ce..354a1e7 100644
@@ -125,6 +125,9 @@ enum {
 	RTM_GETNETCONF = 82,
 #define RTM_GETNETCONF RTM_GETNETCONF
 
+	RTM_GETMDB = 86,
+#define RTM_GETMDB RTM_GETMDB
+
 	__RTM_MAX,
 #define RTM_MAX		(((__RTM_MAX + 3) & ~3) - 1)
 };
net/bridge/Makefile +1 -1
index d0359ea..e859098 100644
@@ -12,6 +12,6 @@ bridge-$(CONFIG_SYSFS) += br_sysfs_if.o br_sysfs_br.o
 
 bridge-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.o
 
-bridge-$(CONFIG_BRIDGE_IGMP_SNOOPING) += br_multicast.o
+bridge-$(CONFIG_BRIDGE_IGMP_SNOOPING) += br_multicast.o br_mdb.o
 
 obj-$(CONFIG_BRIDGE_NF_EBTABLES) += netfilter/
net/bridge/br_mdb.c new file +163 -0

163 lines not on this page · raw message

net/bridge/br_multicast.c +1 -0
index a2a7a1a..68e375a 100644
@@ -1605,6 +1605,7 @@ void br_multicast_init(struct net_bridge *br)
 		    br_multicast_querier_expired, (unsigned long)br);
 	setup_timer(&br->multicast_query_timer, br_multicast_query_expired,
 		    (unsigned long)br);
+	br_mdb_init();
 }
 
 void br_multicast_open(struct net_bridge *br)
net/bridge/br_private.h +1 -0
index cd86222..ae0a6ec 100644
@@ -433,6 +433,7 @@ extern int br_multicast_set_port_router(struct net_bridge_port *p,
 extern int br_multicast_toggle(struct net_bridge *br, unsigned long val);
 extern int br_multicast_set_querier(struct net_bridge *br, unsigned long val);
 extern int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val);
+extern void br_mdb_init(void);
 
 static inline bool br_multicast_is_router(struct net_bridge *br)
 {
security/selinux/nlmsgtab.c +1 -0
index d309e7f..163aaa7 100644
@@ -67,6 +67,7 @@ static struct nlmsg_perm nlmsg_route_perms[] =
 	{ RTM_GETADDRLABEL,	NETLINK_ROUTE_SOCKET__NLMSG_READ  },
 	{ RTM_GETDCB,		NETLINK_ROUTE_SOCKET__NLMSG_READ  },
 	{ RTM_SETDCB,		NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
+	{ RTM_GETMDB,		NETLINK_ROUTE_SOCKET__NLMSG_READ  },
 };
 
 static struct nlmsg_perm nlmsg_tcpdiag_perms[] =
Acked-by on v5 1/1
#1 lore raw
Quoted 20 lines · Cong Wang

From: Cong Wang <[email protected]>

V5: fix two bugs pointed out by Thomas
remove seq check for now, mark it as TODO

V4: remove some useless #include
some coding style fix

V3: drop debugging printk's
update selinux perm table as well

V2: drop patch 1/2, export ifindex directly
Redesign netlink attributes
Improve netlink seq check
Handle IPv6 addr as well

This patch exports bridge multicast database via netlink message type RTM_GETMDB. Similar to fdb, but currently bridge-specific. We may need to support modify multicast database too (RTM_{ADD,DEL}MDB).

Quoted 8 lines

(Thanks to Thomas for patient reviews)

Cc Herbert Xu <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Thomas Graf <[email protected]>
Cc Jesper Dangaard Brouer <[email protected]>
maintainer Applied
#2 lore raw

From: Thomas Graf <[email protected]>
Date: Fri, 7 Dec 2012 10:36:29 +0000

Quoted 23 lines · Cong Wang
Quoted 22 lines

From: Cong Wang <[email protected]>

V5: fix two bugs pointed out by Thomas
remove seq check for now, mark it as TODO

V4: remove some useless #include
some coding style fix

V3: drop debugging printk's
update selinux perm table as well

V2: drop patch 1/2, export ifindex directly
Redesign netlink attributes
Improve netlink seq check
Handle IPv6 addr as well

This patch exports bridge multicast database via netlink message type RTM_GETMDB. Similar to fdb, but currently bridge-specific. We may need to support modify multicast database too (RTM_{ADD,DEL}MDB).

(Thanks to Thomas for patient reviews)

Quoted 8 lines
Quoted 6 lines
Cc Herbert Xu <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Thomas Graf <[email protected]>
Cc Jesper Dangaard Brouer <[email protected]>

Applied, thanks.

#3 lore raw
In reply to Cong Wang
Quoted 20 lines · On Fri, 7 Dec 2012 18:04:48 +0800 Cong Wang <[email protected]> wrote:

From: Cong Wang <[email protected]>

V5: fix two bugs pointed out by Thomas
remove seq check for now, mark it as TODO

V4: remove some useless #include
some coding style fix

V3: drop debugging printk's
update selinux perm table as well

V2: drop patch 1/2, export ifindex directly
Redesign netlink attributes
Improve netlink seq check
Handle IPv6 addr as well

This patch exports bridge multicast database via netlink message type RTM_GETMDB. Similar to fdb, but currently bridge-specific. We may need to support modify multicast database too (RTM_{ADD,DEL}MDB).

Quoted 9 lines

(Thanks to Thomas for patient reviews)

Cc Herbert Xu <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Thomas Graf <[email protected]>
Cc Jesper Dangaard Brouer <[email protected]>

Applied, but required some manual fixing. It required adding if_bridge.h to include/linux in iproute2 exported headers. Also patch still had some fuzz against current version.

author
#4 lore raw
Quoted 5 lines · Stephen Hemminger

Applied, but required some manual fixing. It required adding if_bridge.h to include/linux in iproute2 exported headers. Also patch still had some fuzz against current version.

Thanks, Stephen!

I thought those headers are sync'ed with kernel headers automatically, so we have to keep them up to date manually.