netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] bridge: mdb: add vlan support for user entries
@ 2015-07-10 15:02 Nikolay Aleksandrov
  2015-07-13 21:41 ` David Miller
  2015-07-20 22:28 ` Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2015-07-10 15:02 UTC (permalink / raw)
  To: netdev; +Cc: Nikolay Aleksandrov, bridge, davem

Until now all user mdb entries were added in vlan 0, this patch adds
support to allow the user to specify the vlan for the entry.
About the uapi change a hole in struct br_mdb_entry is used so the size
and offsets are kept the same (verified with pahole and tested with older
iproute2).

Example:
$ bridge mdb
dev br0 port eth1 grp 239.0.0.1 permanent vlan 2000
dev br0 port eth1 grp 239.0.0.1 permanent vlan 200
dev br0 port eth1 grp 239.0.0.1 permanent

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
note: an iproute2 patch will follow if this one is accepted

 include/uapi/linux/if_bridge.h | 1 +
 net/bridge/br_mdb.c            | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
index eaaea6208b42..3635b7797508 100644
--- a/include/uapi/linux/if_bridge.h
+++ b/include/uapi/linux/if_bridge.h
@@ -182,6 +182,7 @@ struct br_mdb_entry {
 #define MDB_TEMPORARY 0
 #define MDB_PERMANENT 1
 	__u8 state;
+	__u16 vid;
 	struct {
 		union {
 			__be32	ip4;
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index 1fb7d076f15c..a8d0e93d43f2 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -85,6 +85,7 @@ static int br_mdb_fill_info(struct sk_buff *skb, struct netlink_callback *cb,
 					memset(&e, 0, sizeof(e));
 					e.ifindex = port->dev->ifindex;
 					e.state = p->state;
+					e.vid = p->addr.vid;
 					if (p->addr.proto == htons(ETH_P_IP))
 						e.addr.u.ip4 = p->addr.u.ip4;
 #if IS_ENABLED(CONFIG_IPV6)
@@ -242,6 +243,7 @@ void br_mdb_notify(struct net_device *dev, struct net_bridge_port *port,
 	entry.addr.u.ip6 = group->u.ip6;
 #endif
 	entry.state = state;
+	entry.vid = group->vid;
 	__br_mdb_notify(dev, &entry, type);
 }
 
@@ -264,6 +266,8 @@ static bool is_valid_mdb_entry(struct br_mdb_entry *entry)
 		return false;
 	if (entry->state != MDB_PERMANENT && entry->state != MDB_TEMPORARY)
 		return false;
+	if (entry->vid >= VLAN_VID_MASK)
+		return false;
 
 	return true;
 }
@@ -372,6 +376,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br,
 	if (!p || p->br != br || p->state == BR_STATE_DISABLED)
 		return -EINVAL;
 
+	ip.vid = entry->vid;
 	ip.proto = entry->addr.proto;
 	if (ip.proto == htons(ETH_P_IP))
 		ip.u.ip4 = entry->addr.u.ip4;
@@ -418,6 +423,7 @@ static int __br_mdb_del(struct net_bridge *br, struct br_mdb_entry *entry)
 	if (!netif_running(br->dev) || br->multicast_disabled)
 		return -EINVAL;
 
+	ip.vid = entry->vid;
 	ip.proto = entry->addr.proto;
 	if (ip.proto == htons(ETH_P_IP)) {
 		if (timer_pending(&br->ip4_other_query.timer))
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] bridge: mdb: add vlan support for user entries
  2015-07-10 15:02 [PATCH net-next] bridge: mdb: add vlan support for user entries Nikolay Aleksandrov
@ 2015-07-13 21:41 ` David Miller
  2015-07-20 22:28 ` Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2015-07-13 21:41 UTC (permalink / raw)
  To: nikolay; +Cc: netdev, bridge, stephen

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Date: Fri, 10 Jul 2015 08:02:08 -0700

> Until now all user mdb entries were added in vlan 0, this patch adds
> support to allow the user to specify the vlan for the entry.
> About the uapi change a hole in struct br_mdb_entry is used so the size
> and offsets are kept the same (verified with pahole and tested with older
> iproute2).
> 
> Example:
> $ bridge mdb
> dev br0 port eth1 grp 239.0.0.1 permanent vlan 2000
> dev br0 port eth1 grp 239.0.0.1 permanent vlan 200
> dev br0 port eth1 grp 239.0.0.1 permanent
> 
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

This looks ok, applied thanks Nikolay.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] bridge: mdb: add vlan support for user entries
  2015-07-10 15:02 [PATCH net-next] bridge: mdb: add vlan support for user entries Nikolay Aleksandrov
  2015-07-13 21:41 ` David Miller
@ 2015-07-20 22:28 ` Stephen Hemminger
  2015-07-20 22:53   ` Nikolay Aleksandrov
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2015-07-20 22:28 UTC (permalink / raw)
  To: Nikolay Aleksandrov; +Cc: netdev, bridge, davem

On Fri, 10 Jul 2015 08:02:08 -0700
Nikolay Aleksandrov <nikolay@cumulusnetworks.com> wrote:

> diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
> index eaaea6208b42..3635b7797508 100644
> --- a/include/uapi/linux/if_bridge.h
> +++ b/include/uapi/linux/if_bridge.h
> @@ -182,6 +182,7 @@ struct br_mdb_entry {
>  #define MDB_TEMPORARY 0
>  #define MDB_PERMANENT 1
>  	__u8 state;
> +	__u16 vid;
>  	struct {
>  		union {
>  			__be32	ip4;

You added a new field into an unused hole in a data
structure shared as part of API with user space.

This seems like it might break when newer iproute
is run on older kernels. The vid would always be 0
on show and ignored when adding entries.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] bridge: mdb: add vlan support for user entries
  2015-07-20 22:28 ` Stephen Hemminger
@ 2015-07-20 22:53   ` Nikolay Aleksandrov
  0 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2015-07-20 22:53 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, bridge, davem

On 07/21/2015 12:28 AM, Stephen Hemminger wrote:
> On Fri, 10 Jul 2015 08:02:08 -0700
> Nikolay Aleksandrov <nikolay@cumulusnetworks.com> wrote:
> 
>> diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
>> index eaaea6208b42..3635b7797508 100644
>> --- a/include/uapi/linux/if_bridge.h
>> +++ b/include/uapi/linux/if_bridge.h
>> @@ -182,6 +182,7 @@ struct br_mdb_entry {
>>  #define MDB_TEMPORARY 0
>>  #define MDB_PERMANENT 1
>>  	__u8 state;
>> +	__u16 vid;
>>  	struct {
>>  		union {
>>  			__be32	ip4;
> 
> You added a new field into an unused hole in a data
> structure shared as part of API with user space.
> 
> This seems like it might break when newer iproute
> is run on older kernels. The vid would always be 0
> on show and ignored when adding entries.
> 

I thought it'd be fine because the vid was 0 anyway and 
when it's 0 it's not shown i.e. no vid so the show command
will have the same output. And when set - it'll be ignored
which is again as the behaviour before when it couldn't be
specified.

Here's the new iproute2 on an older kernel:
# ./bridge/bridge mdb add dev virbr0 port vnet1 grp 239.0.0.1 permanent vid 200
# ./bridge/bridge mdb
dev virbr0 port vnet1 grp 239.0.0.1 permanent

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-20 22:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-10 15:02 [PATCH net-next] bridge: mdb: add vlan support for user entries Nikolay Aleksandrov
2015-07-13 21:41 ` David Miller
2015-07-20 22:28 ` Stephen Hemminger
2015-07-20 22:53   ` Nikolay Aleksandrov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).