[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210714191723.31294-3-LinoSanfilippo@gmx.de>
Date: Wed, 14 Jul 2021 21:17:23 +0200
From: Lino Sanfilippo <LinoSanfilippo@....de>
To: woojung.huh@...rochip.com
Cc: UNGLinuxDriver@...rochip.com, andrew@...n.ch,
vivien.didelot@...il.com, f.fainelli@...il.com, olteanv@...il.com,
davem@...emloft.net, kuba@...nel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Lino Sanfilippo <LinoSanfilippo@....de>
Subject: [PATCH 2/2] net: dsa: tag_ksz: dont let the hardware process the layer 4 checksum
If the checksum calculation is offloaded to the network device (e.g due to
NETIF_F_HW_CSUM inherited from the DSA master device), the calculated
layer 4 checksum is incorrect. This is since the DSA tag which is placed
after the layer 4 data is seen as a part of the data portion and thus
errorneously included into the checksum calculation.
To avoid this, always calculate the layer 4 checksum in software.
Signed-off-by: Lino Sanfilippo <LinoSanfilippo@....de>
---
net/dsa/tag_ksz.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index 364f509d7cd7..d59f0e7019e2 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -56,6 +56,9 @@ static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev)
if (skb_linearize(skb))
return NULL;
+ if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
+ return NULL;
+
/* Tag encoding */
tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
addr = skb_mac_header(skb);
@@ -120,6 +123,9 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
if (skb_linearize(skb))
return NULL;
+ if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
+ return NULL;
+
/* Tag encoding */
tag = skb_put(skb, KSZ9477_INGRESS_TAG_LEN);
addr = skb_mac_header(skb);
@@ -173,6 +179,9 @@ static struct sk_buff *ksz9893_xmit(struct sk_buff *skb,
if (skb_linearize(skb))
return NULL;
+ if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
+ return NULL;
+
/* Tag encoding */
tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
addr = skb_mac_header(skb);
--
2.32.0
Powered by blists - more mailing lists