Skip to contentSkip to conversation

net: dsa: hellcreek: Calculate checksums in tagger

PATCH Applied Kurt Kanzenbach 3 participants 3 messages Apr 15, 2022 – Apr 19, 2022

Subsystems (4)
lore
Share & tools
lore

Kurt Kanzenbach

author maintainer
#0 lore raw

PATCH 1/1 net: dsa: hellcreek: Calculate checksums in tagger

In case the checksum calculation is offloaded to the DSA master network interface, it will include the switch trailing tag. As soon as the switch strips that tag on egress, the calculated checksum is wrong.

Therefore, add the checksum calculation to the tagger (if required) before adding the switch tag. This way, the hellcreek code works with all DSA master interfaces regardless of their declared feature set.

Fixes 01ef09caad66 ("net: dsa: Add tag handling for Hirschmann Hellcreek switches")
---
 net/dsa/tag_hellcreek.c | 8 ++++++++
 1 file changed, 8 insertions(+)
net/dsa/tag_hellcreek.c +8 -0
index f64b805303cd..eb204ad36eee 100644
@@ -21,6 +21,14 @@ static struct sk_buff *hellcreek_xmit(struct sk_buff *skb,
 	struct dsa_port *dp = dsa_slave_to_port(dev);
 	u8 *tag;
 
+	/* Calculate checksums (if required) before adding the trailer tag to
+	 * avoid including it in calculations. That would lead to wrong
+	 * checksums after the switch strips the tag.
+	 */
+	if (skb->ip_summed == CHECKSUM_PARTIAL &&
+	    skb_checksum_help(skb))
+		return NULL;
+
 	/* Tag encoding */
 	tag  = skb_put(skb, HELLCREEK_TAG_LEN);
 	*tag = BIT(dp->index);
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Kurt Kanzenbach

In case the checksum calculation is offloaded to the DSA master network interface, it will include the switch trailing tag. As soon as the switch strips that tag on egress, the calculated checksum is wrong.

Therefore, add the checksum calculation to the tagger (if required) before adding the switch tag. This way, the hellcreek code works with all DSA master interfaces regardless of their declared feature set.

Fixes 01ef09caad66 ("net: dsa: Add tag handling for Hirschmann Hellcreek switches")
Signature · 1 line
Florian
#2 lore raw
In reply to Kurt Kanzenbach
This patch was applied to netdev/net.git (master) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Fri, 15 Apr 2022 12:33:20 +0200 you wrote:

In case the checksum calculation is offloaded to the DSA master network interface, it will include the switch trailing tag. As soon as the switch strips that tag on egress, the calculated checksum is wrong.

Therefore, add the checksum calculation to the tagger (if required) before adding the switch tag. This way, the hellcreek code works with all DSA master interfaces regardless of their declared feature set.

[...]

Here is the summary with links:
- [net] net: dsa: hellcreek: Calculate checksums in tagger

    https://git.kernel.org/netdev/net/c/0763120b0904

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html