[][openwrt][mt7988][crypto][Refactor tport setting for packets to EIP197]
[Description]
Refactor tport setting for packets to EIP197.
In previous version, we use skb_hnat_cdrt and magic tag to determine
whether a packet should be send to EIP197. However, for packets that
performed segement in GSO, headroom data is not consistent with the
original packet. To ensure that only inline mode packets be sent to
EIP197. We use skb->inner_protocol for determination in this patch.
XFRM callback function for inline mode will set the skb->inner_protocol.
[Release-log]
N/A
Change-Id: I6ef1d7f2044ead78d8a756bc012226573758069d
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8494301
diff --git a/package-21.02/kernel/crypto-eip/src/xfrm-offload.c b/package-21.02/kernel/crypto-eip/src/xfrm-offload.c
index ba89eda..99bbfee 100644
--- a/package-21.02/kernel/crypto-eip/src/xfrm-offload.c
+++ b/package-21.02/kernel/crypto-eip/src/xfrm-offload.c
@@ -351,6 +351,14 @@
skb->dev = dst->dev;
/* Set magic tag for tport setting, reset to 0 after tport is set */
skb_hnat_magic_tag(skb) = HNAT_MAGIC_TAG;
+
+ /*
+ * Since skb headroom may not be copy when segment, we cannot rely on
+ * headroom data (ex. cdrt) to decide packets should send to EIP197.
+ * Here is a workaround that only skb with inner_protocol = ESP will
+ * be sent to EIP197.
+ */
+ skb->inner_protocol = IPPROTO_ESP;
/*
* Tx packet to EIP197.
* To avoid conflict of SW and HW sequence number