Skip to content

Commit 80248d4

Browse files
Ansueldavem330
authored andcommitted
net: dsa: qca8k: fix search_and_insert wrong handling of new rule
On inserting a mdb entry, fdb_search_and_insert is used to add a port to the qca8k target entry in the FDB db. A FDB entry can't be modified so it needs to be removed and insert again with the new values. To detect if an entry already exist, the SEARCH operation is used and we check the aging of the entry. If the entry is not 0, the entry exist and we proceed to delete it. Current code have 2 main problem: - The condition to check if the FDB entry exist is wrong and should be the opposite. - When a FDB entry doesn't exist, aging was never actually set to the STATIC value resulting in allocating an invalid entry. Fix both problem by adding aging support to the function, calling the function with STATIC as aging by default and finally by correct the condition to check if the entry actually exist. Fixes: ba8f870 ("net: dsa: qca8k: add support for mdb_add/del") Signed-off-by: Christian Marangi <[email protected]> Cc: [email protected] Signed-off-by: David S. Miller <[email protected]>
1 parent 2c39dd0 commit 80248d4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/net/dsa/qca/qca8k-common.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void qca8k_fdb_flush(struct qca8k_priv *priv)
244244
}
245245

246246
static int qca8k_fdb_search_and_insert(struct qca8k_priv *priv, u8 port_mask,
247-
const u8 *mac, u16 vid)
247+
const u8 *mac, u16 vid, u8 aging)
248248
{
249249
struct qca8k_fdb fdb = { 0 };
250250
int ret;
@@ -261,10 +261,12 @@ static int qca8k_fdb_search_and_insert(struct qca8k_priv *priv, u8 port_mask,
261261
goto exit;
262262

263263
/* Rule exist. Delete first */
264-
if (!fdb.aging) {
264+
if (fdb.aging) {
265265
ret = qca8k_fdb_access(priv, QCA8K_FDB_PURGE, -1);
266266
if (ret)
267267
goto exit;
268+
} else {
269+
fdb.aging = aging;
268270
}
269271

270272
/* Add port to fdb portmask */
@@ -810,7 +812,8 @@ int qca8k_port_mdb_add(struct dsa_switch *ds, int port,
810812
const u8 *addr = mdb->addr;
811813
u16 vid = mdb->vid;
812814

813-
return qca8k_fdb_search_and_insert(priv, BIT(port), addr, vid);
815+
return qca8k_fdb_search_and_insert(priv, BIT(port), addr, vid,
816+
QCA8K_ATU_STATUS_STATIC);
814817
}
815818

816819
int qca8k_port_mdb_del(struct dsa_switch *ds, int port,

0 commit comments

Comments
 (0)