History

switchdev: fix stp update API to work with layered netdevices

make it same as the netdev_switch_port_bridge_setlink/dellink api (ie traverse lowerdevs to get to the switch port). removes "WARN_ON(!ops->ndo_switch_parent_id_get)" because direct bridge ports can be stacked netdevices (like bonds and team of switch ports) which may not implement this ndo. v2 to v3: - remove changes to bond and team. Bring back the transparently following lowerdevs like i initially had for setlink/getlink (http://www.spinics.net/lists/netdev/msg313436.html) dave and scott feldman also seem to prefer it be that way and move to non-transparent way of doing things if we see a problem down the lane. v3 to v4: - fix ret initialization v4 to v5: - return err on first failure (scott feldman) v5 to v6: - change variable name (err) and initialize to -EOPNOTSUPP (scott feldman).

Roopa Prabhu committed 11 years ago

Commit 558d51f1 parent 08b4b8e1 file · +13 −4Browse files

Showing the changes to net/switchdev/switchdev.c (1 of 1 file). Show all

Unified · Split

net/switchdev/switchdev.c+13−4
@@ -47,11 +47,20 @@ EXPORT_SYMBOL_GPL(netdev_switch_parent_id_get); · 46 unmodified lines
4747 int netdev_switch_port_stp_update(struct net_device *dev, u8 state)
4848 {
4949 const struct swdev_ops *ops = dev->swdev_ops;
50+ struct net_device *lower_dev;
51+ struct list_head *iter;
52+ int err = -EOPNOTSUPP;
5053
51− if (!ops || !ops->swdev_port_stp_update)
52− return -EOPNOTSUPP;
53− WARN_ON(!ops->swdev_parent_id_get);
54− return ops->swdev_port_stp_update(dev, state);
54+ if (ops && ops->swdev_port_stp_update)
55+ return ops->swdev_port_stp_update(dev, state);
56+
57+ netdev_for_each_lower_dev(dev, lower_dev, iter) {
58+ err = netdev_switch_port_stp_update(lower_dev, state);
59+ if (err && err != -EOPNOTSUPP)
60+ return err;
61+ }
62+
63+ return err;
5564 }
5665 EXPORT_SYMBOL_GPL(netdev_switch_port_stp_update);
5766