lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 18 Aug 2022 18:49:10 +0300
From:   Vladimir Oltean <vladimir.oltean@....com>
To:     netdev@...r.kernel.org
Cc:     Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Vladimir Oltean <olteanv@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Kevin Hilman <khilman@...nel.org>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Len Brown <len.brown@...el.com>, Pavel Machek <pavel@....cz>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: [RFC PATCH net-next 09/10] net: dsa: make dsa_tree_notify() and derivatives return void

Now that all cross-chip notifiers where we do care for the error code
were converted to use the robust variant, suppress errors coming from
the rest, giving a clear indication as to what we expect to fail and
what we don't.

Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
 net/dsa/dsa2.c     | 83 +++++++++++++++++++++++++++++++++++++++-------
 net/dsa/dsa_priv.h |  5 +--
 net/dsa/port.c     | 62 ++++++++++++++++------------------
 3 files changed, 103 insertions(+), 47 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 40134ed97980..6596e7c2831d 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -26,6 +26,68 @@ LIST_HEAD(dsa_tree_list);
 /* Track the bridges with forwarding offload enabled */
 static unsigned long dsa_fwd_offloading_bridges;
 
+static const char *dsa_event_name(unsigned long e)
+{
+	switch (e) {
+	case DSA_NOTIFIER_AGEING_TIME:
+		return "DSA_NOTIFIER_AGEING_TIME";
+	case DSA_NOTIFIER_BRIDGE_JOIN:
+		return "DSA_NOTIFIER_BRIDGE_JOIN";
+	case DSA_NOTIFIER_BRIDGE_LEAVE:
+		return "DSA_NOTIFIER_BRIDGE_LEAVE";
+	case DSA_NOTIFIER_FDB_ADD:
+		return "DSA_NOTIFIER_FDB_ADD";
+	case DSA_NOTIFIER_FDB_DEL:
+		return "DSA_NOTIFIER_FDB_DEL";
+	case DSA_NOTIFIER_HOST_FDB_ADD:
+		return "DSA_NOTIFIER_HOST_FDB_ADD";
+	case DSA_NOTIFIER_HOST_FDB_DEL:
+		return "DSA_NOTIFIER_HOST_FDB_DEL";
+	case DSA_NOTIFIER_LAG_FDB_ADD:
+		return "DSA_NOTIFIER_LAG_FDB_ADD";
+	case DSA_NOTIFIER_LAG_FDB_DEL:
+		return "DSA_NOTIFIER_LAG_FDB_DEL";
+	case DSA_NOTIFIER_LAG_CHANGE:
+		return "DSA_NOTIFIER_LAG_CHANGE";
+	case DSA_NOTIFIER_LAG_JOIN:
+		return "DSA_NOTIFIER_LAG_JOIN";
+	case DSA_NOTIFIER_LAG_LEAVE:
+		return "DSA_NOTIFIER_LAG_LEAVE";
+	case DSA_NOTIFIER_MDB_ADD:
+		return "DSA_NOTIFIER_MDB_ADD";
+	case DSA_NOTIFIER_MDB_DEL:
+		return "DSA_NOTIFIER_MDB_DEL";
+	case DSA_NOTIFIER_HOST_MDB_ADD:
+		return "DSA_NOTIFIER_HOST_MDB_ADD";
+	case DSA_NOTIFIER_HOST_MDB_DEL:
+		return "DSA_NOTIFIER_HOST_MDB_DEL";
+	case DSA_NOTIFIER_VLAN_ADD:
+		return "DSA_NOTIFIER_VLAN_ADD";
+	case DSA_NOTIFIER_VLAN_DEL:
+		return "DSA_NOTIFIER_VLAN_DEL";
+	case DSA_NOTIFIER_HOST_VLAN_ADD:
+		return "DSA_NOTIFIER_HOST_VLAN_ADD";
+	case DSA_NOTIFIER_HOST_VLAN_DEL:
+		return "DSA_NOTIFIER_HOST_VLAN_DEL";
+	case DSA_NOTIFIER_MTU:
+		return "DSA_NOTIFIER_MTU";
+	case DSA_NOTIFIER_TAG_PROTO:
+		return "DSA_NOTIFIER_TAG_PROTO";
+	case DSA_NOTIFIER_TAG_PROTO_CONNECT:
+		return "DSA_NOTIFIER_TAG_PROTO_CONNECT";
+	case DSA_NOTIFIER_TAG_PROTO_DISCONNECT:
+		return "DSA_NOTIFIER_TAG_PROTO_DISCONNECT";
+	case DSA_NOTIFIER_TAG_8021Q_VLAN_ADD:
+		return "DSA_NOTIFIER_TAG_8021Q_VLAN_ADD";
+	case DSA_NOTIFIER_TAG_8021Q_VLAN_DEL:
+		return "DSA_NOTIFIER_TAG_8021Q_VLAN_DEL";
+	case DSA_NOTIFIER_MASTER_STATE_CHANGE:
+		return "DSA_NOTIFIER_MASTER_STATE_CHANGE";
+	default:
+		return "unknown";
+	}
+}
+
 /**
  * dsa_tree_notify - Execute code for all switches in a DSA switch tree.
  * @dst: collection of struct dsa_switch devices to notify.
@@ -36,14 +98,17 @@ static unsigned long dsa_fwd_offloading_bridges;
  * each member DSA switch. The other alternative of traversing the tree is only
  * through its ports list, which does not uniquely list the switches.
  */
-int dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v)
+void dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v)
 {
 	struct raw_notifier_head *nh = &dst->nh;
 	int err;
 
 	err = raw_notifier_call_chain(nh, e, v);
 
-	return notifier_to_errno(err);
+	err = notifier_to_errno(err);
+	if (err)
+		pr_err("DSA tree %d failed to notify event %s: %pe\n",
+		       dst->index, dsa_event_name(e), ERR_PTR(err));
 }
 
 /**
@@ -80,18 +145,12 @@ int dsa_tree_notify_robust(struct dsa_switch_tree *dst, unsigned long e,
  * WARNING: this function is not reliable during probe time, because probing
  * between trees is asynchronous and not all DSA trees might have probed.
  */
-int dsa_broadcast(unsigned long e, void *v)
+void dsa_broadcast(unsigned long e, void *v)
 {
 	struct dsa_switch_tree *dst;
-	int err = 0;
 
-	list_for_each_entry(dst, &dsa_tree_list, list) {
-		err = dsa_tree_notify(dst, e, v);
-		if (err)
-			break;
-	}
-
-	return err;
+	list_for_each_entry(dst, &dsa_tree_list, list)
+		dsa_tree_notify(dst, e, v);
 }
 
 /**
@@ -108,7 +167,7 @@ int dsa_broadcast_robust(unsigned long e, void *v, unsigned long e_rollback,
 			 void *v_rollback)
 {
 	struct dsa_switch_tree *dst;
-	int err = 0;
+	int err;
 
 	list_for_each_entry(dst, &dsa_tree_list, list) {
 		err = dsa_tree_notify_robust(dst, e, v, e_rollback, v_rollback);
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 6c935f151864..263a07152b07 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -17,6 +17,7 @@
 
 #define DSA_MAX_NUM_OFFLOADING_BRIDGES		BITS_PER_LONG
 
+/* Please update dsa_event_name() when adding new elements to this array */
 enum {
 	DSA_NOTIFIER_AGEING_TIME,
 	DSA_NOTIFIER_BRIDGE_JOIN,
@@ -543,10 +544,10 @@ void dsa_lag_map(struct dsa_switch_tree *dst, struct dsa_lag *lag);
 void dsa_lag_unmap(struct dsa_switch_tree *dst, struct dsa_lag *lag);
 struct dsa_lag *dsa_tree_lag_find(struct dsa_switch_tree *dst,
 				  const struct net_device *lag_dev);
-int dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v);
+void dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v);
 int dsa_tree_notify_robust(struct dsa_switch_tree *dst, unsigned long e,
 			   void *v, unsigned long e_rollback, void *v_rollback);
-int dsa_broadcast(unsigned long e, void *v);
+void dsa_broadcast(unsigned long e, void *v);
 int dsa_broadcast_robust(unsigned long e, void *v, unsigned long e_rollback,
 			 void *v_rollback);
 int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst,
diff --git a/net/dsa/port.c b/net/dsa/port.c
index 4095592c4790..1452f818263a 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -25,9 +25,9 @@
  * reconfigure ports without net_devices (CPU ports, DSA links) whenever
  * a user port's state changes.
  */
-static int dsa_port_notify(const struct dsa_port *dp, unsigned long e, void *v)
+static void dsa_port_notify(const struct dsa_port *dp, unsigned long e, void *v)
 {
-	return dsa_tree_notify(dp->ds->dst, e, v);
+	dsa_tree_notify(dp->ds->dst, e, v);
 }
 
 /**
@@ -551,7 +551,6 @@ void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br)
 	struct dsa_notifier_bridge_info info = {
 		.dp = dp,
 	};
-	int err;
 
 	/* If the port could not be offloaded to begin with, then
 	 * there is nothing to do.
@@ -566,11 +565,7 @@ void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br)
 	 */
 	dsa_port_bridge_destroy(dp, br);
 
-	err = dsa_broadcast(DSA_NOTIFIER_BRIDGE_LEAVE, &info);
-	if (err)
-		dev_err(dp->ds->dev,
-			"port %d failed to notify DSA_NOTIFIER_BRIDGE_LEAVE: %pe\n",
-			dp->index, ERR_PTR(err));
+	dsa_broadcast(DSA_NOTIFIER_BRIDGE_LEAVE, &info);
 
 	dsa_port_switchdev_unsync_attrs(dp, info.bridge);
 }
@@ -598,7 +593,9 @@ int dsa_port_lag_change(struct dsa_port *dp,
 
 	dp->lag_tx_enabled = tx_enabled;
 
-	return dsa_port_notify(dp, DSA_NOTIFIER_LAG_CHANGE, &info);
+	dsa_port_notify(dp, DSA_NOTIFIER_LAG_CHANGE, &info);
+
+	return 0;
 }
 
 static int dsa_port_lag_create(struct dsa_port *dp,
@@ -696,7 +693,6 @@ void dsa_port_lag_leave(struct dsa_port *dp, struct net_device *lag_dev)
 	struct dsa_notifier_lag_info info = {
 		.dp = dp,
 	};
-	int err;
 
 	if (!dp->lag)
 		return;
@@ -711,11 +707,7 @@ void dsa_port_lag_leave(struct dsa_port *dp, struct net_device *lag_dev)
 
 	dsa_port_lag_destroy(dp);
 
-	err = dsa_port_notify(dp, DSA_NOTIFIER_LAG_LEAVE, &info);
-	if (err)
-		dev_err(dp->ds->dev,
-			"port %d failed to notify DSA_NOTIFIER_LAG_LEAVE: %pe\n",
-			dp->index, ERR_PTR(err));
+	dsa_port_notify(dp, DSA_NOTIFIER_LAG_LEAVE, &info);
 }
 
 /* Must be called under rcu_read_lock() */
@@ -1027,7 +1019,9 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
 	if (!dp->ds->fdb_isolation)
 		info.db.bridge.num = 0;
 
-	return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info);
+	dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info);
+
+	return 0;
 }
 
 static int dsa_port_host_fdb_add(struct dsa_port *dp,
@@ -1096,7 +1090,9 @@ static int dsa_port_host_fdb_del(struct dsa_port *dp,
 	if (!dp->ds->fdb_isolation)
 		info.db.bridge.num = 0;
 
-	return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_DEL, &info);
+	dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_DEL, &info);
+
+	return 0;
 }
 
 int dsa_port_standalone_host_fdb_del(struct dsa_port *dp,
@@ -1165,7 +1161,9 @@ int dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr,
 	if (!dp->ds->fdb_isolation)
 		info.db.bridge.num = 0;
 
-	return dsa_port_notify(dp, DSA_NOTIFIER_LAG_FDB_DEL, &info);
+	dsa_port_notify(dp, DSA_NOTIFIER_LAG_FDB_DEL, &info);
+
+	return 0;
 }
 
 int dsa_port_fdb_dump(struct dsa_port *dp, dsa_fdb_dump_cb_t *cb, void *data)
@@ -1213,7 +1211,9 @@ int dsa_port_mdb_del(const struct dsa_port *dp,
 	if (!dp->ds->fdb_isolation)
 		info.db.bridge.num = 0;
 
-	return dsa_port_notify(dp, DSA_NOTIFIER_MDB_DEL, &info);
+	dsa_port_notify(dp, DSA_NOTIFIER_MDB_DEL, &info);
+
+	return 0;
 }
 
 static int dsa_port_host_mdb_add(const struct dsa_port *dp,
@@ -1274,7 +1274,9 @@ static int dsa_port_host_mdb_del(const struct dsa_port *dp,
 	if (!dp->ds->fdb_isolation)
 		info.db.bridge.num = 0;
 
-	return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_DEL, &info);
+	dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_DEL, &info);
+
+	return 0;
 }
 
 int dsa_port_standalone_host_mdb_del(const struct dsa_port *dp,
@@ -1327,7 +1329,9 @@ int dsa_port_vlan_del(struct dsa_port *dp,
 		.vlan = vlan,
 	};
 
-	return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info);
+	dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info);
+
+	return 0;
 }
 
 int dsa_port_host_vlan_add(struct dsa_port *dp,
@@ -1360,15 +1364,12 @@ int dsa_port_host_vlan_del(struct dsa_port *dp,
 		.vlan = vlan,
 	};
 	struct dsa_port *cpu_dp = dp->cpu_dp;
-	int err;
 
-	err = dsa_port_notify(dp, DSA_NOTIFIER_HOST_VLAN_DEL, &info);
-	if (err && err != -EOPNOTSUPP)
-		return err;
+	dsa_port_notify(dp, DSA_NOTIFIER_HOST_VLAN_DEL, &info);
 
 	vlan_vid_del(cpu_dp->master, htons(ETH_P_8021Q), vlan->vid);
 
-	return err;
+	return 0;
 }
 
 int dsa_port_mrp_add(const struct dsa_port *dp,
@@ -1795,14 +1796,9 @@ void dsa_port_tag_8021q_vlan_del(struct dsa_port *dp, u16 vid, bool broadcast)
 		.dp = dp,
 		.vid = vid,
 	};
-	int err;
 
 	if (broadcast)
-		err = dsa_broadcast(DSA_NOTIFIER_TAG_8021Q_VLAN_DEL, &info);
+		dsa_broadcast(DSA_NOTIFIER_TAG_8021Q_VLAN_DEL, &info);
 	else
-		err = dsa_port_notify(dp, DSA_NOTIFIER_TAG_8021Q_VLAN_DEL, &info);
-	if (err)
-		dev_err(dp->ds->dev,
-			"port %d failed to notify tag_8021q VLAN %d deletion: %pe\n",
-			dp->index, vid, ERR_PTR(err));
+		dsa_port_notify(dp, DSA_NOTIFIER_TAG_8021Q_VLAN_DEL, &info);
 }
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ