From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8B6F2EF9AA; Thu, 3 Jul 2025 15:14:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751555690; cv=none; b=G0sAP96HGwFr4GobCgUE8OEFE8w4uHqMkntNPHluB/7myS3mp8+GEcE9vLrOi6zllyllv73rXQkF0V7G0x6HAbnVQ7lk4xA6kV8WM4vBMHhlzDCJRdYlL994XFaJXr2SXbhZhfnikpEjNUAXxCzlfx1Gq8+1rWKlBDsSx5U0rF8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751555690; c=relaxed/simple; bh=/Era8LXx8HfSTYcxWnPxhJexpUrZ+1bTxSh2nJaSdMI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qnrgkjhvyuZeUdZuIP5dppzBjzXrlrvw0k+xbgoOTQk2KCyAsT0umR62WMp0n7jdrOi28+Akw50DvRaelI+U6v1mqwOsQE4XIj1JiEODbPdoBw5J8CuSPcMOlRqpT9YQ6wNDEh/A2aIMBBFkbYUdgpEuKnYVKi2VNlAeVAmFnAU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mQhEkHPZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="mQhEkHPZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61854C4CEE3; Thu, 3 Jul 2025 15:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1751555690; bh=/Era8LXx8HfSTYcxWnPxhJexpUrZ+1bTxSh2nJaSdMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mQhEkHPZcUeJDFqV1RMbKmokrdj4HhoI1hA2Q252krVZWwMP7TRuoG9elAN3gTpKC ZkJAdQAyzjrB0DeYWnY0RYmBXJo0ZMImb5dTVFFyk7VB67buJN/6+PinO/HsSk93zE I7MWhTfLGyGMC4kkiL7vWKDmWyUt9DMKmVImczJc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jakub Kicinski , Gerhard Engleder , Oleksij Rempel , Paolo Abeni , Sasha Levin Subject: [PATCH 6.6 090/139] net: selftests: fix TCP packet checksum Date: Thu, 3 Jul 2025 16:42:33 +0200 Message-ID: <20250703143944.678940648@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250703143941.182414597@linuxfoundation.org> References: <20250703143941.182414597@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jakub Kicinski [ Upstream commit 8d89661a36dd3bb8c9902cff36dc0c144dce3faf ] The length in the pseudo header should be the length of the L3 payload AKA the L4 header+payload. The selftest code builds the packet from the lower layers up, so all the headers are pushed already when it constructs L4. We need to subtract the lower layer headers from skb->len. Fixes: 3e1e58d64c3d ("net: add generic selftest support") Signed-off-by: Jakub Kicinski Reviewed-by: Gerhard Engleder Reported-by: Oleksij Rempel Tested-by: Oleksij Rempel Reviewed-by: Oleksij Rempel Link: https://patch.msgid.link/20250624183258.3377740-1-kuba@kernel.org Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/core/selftests.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/core/selftests.c b/net/core/selftests.c index 7af99d07762ea..946e92cca2111 100644 --- a/net/core/selftests.c +++ b/net/core/selftests.c @@ -160,8 +160,9 @@ static struct sk_buff *net_test_get_skb(struct net_device *ndev, skb->csum = 0; skb->ip_summed = CHECKSUM_PARTIAL; if (attr->tcp) { - thdr->check = ~tcp_v4_check(skb->len, ihdr->saddr, - ihdr->daddr, 0); + int l4len = skb->len - skb_transport_offset(skb); + + thdr->check = ~tcp_v4_check(l4len, ihdr->saddr, ihdr->daddr, 0); skb->csum_start = skb_transport_header(skb) - skb->head; skb->csum_offset = offsetof(struct tcphdr, check); } else { -- 2.39.5