bridge: export multicast database via netlink
Subsystems (4)
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)
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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[] =
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 TODOV4: remove some useless #include
some coding style fixV3: drop debugging printk's
update selinux perm table as wellV2: drop patch 1/2, export ifindex directly
Redesign netlink attributes
Improve netlink seq check
Handle IPv6 addr as wellThis 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]>Signed-off-by Cong Wang <[email protected]>
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 TODOV4: remove some useless #include
some coding style fixV3: drop debugging printk's
update selinux perm table as wellV2: drop patch 1/2, export ifindex directly
Redesign netlink attributes
Improve netlink seq check
Handle IPv6 addr as wellThis 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]>Signed-off-by Cong Wang <[email protected]>Acked-by Thomas Graf <[email protected]>
Applied, thanks.
Stephen Hemminger
AppliedQuoted 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 TODOV4: remove some useless #include
some coding style fixV3: drop debugging printk's
update selinux perm table as wellV2: drop patch 1/2, export ifindex directly
Redesign netlink attributes
Improve netlink seq check
Handle IPv6 addr as wellThis 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]>Signed-off-by Cong Wang <[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.
Quoted 5 lines · Stephen Hemminger
Applied, but required some manual fixing. It required adding
if_bridge.htoinclude/linuxin 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.