Skip to content

Commit

Permalink
net: mscc: ocelot: fix forwarding from BLOCKING ports remaining enabled
Browse files Browse the repository at this point in the history
The blamed commit made the fatally incorrect assumption that ports which
aren't in the FORWARDING STP state should not have packets forwarded
towards them, and that is all that needs to be done.

However, that logic alone permits BLOCKING ports to forward to
FORWARDING ports, which of course allows packet storms to occur when
there is an L2 loop.

The ocelot_get_bridge_fwd_mask should not only ask "what can the bridge
do for you", but "what can you do for the bridge". This way, only
FORWARDING ports forward to the other FORWARDING ports from the same
bridging domain, and we are still compatible with the idea of multiple
bridges.

Fixes: df291e5 ("net: ocelot: support multiple bridges")
Suggested-by: Colin Foster <[email protected]>
Reported-by: Colin Foster <[email protected]>
Signed-off-by: Vladimir Oltean <[email protected]>
Signed-off-by: Colin Foster <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
vladimiroltean authored and davem330 committed Sep 23, 2021
1 parent e68daf6 commit acc64f5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/net/ethernet/mscc/ocelot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,14 +1293,19 @@ static u32 ocelot_get_bond_mask(struct ocelot *ocelot, struct net_device *bond,
return mask;
}

static u32 ocelot_get_bridge_fwd_mask(struct ocelot *ocelot,
static u32 ocelot_get_bridge_fwd_mask(struct ocelot *ocelot, int src_port,
struct net_device *bridge)
{
struct ocelot_port *ocelot_port = ocelot->ports[src_port];
u32 mask = 0;
int port;

if (!ocelot_port || ocelot_port->bridge != bridge ||
ocelot_port->stp_state != BR_STATE_FORWARDING)
return 0;

for (port = 0; port < ocelot->num_phys_ports; port++) {
struct ocelot_port *ocelot_port = ocelot->ports[port];
ocelot_port = ocelot->ports[port];

if (!ocelot_port)
continue;
Expand Down Expand Up @@ -1366,7 +1371,7 @@ void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot)
struct net_device *bridge = ocelot_port->bridge;
struct net_device *bond = ocelot_port->bond;

mask = ocelot_get_bridge_fwd_mask(ocelot, bridge);
mask = ocelot_get_bridge_fwd_mask(ocelot, port, bridge);
mask |= cpu_fwd_mask;
mask &= ~BIT(port);
if (bond) {
Expand Down

0 comments on commit acc64f5

Please sign in to comment.