net: dsa: sync static FDB entries on foreign interfaces to hardware
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 29 Jun 2021 14:06:54 +0000 (17:06 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 29 Jun 2021 17:46:23 +0000 (10:46 -0700)
commit3068d466a67ec96a6972f248f5c7a7b6763dbeb1
tree574d7e40b13c85ab4ca64d9f0a53ed9fb0d5a458
parent26ee7b06a4d3086a3751b69c14663ba6c6bbfe7f
net: dsa: sync static FDB entries on foreign interfaces to hardware

DSA is able to install FDB entries towards the CPU port for addresses
which were dynamically learnt by the software bridge on foreign
interfaces that are in the same bridge with a DSA switch interface.
Since this behavior is opportunistic, it is guarded by the
"assisted_learning_on_cpu_port" property which can be enabled by drivers
and is not done automatically (since certain switches may support
address learning of packets coming from the CPU port).

But if those FDB entries added on the foreign interfaces are static
(added by the user) instead of dynamically learnt, currently DSA does
not do anything (and arguably it should).

Because static FDB entries are not supposed to move on their own, there
is no downside in reusing the "assisted_learning_on_cpu_port" logic to
sync static FDB entries to the DSA CPU port unconditionally, even if
assisted_learning_on_cpu_port is not requested by the driver.

For example, this situation:

   br0
   / \
swp0 dummy0

$ bridge fdb add 02:00:de:ad:00:01 dev dummy0 vlan 1 master static

Results in DSA adding an entry in the hardware FDB, pointing this
address towards the CPU port.

The same is true for entries added to the bridge itself, e.g:

$ bridge fdb add 02:00:de:ad:00:01 dev br0 vlan 1 self local

(except that right now, DSA still ignores 'local' FDB entries, this will
be changed in a later patch)

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/slave.c