Skip to content

Commit 81a619f

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: include fdb entries pointing to bridge in the host fdb list
The bridge supports a legacy way of adding local (non-forwarded) FDB entries, which works on an individual port basis: bridge fdb add dev swp0 00:01:02:03:04:05 master local As well as a new way, added by Roopa Prabhu in commit 3741873 ("bridge: allow adding of fdb entries pointing to the bridge device"): bridge fdb add dev br0 00:01:02:03:04:05 self local The two commands are functionally equivalent, except that the first one produces an entry with fdb->dst == swp0, and the other an entry with fdb->dst == NULL. The confusing part, though, is that even if fdb->dst is swp0 for the 'local on port' entry, that destination is not used. Nonetheless, the idea is that the bridge has reference counting for local entries, and local entries pointing towards the bridge are still 'as local' as local entries for a port. The bridge adds the MAC addresses of the interfaces automatically as FDB entries with is_local=1. For the MAC address of the ports, fdb->dst will be equal to the port, and for the MAC address of the bridge, fdb->dst will point towards the bridge (i.e. be NULL). Therefore, if the MAC address of the bridge is not inherited from either of the physical ports, then we must explicitly catch local FDB entries emitted towards the br0, otherwise we'll miss the MAC address of the bridge (and, of course, any entry with 'bridge add dev br0 ... self local'). Co-developed-by: Tobias Waldekranz <[email protected]> Signed-off-by: Tobias Waldekranz <[email protected]> Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 10fae4a commit 81a619f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

net/dsa/slave.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,7 +2415,11 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused,
24152415
struct net_device *br_dev;
24162416
struct dsa_slave_priv *p;
24172417

2418-
br_dev = netdev_master_upper_dev_get_rcu(dev);
2418+
if (netif_is_bridge_master(dev))
2419+
br_dev = dev;
2420+
else
2421+
br_dev = netdev_master_upper_dev_get_rcu(dev);
2422+
24192423
if (!br_dev)
24202424
return NOTIFY_DONE;
24212425

@@ -2443,8 +2447,13 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused,
24432447
* LAG we don't want to send traffic to the CPU, the
24442448
* other ports bridged with the LAG should be able to
24452449
* autonomously forward towards it.
2450+
* On the other hand, if the address is local
2451+
* (therefore not learned) then we want to trap it to
2452+
* the CPU regardless of whether the interface it
2453+
* belongs to is offloaded or not.
24462454
*/
2447-
if (dsa_tree_offloads_bridge_port(dp->ds->dst, dev))
2455+
if (dsa_tree_offloads_bridge_port(dp->ds->dst, dev) &&
2456+
!fdb_info->is_local)
24482457
return NOTIFY_DONE;
24492458
}
24502459

0 commit comments

Comments
 (0)