Skip to content

Commit 37120f2

Browse files
LinoSanfilippo333davem330
authored andcommitted
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 considered as being part of the daa and thus errorneously included into the checksum calculation. To avoid this, always calculate the layer 4 checksum in software. Signed-off-by: Lino Sanfilippo <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 21cf377 commit 37120f2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

net/dsa/tag_ksz.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev)
5353
u8 *tag;
5454
u8 *addr;
5555

56+
if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
57+
return NULL;
58+
5659
/* Tag encoding */
5760
tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
5861
addr = skb_mac_header(skb);
@@ -114,6 +117,9 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
114117
u8 *addr;
115118
u16 val;
116119

120+
if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
121+
return NULL;
122+
117123
/* Tag encoding */
118124
tag = skb_put(skb, KSZ9477_INGRESS_TAG_LEN);
119125
addr = skb_mac_header(skb);
@@ -164,6 +170,9 @@ static struct sk_buff *ksz9893_xmit(struct sk_buff *skb,
164170
u8 *addr;
165171
u8 *tag;
166172

173+
if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
174+
return NULL;
175+
167176
/* Tag encoding */
168177
tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
169178
addr = skb_mac_header(skb);

0 commit comments

Comments
 (0)