diff mbox series

[net] net: dsa: hellcreek: Calculate checksums in tagger

Message ID 20220415103320.90657-1-kurt@linutronix.de (mailing list archive)
State Accepted
Commit 0763120b090418a5257402754e22a34227ae5f12
Delegated to: Netdev Maintainers
Headers show
Series [net] net: dsa: hellcreek: Calculate checksums in tagger | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Kurt Kanzenbach April 15, 2022, 10:33 a.m. UTC
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")
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 net/dsa/tag_hellcreek.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Florian Fainelli April 16, 2022, 7:40 p.m. UTC | #1
On 4/15/2022 3:33 AM, Kurt Kanzenbach 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.
> 
> Fixes: 01ef09caad66 ("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>
patchwork-bot+netdevbpf@kernel.org April 19, 2022, 8:10 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:

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!
diff mbox series

Patch

diff --git a/net/dsa/tag_hellcreek.c b/net/dsa/tag_hellcreek.c
index f64b805303cd..eb204ad36eee 100644
--- a/net/dsa/tag_hellcreek.c
+++ b/net/dsa/tag_hellcreek.c
@@ -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);