This is the second attempt to provide a fix for the issue described in
99b8202b179f, which was reverted in the previous commit.

When a change is made to some global bridge attribute, such as VLAN
filtering, accept events where orig_dev is the bridge master netdev.

Separate the validation of orig_dev based on whether the attribute in
question is global or per-port.

Fixes: 5696c8aedfcc ("net: dsa: Don't offload port attributes on standalone 
ports")
Signed-off-by: Tobias Waldekranz <tob...@waldekranz.com>
---
 net/dsa/slave.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 491e3761b5f4..63ee2cae4d8e 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -278,8 +278,21 @@ static int dsa_slave_port_attr_set(struct net_device *dev,
        struct dsa_port *dp = dsa_slave_to_port(dev);
        int ret;
 
-       if (!dsa_port_offloads_netdev(dp, attr->orig_dev))
-               return -EOPNOTSUPP;
+       switch (attr->id) {
+       case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
+       case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
+       case SWITCHDEV_ATTR_ID_BRIDGE_MROUTER:
+               /* For global bridge settings, the originating device
+                * may be the bridge itself.
+                */
+               if (netif_is_bridge_master(attr->orig_dev))
+                       break;
+
+               fallthrough;
+       default:
+               if (!dsa_port_offloads_netdev(dp, attr->orig_dev))
+                       return -EOPNOTSUPP;
+       }
 
        switch (attr->id) {
        case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
-- 
2.25.1

Reply via email to