From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB4D1C53210 for ; Thu, 5 Jan 2023 13:02:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2483C855AC; Thu, 5 Jan 2023 14:02:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="sSRY86BJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B2E098558A; Thu, 5 Jan 2023 03:16:36 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by phobos.denx.de (Postfix) with ESMTP id 2941985513 for ; Thu, 5 Jan 2023 03:16:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanedmond@linux.microsoft.com Received: from ovlvm106.redmond.corp.microsoft.com (unknown [131.107.174.57]) by linux.microsoft.com (Postfix) with ESMTPSA id 2EDC720B928C; Wed, 4 Jan 2023 18:16:33 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2EDC720B928C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1672884993; bh=DAV1eA+hoj6ECZZHRoZsX9LnwJvqURzXNf0gTpwxSNY=; h=From:To:Cc:Subject:Date:From; b=sSRY86BJA87ZIn9DPQnT6C6CiURWrDWYMKq3RqzBFK42dksIqMOjKFrHxV00kU2bg OgBtJvzNRGjgZ7fw0LognbwMvlt5eCce0xX7pU69mkuNkdKOdt7PKAiavNgbn6Hwy4 VLKZPgdzWbO7MEA0SI++7z6yFrHxkrLhOLnafw3Y= From: seanedmond@linux.microsoft.com To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, rfried.dev@gmail.com, seanedmond@microsoft.com Subject: [PATCH] net: tftp: Fix for DATA ACK for block count out of order Date: Wed, 4 Jan 2023 18:16:26 -0800 Message-Id: <20230105021626.7032-1-seanedmond@linux.microsoft.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Thu, 05 Jan 2023 14:02:10 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean From: Sean Edmond In rfc7440, if an ACK is not received by the server or if the last data block in a window is dropped, the server will timeout and retransmit the window. In this case, the block count received will be less than the internal block count. In this case, the client should not ACK. ACK should only be sent if the received block count is greater than the expected block count. Signed-off-by: Sean Edmond --- net/tftp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/tftp.c b/net/tftp.c index c780c33f37..51e062bddf 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -592,6 +592,14 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip, debug("Received unexpected block: %d, expected: %d\n", ntohs(*(__be16 *)pkt), (ushort)(tftp_cur_block + 1)); + /* + * Only ACK if the block count received is greater than + * the expected block count, otherwise skip ACK. + * (required to properly handle the server retransmitting + * the window) + */ + if ((ushort)(tftp_cur_block + 1) - (short)(ntohs(*(__be16 *)pkt)) > 0) + break; /* * If one packet is dropped most likely * all other buffers in the window -- 2.39.0