[][MAC80211][hnat][Fix IPv6 unbind issue for the routing mode]

[Description]
Fix IPv6 unbind issue for the routing mode.

In the previous commit [0], we fixed an issue where flow offload
could not be bound without ARP in bridge mode. But this commit
caused the IPv6 cannot bind in routing mode.

Therefore, we refactor the previous commit to resolve this issue.

[0] https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/
mtk-openwrt-feeds/+/9fdc0e8bc2ee766cac5c603c464d1d9325bab34f

Without this patch, the IPv6 flow cannot bind in the routing mode.

[Release-log]
N/A


Change-Id: Ifb14eee4fa812cbb50d85b421876f9a2ce0a9259
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8392937
diff --git a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/999-3001-mt7622-backport-nf-hw-offload-framework-and-upstream.patch b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/999-3001-mt7622-backport-nf-hw-offload-framework-and-upstream.patch
index 528abb1..2dc17ae 100644
--- a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/999-3001-mt7622-backport-nf-hw-offload-framework-and-upstream.patch
+++ b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/999-3001-mt7622-backport-nf-hw-offload-framework-and-upstream.patch
@@ -6136,7 +6136,7 @@
 index 0000000..2cab008
 --- /dev/null
 +++ b/net/netfilter/xt_FLOWOFFLOAD.c
-@@ -0,0 +1,794 @@
+@@ -0,0 +1,799 @@
 +/*
 + * Copyright (C) 2018-2021 Felix Fietkau <nbd@nbd.name>
 + *
@@ -6494,7 +6494,8 @@
 +				     const struct dst_entry *dst_cache,
 +				     const struct nf_conn *ct,
 +				     enum ip_conntrack_dir dir, u8 *ha,
-+				     struct net_device_path_stack *stack)
++				     struct net_device_path_stack *stack,
++				     bool is_bridge)
 +{
 +	const void *daddr = &ct->tuplehash[!dir].tuple.src.u3;
 +	struct net_device *dev = dst_cache->dev;
@@ -6504,7 +6505,7 @@
 +	if (!nf_is_valid_ether_device(dev))
 +		goto out;
 +
-+	if (ct->status & IPS_NAT_MASK) {
++	if (!is_bridge) {
 +		n = dst_neigh_lookup(dst_cache, daddr);
 +		if (!n)
 +			return -1;
@@ -6535,9 +6536,13 @@
 +	struct net_device_path_stack stack;
 +	struct nf_forward_info info = {};
 +	unsigned char ha[ETH_ALEN];
++	bool is_bridge = false;
 +	int i;
 +
-+	if (!(ct->status & IPS_NAT_MASK) && skb_mac_header_was_set(skb)) {
++	if (devs[dir] == devs[!dir])
++		is_bridge = true;
++
++	if (is_bridge && skb_mac_header_was_set(skb)) {
 +		eth = eth_hdr(skb);
 +		skb_dir = CTINFO2DIR(skb_get_nfct(skb) & NFCT_INFOMASK);
 +
@@ -6550,7 +6555,7 @@
 +		}
 +	}
 +
-+	if (nf_dev_fill_forward_path(route, dst, ct, dir, ha, &stack) >= 0)
++	if (nf_dev_fill_forward_path(route, dst, ct, dir, ha, &stack, is_bridge) >= 0)
 +		nf_dev_path_info(&stack, &info, ha);
 +
 +	devs[!dir] = (struct net_device *)info.indev;