74cb562a51017c97fb7a56a90f9490803858d2b7
[openwrt/staging/stintel.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 20 Mar 2023 15:37:55 +0100
3 Subject: [PATCH] net: ethernet: mediatek: mtk_ppe: prefer newly added l2
4 flows over existing ones
5
6 When a device is roaming between interfaces and a new flow entry is created,
7 we should assume that its output device is more up to date than whatever
8 entry existed already.
9
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 ---
12
13 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
14 +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
15 @@ -657,10 +657,20 @@ void mtk_foe_entry_clear(struct mtk_ppe
16 static int
17 mtk_foe_entry_commit_l2(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)
18 {
19 + struct mtk_flow_entry *prev;
20 +
21 entry->type = MTK_FLOW_TYPE_L2;
22
23 - return rhashtable_insert_fast(&ppe->l2_flows, &entry->l2_node,
24 - mtk_flow_l2_ht_params);
25 + prev = rhashtable_lookup_get_insert_fast(&ppe->l2_flows, &entry->l2_node,
26 + mtk_flow_l2_ht_params);
27 + if (likely(!prev))
28 + return 0;
29 +
30 + if (IS_ERR(prev))
31 + return PTR_ERR(prev);
32 +
33 + return rhashtable_replace_fast(&ppe->l2_flows, &prev->l2_node,
34 + &entry->l2_node, mtk_flow_l2_ht_params);
35 }
36
37 int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)