Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

switchdev: respect SKIP_EOPNOTSUPP flag in case there is no recursion

Caller passing down the SKIP_EOPNOTSUPP switchdev flag expects that
-EOPNOTSUPP cannot be returned. But in case of direct op call without
recurtion, this may happen. So fix this by checking it always on the
end of __switchdev_port_attr_set function.

Fixes: 464314ea6c11 ("switchdev: skip over ports returning -EOPNOTSUPP when recursing ports")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jiri Pirko and committed by
David S. Miller
0c63d80c 2a4f4176

+4 -5
+4 -5
net/switchdev/switchdev.c
··· 225 225 struct list_head *iter; 226 226 int err = -EOPNOTSUPP; 227 227 228 - if (ops && ops->switchdev_port_attr_set) 229 - return ops->switchdev_port_attr_set(dev, attr, trans); 228 + if (ops && ops->switchdev_port_attr_set) { 229 + err = ops->switchdev_port_attr_set(dev, attr, trans); 230 + goto done; 231 + } 230 232 231 233 if (attr->flags & SWITCHDEV_F_NO_RECURSE) 232 234 goto done; ··· 240 238 241 239 netdev_for_each_lower_dev(dev, lower_dev, iter) { 242 240 err = __switchdev_port_attr_set(lower_dev, attr, trans); 243 - if (err == -EOPNOTSUPP && 244 - attr->flags & SWITCHDEV_F_SKIP_EOPNOTSUPP) 245 - continue; 246 241 if (err) 247 242 break; 248 243 }