[PATCH 2/8] tftp: remove sanity check of first block

Enrico Scholz enrico.scholz at sigma-chemnitz.de
Sun Aug 28 07:02:25 PDT 2022


With tftp window size support, the first received block might be !=
1 (e.g. when it was reordered or dropped).  There could be checked
against '!in_window(block, 1, priv->windowsize)', but the corresponding
sanity check can be dropped completely:

- OACK logic verifies that we speak with a tftp server (which always
  sends block #1 as the first one)

- the code some lines later handles this case already

Remove the check and simplify things.

Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
---
 fs/tftp.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/fs/tftp.c b/fs/tftp.c
index 783413797251..aaeb19590e93 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -686,14 +686,6 @@ static void tftp_recv(struct file_priv *priv,
 			priv->tftp_con->udp->uh_dport = uh_sport;
 			priv->last_block = 0;
 			tftp_window_cache_reset(&priv->cache);
-
-			if (block != 1) {	/* Assertion */
-				pr_err("error: First block is not block 1 (%d)\n",
-					block);
-				priv->err = -EINVAL;
-				priv->state = STATE_DONE;
-				break;
-			}
 		}
 
 		tftp_handle_data(priv, block, pkt + 2, len);
-- 
2.37.2




More information about the barebox mailing list