mirror of
https://github.com/padavanonly/immortalwrt-mt798x.git
synced 2025-12-16 08:44:03 +00:00
mtk hnat:add spin lock to prevent multicore racing
This commit is contained in:
parent
73cdea2db0
commit
96d6459965
@ -386,6 +386,8 @@ static int hnat_hw_init(u32 ppe_id)
|
||||
hnat_priv->g_wandev = dev_get_by_name(&init_net, hnat_priv->wan);
|
||||
|
||||
dev_info(hnat_priv->dev, "PPE%d hwnat start\n", ppe_id);
|
||||
|
||||
spin_lock_init(&hnat_priv->entry_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -697,6 +697,7 @@ struct mtk_hnat {
|
||||
bool guest_en;
|
||||
bool dscp_en;
|
||||
bool macvlan_support;
|
||||
spinlock_t entry_lock;
|
||||
};
|
||||
|
||||
struct extdev_entry {
|
||||
|
||||
@ -1897,11 +1897,17 @@ int mtk_sw_nat_hook_tx(struct sk_buff *skb, int gmac_no)
|
||||
return NF_ACCEPT;
|
||||
|
||||
entry = &hnat_priv->foe_table_cpu[skb_hnat_ppe(skb)][skb_hnat_entry(skb)];
|
||||
spin_lock(&hnat_priv->entry_lock);
|
||||
|
||||
if (entry_hnat_is_bound(entry))
|
||||
{spin_unlock(&hnat_priv->entry_lock);
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
|
||||
if (skb_hnat_reason(skb) != HIT_UNBIND_RATE_REACH)
|
||||
{spin_unlock(&hnat_priv->entry_lock);
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
|
||||
eth = eth_hdr(skb);
|
||||
memcpy(&bfib1_tx, &entry->bfib1, sizeof(entry->bfib1));
|
||||
@ -1909,7 +1915,9 @@ int mtk_sw_nat_hook_tx(struct sk_buff *skb, int gmac_no)
|
||||
/*not bind multicast if PPE mcast not enable*/
|
||||
if (!hnat_priv->data->mcast) {
|
||||
if (is_multicast_ether_addr(eth->h_dest))
|
||||
{spin_unlock(&hnat_priv->entry_lock);
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
|
||||
if (IS_IPV4_GRP(entry))
|
||||
entry->ipv4_hnapt.iblk2.mcast = 0;
|
||||
@ -2034,7 +2042,7 @@ int mtk_sw_nat_hook_tx(struct sk_buff *skb, int gmac_no)
|
||||
bfib1_tx.state = BIND;
|
||||
wmb();
|
||||
memcpy(&entry->bfib1, &bfib1_tx, sizeof(bfib1_tx));
|
||||
|
||||
spin_unlock(&hnat_priv->entry_lock);
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
|
||||
@ -2242,8 +2250,9 @@ static unsigned int mtk_hnat_nf_post_routing(
|
||||
|
||||
if (fn && fn(skb, arp_dev, &hw_path))
|
||||
break;
|
||||
|
||||
spin_lock(&hnat_priv->entry_lock);
|
||||
skb_to_hnat_info(skb, out, entry, &hw_path);
|
||||
spin_unlock(&hnat_priv->entry_lock);
|
||||
break;
|
||||
case HIT_BIND_KEEPALIVE_DUP_OLD_HDR:
|
||||
if (fn && !mtk_hnat_accel_type(skb))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user