[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170203182021.14246-4-vivien.didelot@savoirfairelinux.com>
Date: Fri, 3 Feb 2017 13:20:18 -0500
From: Vivien Didelot <vivien.didelot@...oirfairelinux.com>
To: netdev@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, kernel@...oirfairelinux.com,
"David S. Miller" <davem@...emloft.net>,
Florian Fainelli <f.fainelli@...il.com>,
Andrew Lunn <andrew@...n.ch>, cphealy@...il.com,
Vivien Didelot <vivien.didelot@...oirfairelinux.com>
Subject: [PATCH net-next 3/6] 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 <vivien.didelot@...oirfairelinux.com>
---
net/dsa/slave.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 332eb234dc21..d726307c7795 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -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,
@@ -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)
--
2.11.0
Powered by blists - more mailing lists