Skip to content

Commit

Permalink
net: dsa: rollback bridging on error
Browse files Browse the repository at this point in the history
When an error is returned during the bridging of a port in a
NETDEV_CHANGEUPPER event, net/core/dev.c rolls back the operation.

Be consistent and unassign dp->bridge_dev when this happens.

In the meantime, add comments to document this behavior.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
vivien authored and davem330 committed Feb 6, 2017
1 parent 8e92ab3 commit 9c26542
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,21 @@ static int dsa_slave_bridge_port_join(struct net_device *dev,
struct dsa_switch *ds = p->dp->ds;
int ret = -EOPNOTSUPP;

/* Here the port is already bridged. Reflect the current configuration
* so that drivers can program their chips accordingly.
*/
p->dp->bridge_dev = br;

if (ds->ops->port_bridge_join)
ret = ds->ops->port_bridge_join(ds, p->dp->index, br);

return ret == -EOPNOTSUPP ? 0 : ret;
/* The bridging is rolled back on error */
if (ret && ret != -EOPNOTSUPP) {
p->dp->bridge_dev = NULL;
return ret;
}

return 0;
}

static void dsa_slave_bridge_port_leave(struct net_device *dev,
Expand All @@ -576,6 +585,9 @@ static void dsa_slave_bridge_port_leave(struct net_device *dev,
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;

/* Here the port is already unbridged. Reflect the current configuration
* so that drivers can program their chips accordingly.
*/
p->dp->bridge_dev = NULL;

if (ds->ops->port_bridge_leave)
Expand Down

0 comments on commit 9c26542

Please sign in to comment.