From patchwork Thu Jan 5 00:45:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Edmond X-Patchwork-Id: 1721819 X-Patchwork-Delegate: rfried.dev@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=cT0WKZy4; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NnmpK3VdPz23dq for ; Fri, 6 Jan 2023 00:02:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0B1C6855A3; Thu, 5 Jan 2023 14:02:12 +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="cT0WKZy4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C8A5685587; Thu, 5 Jan 2023 01:45:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-17.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,SPF_HELO_PASS,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by phobos.denx.de (Postfix) with ESMTP id 31C1C8552C for ; Thu, 5 Jan 2023 01:45:45 +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 A135620B8762; Wed, 4 Jan 2023 16:45:43 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A135620B8762 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1672879543; bh=SpzMngjJYTete8WxPxDpckHfWNZO8+B+EOYMgNBUnNk=; h=From:To:Cc:Subject:Date:From; b=cT0WKZy4NJLYC3aOciDLdVTy5FdXRCU5az2CqxXvpnLWCf/FavuT/lHCrnsYnNdu/ MegEMQ+PURfZHKt9j8rHemZOKcyr1GRHPvTIvF0a4i4U+Rfb167Ms39lJ7hD3C9cog k8qo/oBN7aku6oGKJthPfOCehNAY4Nn129ulW9xE= From: seanedmond@linux.microsoft.com To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, rfried.dev@gmail.com Subject: [PATCH] net: tftp: Fix for DATA ACK for block count out of order Date: Wed, 4 Jan 2023 16:45:42 -0800 Message-Id: <20230105004542.13638-1-seanedmond@linux.microsoft.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 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