summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorWolfram Sang <w.sang@pengutronix.de>2012-04-04 18:04:43 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-04-05 08:56:03 +0200
commit25b0134d1498f3b235d564b2eec5998d69cd0324 (patch)
tree4daa66c205a35abbb1af75cc5acfe3164283c094 /net
parent56f6bfb820a61f9aef0964f609b22d0ad73d0bb3 (diff)
downloadbarebox-25b0134d1498f3b235d564b2eec5998d69cd0324.tar.gz
barebox-25b0134d1498f3b235d564b2eec5998d69cd0324.tar.xz
net: tftp: do not retry endlessly
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r--net/tftp.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/net/tftp.c b/net/tftp.c
index 243ad0a968..fc33c94583 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -39,6 +39,7 @@ static unsigned int tftp_last_block; /* last packet sequence number received */
static int tftp_state;
static uint64_t tftp_timer_start;
static int tftp_err;
+static unsigned tftp_retries;
#define STATE_RRQ 1
#define STATE_WRQ 2
@@ -106,6 +107,7 @@ static int tftp_send(void)
}
tftp_last_block = tftp_block;
+ tftp_retries = 0;
s = (uint16_t *)pkt;
*s++ = htons(TFTP_DATA);
*s++ = htons(tftp_block);
@@ -231,6 +233,7 @@ static void tftp_handler(void *ctx, char *packet, unsigned len)
break;
tftp_last_block = tftp_block;
+ tftp_retries = 0;
if (!(tftp_block % 10))
tftp_size++;
@@ -278,6 +281,7 @@ static int do_tftpb(int argc, char *argv[])
do_tftp_push(0);
tftp_last_block = 0;
tftp_size = 0;
+ tftp_retries = 0;
while((opt = getopt(argc, argv, "p")) > 0) {
switch(opt) {
@@ -348,6 +352,12 @@ static int do_tftpb(int argc, char *argv[])
tftp_err = tftp_send();
if (tftp_err)
goto out_unreg;
+ tftp_retries++;
+ }
+
+ if (tftp_retries > PKT_NUM_RETRIES) {
+ tftp_err = -ETIMEDOUT;
+ break;
}
}
out_unreg: