[WCNCR00150960] misc: wrong VLAN ID shown in tcpdump
[Description]
Fix wrong VLAN ID shown in tcpdump
This is a side-effect caused by commit 4ac8b8d73344 ("[WCNCR00150251]
misc: cannot get DHCP ip over VLAN"). There is a 2-bytes hole between
'skb->mac_header + ETH_HLEN' and 'skb->data'. Applications may detect
wrong MAC address if this kind of packets passed up.
To avoid this problem, we have to adjust the memory sequence of ETH-header
properly. Shift whole ETH_HDR(14 bytes) 2 bytes.
Feature: misc
Change-Id: I7db38d26cb9e4b8ea48e5d402c242d85ec01fa5b
CR-Id: WCNCR00150960
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
diff --git a/os/linux/gl_kal.c b/os/linux/gl_kal.c
index a629bac..b5c945e 100644
--- a/os/linux/gl_kal.c
+++ b/os/linux/gl_kal.c
@@ -946,8 +946,14 @@
*/
const UINT_8 vlan_skb_mem_move = 2;
+ /* Remove "Len" and shift data pointer 2 bytes */
kalMemCopy(prSkb->data+vlan_skb_mem_move, prSkb->data, vlan_skb_mem_move);
skb_pull_rcsum(prSkb, vlan_skb_mem_move);
+
+ /* Have to update MAC header properly. Otherwise, wrong MACs woud be passed up */
+ kalMemMove(prSkb->data - ETH_HLEN, prSkb->data - ETH_HLEN - vlan_skb_mem_move, ETH_HLEN);
+ prSkb->mac_header += vlan_skb_mem_move;
+
skb_reset_network_header(prSkb);
skb_reset_transport_header(prSkb);
skb_reset_mac_len(prSkb);
diff --git a/os/linux/include/gl_kal.h b/os/linux/include/gl_kal.h
index 09adf2e..125af23 100644
--- a/os/linux/include/gl_kal.h
+++ b/os/linux/include/gl_kal.h
@@ -579,6 +579,9 @@
/* Zero specific memory block */
#define kalMemZero(pvAddr, u4Size) memset(pvAddr, 0, u4Size)
+/* Move memory block with specific size */
+#define kalMemMove(pvDst, pvSrc, u4Size) memmove(pvDst, pvSrc, u4Size)
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
#define strnicmp(s1, s2, n) strncasecmp(s1, s2, n)
#endif