All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] inet_ecn: Fix endianness of checksum update when setting ECT(1)
@ 2020-11-30 18:37 Toke Høiland-Jørgensen
  2020-12-02  1:24 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-11-30 18:37 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Toke Høiland-Jørgensen, netdev, Jonathan Morton,
	Pete Heist

When adding support for propagating ECT(1) marking in IP headers it seems I
suffered from endianness-confusion in the checksum update calculation: In
fact the ECN field is in the *lower* bits of the first 16-bit word of the
IP header when calculating in network byte order. This means that the
addition performed to update the checksum field was wrong; let's fix that.

Fixes: b723748750ec ("tunnel: Propagate ECT(1) when decapsulating as recommended by RFC6040")
Reported-by: Jonathan Morton <chromatix99@gmail.com>
Tested-by: Pete Heist <pete@heistp.net>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 include/net/inet_ecn.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index e1eaf1780288..563457fec557 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.h
@@ -107,7 +107,7 @@ static inline int IP_ECN_set_ect1(struct iphdr *iph)
 	if ((iph->tos & INET_ECN_MASK) != INET_ECN_ECT_0)
 		return 0;
 
-	check += (__force u16)htons(0x100);
+	check += (__force u16)htons(0x1);
 
 	iph->check = (__force __sum16)(check + (check>=0xFFFF));
 	iph->tos ^= INET_ECN_MASK;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-02 10:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-30 18:37 [PATCH net] inet_ecn: Fix endianness of checksum update when setting ECT(1) Toke Høiland-Jørgensen
2020-12-02  1:24 ` Jakub Kicinski
2020-12-02 10:07   ` Toke Høiland-Jørgensen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.