net: dsa: install the host MDB and FDB entries in the master's RX filter

If the DSA master implements strict address filtering, then the unicast
and multicast addresses kept by the DSA CPU ports should be synchronized
with the address lists of the DSA master.

Note that we want the synchronization of the master's address lists even
if the DSA switch doesn't support unicast/multicast database operations,
on the premises that the packets will be flooded to the CPU in that
case, and we should still instruct the master to receive them. This is
why we do the dev_uc_add() etc first, even if dsa_port_notify() returns
-EOPNOTSUPP. In turn, dev_uc_add() and friends return error only if
memory allocation fails, so it is probably ok to check and propagate
that error code and not just ignore it.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Vladimir Oltean 2021-06-29 17:06:53 +03:00 committed by David S. Miller
parent 3f6e32f92a
commit 26ee7b06a4
1 changed files with 24 additions and 0 deletions

View File

@ -655,6 +655,12 @@ int dsa_port_host_fdb_add(struct dsa_port *dp, const unsigned char *addr,
.addr = addr,
.vid = vid,
};
struct dsa_port *cpu_dp = dp->cpu_dp;
int err;
err = dev_uc_add(cpu_dp->master, addr);
if (err)
return err;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_ADD, &info);
}
@ -668,6 +674,12 @@ int dsa_port_host_fdb_del(struct dsa_port *dp, const unsigned char *addr,
.addr = addr,
.vid = vid,
};
struct dsa_port *cpu_dp = dp->cpu_dp;
int err;
err = dev_uc_del(cpu_dp->master, addr);
if (err)
return err;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_DEL, &info);
}
@ -715,6 +727,12 @@ int dsa_port_host_mdb_add(const struct dsa_port *dp,
.port = dp->index,
.mdb = mdb,
};
struct dsa_port *cpu_dp = dp->cpu_dp;
int err;
err = dev_mc_add(cpu_dp->master, mdb->addr);
if (err)
return err;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_ADD, &info);
}
@ -727,6 +745,12 @@ int dsa_port_host_mdb_del(const struct dsa_port *dp,
.port = dp->index,
.mdb = mdb,
};
struct dsa_port *cpu_dp = dp->cpu_dp;
int err;
err = dev_mc_del(cpu_dp->master, mdb->addr);
if (err)
return err;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_DEL, &info);
}