Skip to contentSkip to conversation

net: netpoll: Initialize UDP checksum field before checksumming

PATCH Applied Breno Leitao 4 participants 5 messages Jun 20, 2025 – Jun 26, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: netpoll: Initialize UDP checksum field before checksumming

commit f1fce08e63fe ("netpoll: Eliminate redundant assignment") removed the initialization of the UDP checksum, which was wrong and broke netpoll IPv6 transmission due to bad checksumming.

udph->check needs to be set before calling csum_ipv6_magic().

Fixes f1fce08e63fe ("netpoll: Eliminate redundant assignment")
---
 net/core/netpoll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/netpoll.c +1 -1
index 4ddb7490df4b8..6ad84d4a2b464 100644
@@ -432,6 +432,7 @@ int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 	udph->dest = htons(np->remote_port);
 	udph->len = htons(udp_len);
 
+	udph->check = 0;
 	if (np->ipv6) {
 		udph->check = csum_ipv6_magic(&np->local_ip.in6,
 					      &np->remote_ip.in6,
@@ -460,7 +461,6 @@ int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 		skb_reset_mac_header(skb);
 		skb->protocol = eth->h_proto = htons(ETH_P_IPV6);
 	} else {
-		udph->check = 0;
 		udph->check = csum_tcpudp_magic(np->local_ip.ip,
 						np->remote_ip.ip,
 						udp_len, IPPROTO_UDP,

---
base-commit: 720d4a1714e78cfdc05d44352868601be9c3de94
change-id: 20250620-netpoll_fix-8c678facd8d9

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Breno Leitao

commit f1fce08e63fe ("netpoll: Eliminate redundant assignment") removed the initialization of the UDP checksum, which was wrong and broke netpoll IPv6 transmission due to bad checksumming.

udph->check needs to be set before calling csum_ipv6_magic().

Fixes f1fce08e63fe ("netpoll: Eliminate redundant assignment")
#2 lore raw
In reply to Breno Leitao
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 20 Jun 2025 11:48:55 -0700 you wrote:

commit f1fce08e63fe ("netpoll: Eliminate redundant assignment") removed the initialization of the UDP checksum, which was wrong and broke netpoll IPv6 transmission due to bad checksumming.

udph->check needs to be set before calling csum_ipv6_magic().

Fixes f1fce08e63fe ("netpoll: Eliminate redundant assignment")

[...]

Here is the summary with links:
- [net] net: netpoll: Initialize UDP checksum field before checksumming

    https://git.kernel.org/netdev/net/c/f59902070269

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Reviewed-by on v1 1/1
#3 lore raw
In reply to Breno Leitao
Quoted 8 lines · Breno Leitao

commit f1fce08e63fe ("netpoll: Eliminate redundant assignment") removed the initialization of the UDP checksum, which was wrong and broke netpoll IPv6 transmission due to bad checksumming.

udph->check needs to be set before calling csum_ipv6_magic().

Fixes f1fce08e63fe ("netpoll: Eliminate redundant assignment")
#4 lore raw
In reply to Breno Leitao
Quoted 8 lines · Breno Leitao

commit f1fce08e63fe ("netpoll: Eliminate redundant assignment") removed the initialization of the UDP checksum, which was wrong and broke netpoll IPv6 transmission due to bad checksumming.

udph->check needs to be set before calling csum_ipv6_magic().

Fixes f1fce08e63fe ("netpoll: Eliminate redundant assignment")

On second thought: small nit: net/core/netpoll.c patches generally only have netpoll: as prefix, not net: netpoll:

Also, perhaps just revert the offending patch? Revert, rather than forward fix.

That said, current approach works too.

Quoted 33 lines
---
 net/core/netpoll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/netpoll.c +1 -2
index 4ddb7490df4b8..6ad84d4a2b464 100644
@@ -432,6 +432,7 @@ int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 	udph->dest = htons(np->remote_port);
 	udph->len = htons(udp_len);
 
+	udph->check = 0;
 	if (np->ipv6) {
 		udph->check = csum_ipv6_magic(&np->local_ip.in6,
 					      &np->remote_ip.in6,
@@ -460,7 +461,6 @@ int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 		skb_reset_mac_header(skb);
 		skb->protocol = eth->h_proto = htons(ETH_P_IPV6);
 	} else {
-		udph->check = 0;
 		udph->check = csum_tcpudp_magic(np->local_ip.ip,
 						np->remote_ip.ip,
 						udp_len, IPPROTO_UDP,
 
---

base-commit: 720d4a1714e78cfdc05d44352868601be9c3de94
change-id: 20250620-netpoll_fix-8c678facd8d9

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>