[][Fix HNAT issue that entry be deleted unexpectedly]
[Description]
Fix HNAT issue that entry be deleted unexpectedly.
The change has nothing to do with the chipset.
The previous code did not consider the type of entry, which would cause the entry(e.g. dslite) to be deleted incorrectly.
This patch is to correct dscp update.
[Release-log]
N/A
Change-Id: Ibbca8b4f1b55f4f8bf9f0c4b22ece8a151b250dd
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/5363618
diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
index da97b89..4c24043 100644
--- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
+++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
@@ -1854,14 +1854,14 @@
switch (ntohs(eth->h_proto)) {
case ETH_P_IP:
iph = ip_hdr(skb);
- if (entry->ipv4_hnapt.iblk2.dscp != iph->tos)
+ if (IS_IPV4_GRP(entry) && entry->ipv4_hnapt.iblk2.dscp != iph->tos)
flag = true;
break;
case ETH_P_IPV6:
ip6h = ipv6_hdr(skb);
- if (entry->ipv6_5t_route.iblk2.dscp !=
- (ip6h->priority << 4 |
- (ip6h->flow_lbl[0] >> 4)))
+ if ((IS_IPV6_3T_ROUTE(entry) || IS_IPV6_5T_ROUTE(entry)) &&
+ (entry->ipv6_5t_route.iblk2.dscp !=
+ (ip6h->priority << 4 | (ip6h->flow_lbl[0] >> 4))))
flag = true;
break;
default:
@@ -1869,6 +1869,7 @@
}
if (flag) {
+ pr_info("Delete entry idx=%d.\n", skb_hnat_entry(skb));
memset(entry, 0, sizeof(struct foe_entry));
hnat_cache_ebl(1);
}