1 From 5fb4a451a87d8ed3363d28b63a3295399373d6c4 Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Wed, 6 Jan 2021 11:51:34 +0200
4 Subject: [PATCH] net: dsa: exit early in dsa_slave_switchdev_event if we can't
7 Right now, the following would happen for a switch driver that does not
8 implement .port_fdb_add or .port_fdb_del.
10 dsa_slave_switchdev_event returns NOTIFY_OK and schedules:
11 -> dsa_slave_switchdev_event_work
13 -> dsa_port_notify(DSA_NOTIFIER_FDB_ADD)
15 -> if (!ds->ops->port_fdb_add) return -EOPNOTSUPP;
16 -> an error is printed with dev_dbg, and
17 dsa_fdb_offload_notify(switchdev_work) is not called.
19 We can avoid scheduling the worker for nothing and say NOTIFY_DONE.
20 Because we don't call dsa_fdb_offload_notify, the static FDB entry will
21 remain just in the software bridge.
23 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
24 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
25 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
26 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
28 net/dsa/slave.c | 3 +++
29 1 file changed, 3 insertions(+)
33 @@ -1650,6 +1650,9 @@ static int dsa_slave_switchdev_event(str
35 dp = dsa_slave_to_port(dev);
37 + if (!dp->ds->ops->port_fdb_add || !dp->ds->ops->port_fdb_del)
40 switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);