From: Toke Høiland-Jørgensen Date: Mon, 30 Nov 2020 18:37:05 +0000 (+0100) Subject: inet_ecn: Fix endianness of checksum update when setting ECT(1) X-Git-Tag: v5.15~2314^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2867e1eac61016f59b3d730e3f7aa488e186e917;p=platform%2Fkernel%2Flinux-starfive.git inet_ecn: Fix endianness of checksum update when setting ECT(1) 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 Tested-by: Pete Heist Signed-off-by: Toke Høiland-Jørgensen Link: https://lore.kernel.org/r/20201130183705.17540-1-toke@redhat.com Signed-off-by: Jakub Kicinski --- diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h index e1eaf17..563457f 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;