switchdev: skip over ports returning -EOPNOTSUPP when recursing ports
authorScott Feldman <sfeldma@gmail.com>
Fri, 9 Oct 2015 02:23:18 +0000 (19:23 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Oct 2015 12:20:20 +0000 (05:20 -0700)
This allows us to recurse over all the ports, skipping over unsupporting
ports.  Without the change, the recursion would stop at first unsupported
port.

Signed-off-by: Scott Feldman <sfeldma@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/switchdev.h
net/switchdev/switchdev.c

index 61f129bd74b237129fc67d120a794037e3500951..1ce70830357d7b94af5904877cec6c59e67f350e 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/list.h>
 
 #define SWITCHDEV_F_NO_RECURSE         BIT(0)
+#define SWITCHDEV_F_SKIP_EOPNOTSUPP    BIT(1)
 
 struct switchdev_trans_item {
        struct list_head list;
index 6e4a4f9ad927a175a927e2f155c0db323043d111..7a9ab90363be1205dcff102fa486cd5698569e99 100644 (file)
@@ -147,7 +147,7 @@ static int __switchdev_port_attr_set(struct net_device *dev,
                return ops->switchdev_port_attr_set(dev, attr, trans);
 
        if (attr->flags & SWITCHDEV_F_NO_RECURSE)
-               return err;
+               goto done;
 
        /* Switch device port(s) may be stacked under
         * bond/team/vlan dev, so recurse down to set attr on
@@ -156,10 +156,17 @@ static int __switchdev_port_attr_set(struct net_device *dev,
 
        netdev_for_each_lower_dev(dev, lower_dev, iter) {
                err = __switchdev_port_attr_set(lower_dev, attr, trans);
+               if (err == -EOPNOTSUPP &&
+                   attr->flags & SWITCHDEV_F_SKIP_EOPNOTSUPP)
+                       continue;
                if (err)
                        break;
        }
 
+done:
+       if (err == -EOPNOTSUPP && attr->flags & SWITCHDEV_F_SKIP_EOPNOTSUPP)
+               err = 0;
+
        return err;
 }