Skip to content

Commit 9c26542

Browse files
viviendavem330
authored andcommitted
net: dsa: rollback bridging on error
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8e92ab3 commit 9c26542

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

net/dsa/slave.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,21 @@ static int dsa_slave_bridge_port_join(struct net_device *dev,
562562
struct dsa_switch *ds = p->dp->ds;
563563
int ret = -EOPNOTSUPP;
564564

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

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

570-
return ret == -EOPNOTSUPP ? 0 : ret;
573+
/* The bridging is rolled back on error */
574+
if (ret && ret != -EOPNOTSUPP) {
575+
p->dp->bridge_dev = NULL;
576+
return ret;
577+
}
578+
579+
return 0;
571580
}
572581

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

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

581593
if (ds->ops->port_bridge_leave)

0 commit comments

Comments
 (0)