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