From fe05ec60207898afeb09fcd2714985d4d3c17848 Mon Sep 17 00:00:00 2001 From: developer Date: Sat, 18 Mar 2023 22:11:13 +0800 Subject: [PATCH] [Description] Fix hook drop normal packet In some cases, the packet match the to the logic of eth->wlan of the legacy chip(mt7621). After failing to find the interface, it will be discarded by the hnat function. Here packets should be handed over to the kernel [Release-log] N/A Change-Id: Idca4c6e899e743c89fbcb562f2695a77b02a98af Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7265953 --- .../net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 7ca3347f09..72e36f96d6 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 @@ -488,7 +488,14 @@ unsigned int do_hnat_ge_to_ext(struct sk_buff *skb, const char *func) else index = entry->ipv6_5t_route.act_dp; - skb->dev = get_dev_from_index(index); + dev = get_dev_from_index(index); + if (!dev) { + trace_printk("%s: called from %s. Get wifi interface fail\n", + __func__, func); + return 0; + } + + skb->dev = dev; if (IS_HQOS_MODE && eth_hdr(skb)->h_proto == HQOS_MAGIC_TAG) { skb = skb_unshare(skb, GFP_ATOMIC);