Skip to content

Commit 2c4eca3

Browse files
vladimirolteandavem330
authored andcommitted
net: bridge: switchdev: include local flag in FDB notifications
As explained in bugfix commit 6ab4c31 ("net: bridge: don't notify switchdev for local FDB addresses") as well as in this discussion: https://lore.kernel.org/netdev/20210117193009.io3nungdwuzmo5f7@skbuf/ the switchdev notifiers for FDB entries managed to have a zero-day bug, which was that drivers would not know what to do with local FDB entries, because they were not told that they are local. The bug fix was to simply not notify them of those addresses. Let us now add the 'is_local' bit to bridge FDB entries, and make all drivers ignore these entries by their own choice. Co-developed-by: Tobias Waldekranz <tobias@waldekranz.com> Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e5b4b89 commit 2c4eca3

9 files changed

Lines changed: 15 additions & 14 deletions

File tree

‎drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,7 +2098,7 @@ static void dpaa2_switch_event_work(struct work_struct *work)
20982098

20992099
switch (switchdev_work->event) {
21002100
case SWITCHDEV_FDB_ADD_TO_DEVICE:
2101-
if (!fdb_info->added_by_user)
2101+
if (!fdb_info->added_by_user || fdb_info->is_local)
21022102
break;
21032103
if (is_unicast_ether_addr(fdb_info->addr))
21042104
err = dpaa2_switch_port_fdb_add_uc(netdev_priv(dev),
@@ -2113,7 +2113,7 @@ static void dpaa2_switch_event_work(struct work_struct *work)
21132113
&fdb_info->info, NULL);
21142114
break;
21152115
case SWITCHDEV_FDB_DEL_TO_DEVICE:
2116-
if (!fdb_info->added_by_user)
2116+
if (!fdb_info->added_by_user || fdb_info->is_local)
21172117
break;
21182118
if (is_unicast_ether_addr(fdb_info->addr))
21192119
dpaa2_switch_port_fdb_del_uc(netdev_priv(dev), fdb_info->addr);

‎drivers/net/ethernet/marvell/prestera/prestera_switchdev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ static void prestera_fdb_event_work(struct work_struct *work)
798798
switch (swdev_work->event) {
799799
case SWITCHDEV_FDB_ADD_TO_DEVICE:
800800
fdb_info = &swdev_work->fdb_info;
801-
if (!fdb_info->added_by_user)
801+
if (!fdb_info->added_by_user || fdb_info->is_local)
802802
break;
803803

804804
err = prestera_port_fdb_set(port, fdb_info, true);

‎drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,7 +2916,8 @@ mlxsw_sp_switchdev_bridge_nve_fdb_event(struct mlxsw_sp_switchdev_event_work *
29162916
return;
29172917

29182918
if (switchdev_work->event == SWITCHDEV_FDB_ADD_TO_DEVICE &&
2919-
!switchdev_work->fdb_info.added_by_user)
2919+
(!switchdev_work->fdb_info.added_by_user ||
2920+
switchdev_work->fdb_info.is_local))
29202921
return;
29212922

29222923
if (!netif_running(dev))
@@ -2971,7 +2972,7 @@ static void mlxsw_sp_switchdev_bridge_fdb_event_work(struct work_struct *work)
29712972
switch (switchdev_work->event) {
29722973
case SWITCHDEV_FDB_ADD_TO_DEVICE:
29732974
fdb_info = &switchdev_work->fdb_info;
2974-
if (!fdb_info->added_by_user)
2975+
if (!fdb_info->added_by_user || fdb_info->is_local)
29752976
break;
29762977
err = mlxsw_sp_port_fdb_set(mlxsw_sp_port, fdb_info, true);
29772978
if (err)

‎drivers/net/ethernet/rocker/rocker_main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,7 +2736,7 @@ static void rocker_switchdev_event_work(struct work_struct *work)
27362736
switch (switchdev_work->event) {
27372737
case SWITCHDEV_FDB_ADD_TO_DEVICE:
27382738
fdb_info = &switchdev_work->fdb_info;
2739-
if (!fdb_info->added_by_user)
2739+
if (!fdb_info->added_by_user || fdb_info->is_local)
27402740
break;
27412741
err = rocker_world_port_fdb_add(rocker_port, fdb_info);
27422742
if (err) {
@@ -2747,7 +2747,7 @@ static void rocker_switchdev_event_work(struct work_struct *work)
27472747
break;
27482748
case SWITCHDEV_FDB_DEL_TO_DEVICE:
27492749
fdb_info = &switchdev_work->fdb_info;
2750-
if (!fdb_info->added_by_user)
2750+
if (!fdb_info->added_by_user || fdb_info->is_local)
27512751
break;
27522752
err = rocker_world_port_fdb_del(rocker_port, fdb_info);
27532753
if (err)

‎drivers/net/ethernet/ti/am65-cpsw-switchdev.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ static void am65_cpsw_switchdev_event_work(struct work_struct *work)
385385
fdb->addr, fdb->vid, fdb->added_by_user,
386386
fdb->offloaded, port_id);
387387

388-
if (!fdb->added_by_user)
388+
if (!fdb->added_by_user || fdb->is_local)
389389
break;
390390
if (memcmp(port->slave.mac_addr, (u8 *)fdb->addr, ETH_ALEN) == 0)
391391
port_id = HOST_PORT_NUM;
@@ -401,7 +401,7 @@ static void am65_cpsw_switchdev_event_work(struct work_struct *work)
401401
fdb->addr, fdb->vid, fdb->added_by_user,
402402
fdb->offloaded, port_id);
403403

404-
if (!fdb->added_by_user)
404+
if (!fdb->added_by_user || fdb->is_local)
405405
break;
406406
if (memcmp(port->slave.mac_addr, (u8 *)fdb->addr, ETH_ALEN) == 0)
407407
port_id = HOST_PORT_NUM;

‎drivers/net/ethernet/ti/cpsw_switchdev.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ static void cpsw_switchdev_event_work(struct work_struct *work)
395395
fdb->addr, fdb->vid, fdb->added_by_user,
396396
fdb->offloaded, port);
397397

398-
if (!fdb->added_by_user)
398+
if (!fdb->added_by_user || fdb->is_local)
399399
break;
400400
if (memcmp(priv->mac_addr, (u8 *)fdb->addr, ETH_ALEN) == 0)
401401
port = HOST_PORT_NUM;
@@ -411,7 +411,7 @@ static void cpsw_switchdev_event_work(struct work_struct *work)
411411
fdb->addr, fdb->vid, fdb->added_by_user,
412412
fdb->offloaded, port);
413413

414-
if (!fdb->added_by_user)
414+
if (!fdb->added_by_user || fdb->is_local)
415415
break;
416416
if (memcmp(priv->mac_addr, (u8 *)fdb->addr, ETH_ALEN) == 0)
417417
port = HOST_PORT_NUM;

‎include/net/switchdev.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ struct switchdev_notifier_fdb_info {
209209
const unsigned char *addr;
210210
u16 vid;
211211
u8 added_by_user:1,
212+
is_local:1,
212213
offloaded:1;
213214
};
214215

‎net/bridge/br_switchdev.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,12 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
114114
.addr = fdb->key.addr.addr,
115115
.vid = fdb->key.vlan_id,
116116
.added_by_user = test_bit(BR_FDB_ADDED_BY_USER, &fdb->flags),
117+
.is_local = test_bit(BR_FDB_LOCAL, &fdb->flags),
117118
.offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags),
118119
};
119120

120121
if (!fdb->dst)
121122
return;
122-
if (test_bit(BR_FDB_LOCAL, &fdb->flags))
123-
return;
124123

125124
switch (type) {
126125
case RTM_DELNEIGH:

‎net/dsa/slave.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused,
23292329
fdb_info = ptr;
23302330

23312331
if (dsa_slave_dev_check(dev)) {
2332-
if (!fdb_info->added_by_user)
2332+
if (!fdb_info->added_by_user || fdb_info->is_local)
23332333
return NOTIFY_OK;
23342334

23352335
dp = dsa_slave_to_port(dev);

0 commit comments

Comments
 (0)