Commit 2c4eca3e authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller
Browse files

net: bridge: switchdev: include local flag in FDB notifications

As explained in bugfix commit 6ab4c311 ("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: default avatarTobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: default avatarTobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e5b4b898
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2098,7 +2098,7 @@ static void dpaa2_switch_event_work(struct work_struct *work)

	switch (switchdev_work->event) {
	case SWITCHDEV_FDB_ADD_TO_DEVICE:
		if (!fdb_info->added_by_user)
		if (!fdb_info->added_by_user || fdb_info->is_local)
			break;
		if (is_unicast_ether_addr(fdb_info->addr))
			err = dpaa2_switch_port_fdb_add_uc(netdev_priv(dev),
@@ -2113,7 +2113,7 @@ static void dpaa2_switch_event_work(struct work_struct *work)
					 &fdb_info->info, NULL);
		break;
	case SWITCHDEV_FDB_DEL_TO_DEVICE:
		if (!fdb_info->added_by_user)
		if (!fdb_info->added_by_user || fdb_info->is_local)
			break;
		if (is_unicast_ether_addr(fdb_info->addr))
			dpaa2_switch_port_fdb_del_uc(netdev_priv(dev), fdb_info->addr);
+1 −1
Original line number Diff line number Diff line
@@ -798,7 +798,7 @@ static void prestera_fdb_event_work(struct work_struct *work)
	switch (swdev_work->event) {
	case SWITCHDEV_FDB_ADD_TO_DEVICE:
		fdb_info = &swdev_work->fdb_info;
		if (!fdb_info->added_by_user)
		if (!fdb_info->added_by_user || fdb_info->is_local)
			break;

		err = prestera_port_fdb_set(port, fdb_info, true);
+3 −2
Original line number Diff line number Diff line
@@ -2916,7 +2916,8 @@ mlxsw_sp_switchdev_bridge_nve_fdb_event(struct mlxsw_sp_switchdev_event_work *
		return;

	if (switchdev_work->event == SWITCHDEV_FDB_ADD_TO_DEVICE &&
	    !switchdev_work->fdb_info.added_by_user)
	    (!switchdev_work->fdb_info.added_by_user ||
	     switchdev_work->fdb_info.is_local))
		return;

	if (!netif_running(dev))
@@ -2971,7 +2972,7 @@ static void mlxsw_sp_switchdev_bridge_fdb_event_work(struct work_struct *work)
	switch (switchdev_work->event) {
	case SWITCHDEV_FDB_ADD_TO_DEVICE:
		fdb_info = &switchdev_work->fdb_info;
		if (!fdb_info->added_by_user)
		if (!fdb_info->added_by_user || fdb_info->is_local)
			break;
		err = mlxsw_sp_port_fdb_set(mlxsw_sp_port, fdb_info, true);
		if (err)
+2 −2
Original line number Diff line number Diff line
@@ -2736,7 +2736,7 @@ static void rocker_switchdev_event_work(struct work_struct *work)
	switch (switchdev_work->event) {
	case SWITCHDEV_FDB_ADD_TO_DEVICE:
		fdb_info = &switchdev_work->fdb_info;
		if (!fdb_info->added_by_user)
		if (!fdb_info->added_by_user || fdb_info->is_local)
			break;
		err = rocker_world_port_fdb_add(rocker_port, fdb_info);
		if (err) {
@@ -2747,7 +2747,7 @@ static void rocker_switchdev_event_work(struct work_struct *work)
		break;
	case SWITCHDEV_FDB_DEL_TO_DEVICE:
		fdb_info = &switchdev_work->fdb_info;
		if (!fdb_info->added_by_user)
		if (!fdb_info->added_by_user || fdb_info->is_local)
			break;
		err = rocker_world_port_fdb_del(rocker_port, fdb_info);
		if (err)
+2 −2
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ static void am65_cpsw_switchdev_event_work(struct work_struct *work)
			   fdb->addr, fdb->vid, fdb->added_by_user,
			   fdb->offloaded, port_id);

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

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