724-v5.12-net-dsa-exit-early-in-dsa_slave_switchdev_event-if-w.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From 5fb4a451a87d8ed3363d28b63a3295399373d6c4 Mon Sep 17 00:00:00 2001
  2. From: Vladimir Oltean <[email protected]>
  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. Right now, the following would happen for a switch driver that does not
  7. implement .port_fdb_add or .port_fdb_del.
  8. dsa_slave_switchdev_event returns NOTIFY_OK and schedules:
  9. -> dsa_slave_switchdev_event_work
  10. -> dsa_port_fdb_add
  11. -> dsa_port_notify(DSA_NOTIFIER_FDB_ADD)
  12. -> dsa_switch_fdb_add
  13. -> if (!ds->ops->port_fdb_add) return -EOPNOTSUPP;
  14. -> an error is printed with dev_dbg, and
  15. dsa_fdb_offload_notify(switchdev_work) is not called.
  16. We can avoid scheduling the worker for nothing and say NOTIFY_DONE.
  17. Because we don't call dsa_fdb_offload_notify, the static FDB entry will
  18. remain just in the software bridge.
  19. Signed-off-by: Vladimir Oltean <[email protected]>
  20. Reviewed-by: Florian Fainelli <[email protected]>
  21. Reviewed-by: Andrew Lunn <[email protected]>
  22. Signed-off-by: Jakub Kicinski <[email protected]>
  23. ---
  24. net/dsa/slave.c | 3 +++
  25. 1 file changed, 3 insertions(+)
  26. --- a/net/dsa/slave.c
  27. +++ b/net/dsa/slave.c
  28. @@ -2172,6 +2172,9 @@ static int dsa_slave_switchdev_event(str
  29. dp = dsa_slave_to_port(dev);
  30. + if (!dp->ds->ops->port_fdb_add || !dp->ds->ops->port_fdb_del)
  31. + return NOTIFY_DONE;
  32. +
  33. switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);
  34. if (!switchdev_work)
  35. return NOTIFY_BAD;