767-net-dsa-Sync-static-FDB-entries-on-foreign-interface.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From 81e39fd78db82fb51b05fff309b9c521f1a0bc5a Mon Sep 17 00:00:00 2001
  2. From: Tobias Waldekranz <[email protected]>
  3. Date: Sat, 16 Jan 2021 02:25:14 +0100
  4. Subject: [PATCH] net: dsa: Sync static FDB entries on foreign interfaces to
  5. hardware
  6. Reuse the "assisted_learning_on_cpu_port" functionality to always add
  7. entries for user-configured entries on foreign interfaces, even if
  8. assisted_learning_on_cpu_port is not enabled. E.g. in this situation:
  9. br0
  10. / \
  11. swp0 dummy0
  12. $ bridge fdb add 02:00:de:ad:00:01 dev dummy0 vlan 1 master
  13. Results in DSA adding an entry in the hardware FDB, pointing this
  14. address towards the CPU port.
  15. The same is true for entries added to the bridge itself, e.g:
  16. $ bridge fdb add 02:00:de:ad:00:01 dev br0 vlan 1 self
  17. Signed-off-by: Tobias Waldekranz <[email protected]>
  18. ---
  19. net/dsa/slave.c | 12 ++++++++----
  20. 1 file changed, 8 insertions(+), 4 deletions(-)
  21. --- a/net/dsa/slave.c
  22. +++ b/net/dsa/slave.c
  23. @@ -2199,9 +2199,12 @@ static int dsa_slave_switchdev_event(str
  24. else if (!fdb_info->added_by_user)
  25. return NOTIFY_OK;
  26. } else {
  27. - /* Snoop addresses learnt on foreign interfaces
  28. - * bridged with us, for switches that don't
  29. - * automatically learn SA from CPU-injected traffic
  30. + /* Snoop addresses added to foreign interfaces
  31. + * bridged with us, or the bridge
  32. + * itself. Dynamically learned addresses can
  33. + * also be added for switches that don't
  34. + * automatically learn SA from CPU-injected
  35. + * traffic.
  36. */
  37. struct net_device *br_dev;
  38. struct dsa_slave_priv *p;
  39. @@ -2223,7 +2226,8 @@ static int dsa_slave_switchdev_event(str
  40. dp = p->dp->cpu_dp;
  41. - if (!dp->ds->assisted_learning_on_cpu_port)
  42. + if (!fdb_info->added_by_user &&
  43. + !dp->ds->assisted_learning_on_cpu_port)
  44. return NOTIFY_DONE;
  45. }