[][openwrt][mt7988][crypto][Refactor FP setting in IPSec hnat binding flow]
[Description]
Refactor FP setting in IPSec hnat binding flow.
In the previous version, FP was determined based on the destination
device during binding. For instance, if the destination device is a WAN,
then FP is directly set to the GMAC2 port.
However, in mt7988d configuration, there may be a swapping of LAN port
and WAN port. This means that WAN can either be GMAC2 or GMAC3.
Therefore, we now rely on the interface id to determine which FP should
be set.
[Release-log]
N/A
Change-Id: I2bda377a9c668b02f29a9fcd3425b4e65d22a26a
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8383420
diff --git a/target/linux/mediatek/patches-5.4/999-4102-mtk-crypto-offload-support.patch b/target/linux/mediatek/patches-5.4/999-4102-mtk-crypto-offload-support.patch
index 09650e1..455ff04 100644
--- a/target/linux/mediatek/patches-5.4/999-4102-mtk-crypto-offload-support.patch
+++ b/target/linux/mediatek/patches-5.4/999-4102-mtk-crypto-offload-support.patch
@@ -41,7 +41,7 @@
skb_hnat_set_is_decap(skb, 0);
--- a/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
+++ b/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
-@@ -1077,6 +1077,9 @@ static unsigned int hnat_ipv4_get_nextho
+@@ -1078,6 +1078,9 @@ static unsigned int hnat_ipv4_get_nextho
return 0;
}
@@ -51,7 +51,7 @@
rcu_read_lock_bh();
nexthop = (__force u32)rt_nexthop(rt, ip_hdr(skb)->daddr);
neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
-@@ -1301,6 +1304,9 @@ static inline void hnat_fill_offload_eng
+@@ -1302,6 +1305,9 @@ static inline void hnat_fill_offload_eng
*/
entry->ipv4_hnapt.tport_id = NR_TDMA_QDMA_TPORT;
entry->ipv4_hnapt.tops_entry = skb_hnat_tops(skb);
@@ -61,7 +61,7 @@
} else {
return;
}
-@@ -1310,6 +1316,75 @@ static inline void hnat_fill_offload_eng
+@@ -1311,6 +1317,79 @@ static inline void hnat_fill_offload_eng
#endif /* defined(CONFIG_MEDIATEK_NETSYS_V3) */
}
@@ -70,6 +70,7 @@
+ struct foe_entry entry = { 0 };
+ struct ethhdr *eth = eth_hdr(skb);
+ u32 gmac = NR_DISCARD;
++ struct mtk_mac *mac = netdev_priv(dev);
+
+ if (skb_hnat_tops(skb) && mtk_tnl_encap_offload)
+ mtk_tnl_encap_offload(skb);
@@ -93,9 +94,12 @@
+ else
+ gmac = NR_GMAC1_PORT;
+ } else if (IS_LAN2(dev)) {
-+ gmac = NR_GMAC2_PORT;
++ gmac = (mac->id == MTK_GMAC2_ID) ? NR_GMAC2_PORT : NR_GMAC3_PORT;
+ } else if (IS_WAN(dev)) {
-+ gmac = (IS_GMAC1_MODE) ? NR_GMAC1_PORT : NR_GMAC2_PORT;
++ if (IS_GMAC1_MODE)
++ gmac = NR_GMAC1_PORT;
++ else
++ gmac = (mac->id == MTK_GMAC2_ID) ? NR_GMAC2_PORT : NR_GMAC3_PORT;
+ } else {
+ pr_notice("Unknown case of dp, iif=%x --> %s\n", skb_hnat_iface(skb), dev->name);
+ return -1;
@@ -137,7 +141,7 @@
static unsigned int skb_to_hnat_info(struct sk_buff *skb,
const struct net_device *dev,
struct foe_entry *foe,
-@@ -2359,6 +2434,7 @@ int mtk_sw_nat_hook_rx(struct sk_buff *s
+@@ -2360,6 +2439,7 @@ int mtk_sw_nat_hook_rx(struct sk_buff *s
skb_hnat_alg(skb) = 0;
skb_hnat_set_tops(skb, 0);
@@ -145,7 +149,7 @@
skb_hnat_magic_tag(skb) = HNAT_MAGIC_TAG;
if (skb_hnat_iface(skb) == FOE_MAGIC_WED0)
-@@ -2445,7 +2521,8 @@ static unsigned int mtk_hnat_accel_type(
+@@ -2446,7 +2526,8 @@ static unsigned int mtk_hnat_accel_type(
* is from local_out which is also filtered in sanity check.
*/
dst = skb_dst(skb);
@@ -155,7 +159,7 @@
return 0;
ct = nf_ct_get(skb, &ctinfo);
-@@ -2849,6 +2926,14 @@ static unsigned int mtk_hnat_nf_post_rou
+@@ -2850,6 +2931,14 @@ static unsigned int mtk_hnat_nf_post_rou
}
}
@@ -170,7 +174,7 @@
if (!IS_LAN_GRP(out) && !IS_WAN(out) && !IS_EXT(out))
is_virt_dev = true;
-@@ -3158,7 +3243,10 @@ mtk_hnat_ipv4_nf_local_out(void *priv, s
+@@ -3159,7 +3248,10 @@ mtk_hnat_ipv4_nf_local_out(void *priv, s
if (iph->protocol == IPPROTO_IPV6) {
entry->udib1.pkt_type = IPV6_6RD;
hnat_set_head_frags(state, skb, 0, hnat_set_alg);