Skip to content

Commit

Permalink
net: dsa: hellcreek: Calculate checksums in tagger
Browse files Browse the repository at this point in the history
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: 01ef09c ("net: dsa: Add tag handling for Hirschmann Hellcreek switches")
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20220415103320.90657-1-kurt@linutronix.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Kurt Kanzenbach authored and Paolo Abeni committed Apr 19, 2022
1 parent cbe6c3a commit 0763120
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions net/dsa/tag_hellcreek.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0763120

Please sign in to comment.