diff mbox series

[net-next,v2,3/7] rocker: rocker_main: Ignore bridge VLAN events

Message ID 708f594ac6cef4a63a6f6a28759098c4d7922976.1527503302.git.petrm@mellanox.com
State Superseded, archived
Delegated to: David Miller
Headers show
Series net: bridge: Notify about bridge VLANs | expand

Commit Message

Petr Machata May 28, 2018, 10:50 a.m. UTC
Ignore VLAN events where the orig_dev is the bridge device itself.

Signed-off-by: Petr Machata <petrm@mellanox.com>
---
 drivers/net/ethernet/rocker/rocker_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Ilias Apalodimas May 29, 2018, 10:25 a.m. UTC | #1
Hi Petr, 

On Mon, May 28, 2018 at 12:50:09PM +0200, Petr Machata wrote:
> Ignore VLAN events where the orig_dev is the bridge device itself.
> 
> Signed-off-by: Petr Machata <petrm@mellanox.com>
> ---
>  drivers/net/ethernet/rocker/rocker_main.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c
> index e73e4fe..aeafdb9 100644
> --- a/drivers/net/ethernet/rocker/rocker_main.c
> +++ b/drivers/net/ethernet/rocker/rocker_main.c
> @@ -1632,6 +1632,9 @@ rocker_world_port_obj_vlan_add(struct rocker_port *rocker_port,
>  {
>  	struct rocker_world_ops *wops = rocker_port->rocker->wops;
>  
> +	if (netif_is_bridge_master(vlan->obj.orig_dev))
> +		return -EOPNOTSUPP;
> +
What will happen to the "bridge vlan add dev br0 vid X pvid untagged self" when
the lower level (the driver) returns -EOPNOTSUPP? Will it avoid adding a vlan on
the bridge ?

>  	if (!wops->port_obj_vlan_add)
>  		return -EOPNOTSUPP;
>  
> @@ -1647,6 +1650,9 @@ rocker_world_port_obj_vlan_del(struct rocker_port *rocker_port,
>  {
>  	struct rocker_world_ops *wops = rocker_port->rocker->wops;
>  
> +	if (netif_is_bridge_master(vlan->obj.orig_dev))
> +		return -EOPNOTSUPP;
> +
>  	if (!wops->port_obj_vlan_del)
>  		return -EOPNOTSUPP;
>  	return wops->port_obj_vlan_del(rocker_port, vlan);
> -- 
> 2.4.11
>
Petr Machata May 29, 2018, 2:37 p.m. UTC | #2
Ilias Apalodimas <ilias.apalodimas@linaro.org> writes:

>> diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c
>> index e73e4fe..aeafdb9 100644
>> --- a/drivers/net/ethernet/rocker/rocker_main.c
>> +++ b/drivers/net/ethernet/rocker/rocker_main.c
>> @@ -1632,6 +1632,9 @@ rocker_world_port_obj_vlan_add(struct rocker_port *rocker_port,
>>  {
>>  	struct rocker_world_ops *wops = rocker_port->rocker->wops;
>>  
>> +	if (netif_is_bridge_master(vlan->obj.orig_dev))
>> +		return -EOPNOTSUPP;
>> +
> What will happen to the "bridge vlan add dev br0 vid X pvid untagged self" when
> the lower level (the driver) returns -EOPNOTSUPP? Will it avoid adding a vlan on
> the bridge ?

No, it will still do it. The reasons are:

- that's what currently happens anyway: none of the drivers has any
  support, yet the bridge logic is done

- -EOPNOTSUPP is what switchdev_port_obj_*() return if switchdev is not
  compiled in

In order to suppress the setting, return e.g. -EINVAL:

# bridge vlan add dev br vid 111 self
RTNETLINK answers: Invalid argument
# bridge vlan show dev br
port    vlan ids
br       1 PVID Egress Untagged

Thanks,
Petr
Ilias Apalodimas May 29, 2018, 2:44 p.m. UTC | #3
On Tue, May 29, 2018 at 05:37:30PM +0300, Petr Machata wrote:
> Ilias Apalodimas <ilias.apalodimas@linaro.org> writes:
> 
> >> diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c
> >> index e73e4fe..aeafdb9 100644
> >> --- a/drivers/net/ethernet/rocker/rocker_main.c
> >> +++ b/drivers/net/ethernet/rocker/rocker_main.c
> >> @@ -1632,6 +1632,9 @@ rocker_world_port_obj_vlan_add(struct rocker_port *rocker_port,
> >>  {
> >>  	struct rocker_world_ops *wops = rocker_port->rocker->wops;
> >>  
> >> +	if (netif_is_bridge_master(vlan->obj.orig_dev))
> >> +		return -EOPNOTSUPP;
> >> +
> > What will happen to the "bridge vlan add dev br0 vid X pvid untagged self" when
> > the lower level (the driver) returns -EOPNOTSUPP? Will it avoid adding a vlan on
> > the bridge ?
> 
> No, it will still do it. The reasons are:
> 
> - that's what currently happens anyway: none of the drivers has any
>   support, yet the bridge logic is done
> 
> - -EOPNOTSUPP is what switchdev_port_obj_*() return if switchdev is not
>   compiled in
> 
> In order to suppress the setting, return e.g. -EINVAL:
> 
> # bridge vlan add dev br vid 111 self
> RTNETLINK answers: Invalid argument
> # bridge vlan show dev br
> port    vlan ids
> br       1 PVID Egress Untagged
> 
> Thanks,
> Petr
Ok that's perfect then. As i mentioned it's really useful for a use case i am
doing on a switch that needs it's cpu port configured individually.

Thanks,
Ilias
diff mbox series

Patch

diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c
index e73e4fe..aeafdb9 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -1632,6 +1632,9 @@  rocker_world_port_obj_vlan_add(struct rocker_port *rocker_port,
 {
 	struct rocker_world_ops *wops = rocker_port->rocker->wops;
 
+	if (netif_is_bridge_master(vlan->obj.orig_dev))
+		return -EOPNOTSUPP;
+
 	if (!wops->port_obj_vlan_add)
 		return -EOPNOTSUPP;
 
@@ -1647,6 +1650,9 @@  rocker_world_port_obj_vlan_del(struct rocker_port *rocker_port,
 {
 	struct rocker_world_ops *wops = rocker_port->rocker->wops;
 
+	if (netif_is_bridge_master(vlan->obj.orig_dev))
+		return -EOPNOTSUPP;
+
 	if (!wops->port_obj_vlan_del)
 		return -EOPNOTSUPP;
 	return wops->port_obj_vlan_del(rocker_port, vlan);