652efa2567be2460e7d1f305d4a9a43f49ecdc69
[openwrt/staging/dangole.git] /
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
5 program the FDB
6
7 Right now, the following would happen for a switch driver that does not
8 implement .port_fdb_add or .port_fdb_del.
9
10 dsa_slave_switchdev_event returns NOTIFY_OK and schedules:
11 -> dsa_slave_switchdev_event_work
12 -> dsa_port_fdb_add
13 -> dsa_port_notify(DSA_NOTIFIER_FDB_ADD)
14 -> dsa_switch_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.
18
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.
22
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>
27 ---
28 net/dsa/slave.c | 3 +++
29 1 file changed, 3 insertions(+)
30
31 --- a/net/dsa/slave.c
32 +++ b/net/dsa/slave.c
33 @@ -2171,6 +2171,9 @@ static int dsa_slave_switchdev_event(str
34
35 dp = dsa_slave_to_port(dev);
36
37 + if (!dp->ds->ops->port_fdb_add || !dp->ds->ops->port_fdb_del)
38 + return NOTIFY_DONE;
39 +
40 switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);
41 if (!switchdev_work)
42 return NOTIFY_BAD;