* [PATCH] net: tftp: fix progress marker for file transfer
@ 2020-05-07 21:55 Ravik Hasija
2020-05-23 5:07 ` Ramon Fried
2020-06-12 21:16 ` Tom Rini
0 siblings, 2 replies; 3+ messages in thread
From: Ravik Hasija @ 2020-05-07 21:55 UTC (permalink / raw)
To: u-boot
During packet sequence number wraparound the show_block_marker() API was
not called, as a result the progress marker doesn't stay within column
boundary. Use position in file instead of sequence number to align the
marker.
Signed-off-by: Ravik Hasija <rahasij@linux.microsoft.com>
---
net/tftp.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/net/tftp.c b/net/tftp.c
index 34488b76c8..8039694ef2 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -229,9 +229,11 @@ static void tftp_timeout_handler(void);
static void show_block_marker(void)
{
+ ulong pos;
+
#ifdef CONFIG_TFTP_TSIZE
if (tftp_tsize) {
- ulong pos = tftp_cur_block * tftp_block_size +
+ pos = tftp_cur_block * tftp_block_size +
tftp_block_wrap_offset;
if (pos > tftp_tsize)
pos = tftp_tsize;
@@ -243,9 +245,11 @@ static void show_block_marker(void)
} else
#endif
{
- if (((tftp_cur_block - 1) % 10) == 0)
+ pos = (tftp_cur_block - 1) +
+ (tftp_block_wrap * TFTP_SEQUENCE_SIZE);
+ if ((pos % 10) == 0)
putc('#');
- else if ((tftp_cur_block % (10 * HASHES_PER_LINE)) == 0)
+ else if (((pos + 1) % (10 * HASHES_PER_LINE)) == 0)
puts("\n\t ");
}
}
@@ -278,9 +282,8 @@ static void update_block_number(void)
tftp_block_wrap++;
tftp_block_wrap_offset += tftp_block_size * TFTP_SEQUENCE_SIZE;
timeout_count = 0; /* we've done well, reset the timeout */
- } else {
- show_block_marker();
}
+ show_block_marker();
}
/* The TFTP get or put is complete */
@@ -514,8 +517,6 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
len -= 2;
tftp_cur_block = ntohs(*(__be16 *)pkt);
- update_block_number();
-
if (tftp_state == STATE_SEND_RRQ)
debug("Server did not acknowledge timeout option!\n");
@@ -541,6 +542,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
break;
}
+ update_block_number();
tftp_prev_block = tftp_cur_block;
timeout_count_max = tftp_timeout_count_max;
net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH] net: tftp: fix progress marker for file transfer
2020-05-07 21:55 [PATCH] net: tftp: fix progress marker for file transfer Ravik Hasija
@ 2020-05-23 5:07 ` Ramon Fried
2020-06-12 21:16 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Ramon Fried @ 2020-05-23 5:07 UTC (permalink / raw)
To: u-boot
On Fri, May 8, 2020 at 2:16 PM Ravik Hasija <rahasij@linux.microsoft.com> wrote:
>
> During packet sequence number wraparound the show_block_marker() API was
> not called, as a result the progress marker doesn't stay within column
> boundary. Use position in file instead of sequence number to align the
> marker.
>
> Signed-off-by: Ravik Hasija <rahasij@linux.microsoft.com>
> ---
> net/tftp.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/net/tftp.c b/net/tftp.c
> index 34488b76c8..8039694ef2 100644
> --- a/net/tftp.c
> +++ b/net/tftp.c
> @@ -229,9 +229,11 @@ static void tftp_timeout_handler(void);
>
> static void show_block_marker(void)
> {
> + ulong pos;
> +
> #ifdef CONFIG_TFTP_TSIZE
> if (tftp_tsize) {
> - ulong pos = tftp_cur_block * tftp_block_size +
> + pos = tftp_cur_block * tftp_block_size +
> tftp_block_wrap_offset;
> if (pos > tftp_tsize)
> pos = tftp_tsize;
> @@ -243,9 +245,11 @@ static void show_block_marker(void)
> } else
> #endif
> {
> - if (((tftp_cur_block - 1) % 10) == 0)
> + pos = (tftp_cur_block - 1) +
> + (tftp_block_wrap * TFTP_SEQUENCE_SIZE);
> + if ((pos % 10) == 0)
> putc('#');
> - else if ((tftp_cur_block % (10 * HASHES_PER_LINE)) == 0)
> + else if (((pos + 1) % (10 * HASHES_PER_LINE)) == 0)
> puts("\n\t ");
> }
> }
> @@ -278,9 +282,8 @@ static void update_block_number(void)
> tftp_block_wrap++;
> tftp_block_wrap_offset += tftp_block_size * TFTP_SEQUENCE_SIZE;
> timeout_count = 0; /* we've done well, reset the timeout */
> - } else {
> - show_block_marker();
> }
> + show_block_marker();
> }
>
> /* The TFTP get or put is complete */
> @@ -514,8 +517,6 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
> len -= 2;
> tftp_cur_block = ntohs(*(__be16 *)pkt);
>
> - update_block_number();
> -
> if (tftp_state == STATE_SEND_RRQ)
> debug("Server did not acknowledge timeout option!\n");
>
> @@ -541,6 +542,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
> break;
> }
>
> + update_block_number();
> tftp_prev_block = tftp_cur_block;
> timeout_count_max = tftp_timeout_count_max;
> net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
> --
> 2.17.1
>
Reviewed-By: Ramon Fried <rfried.dev@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH] net: tftp: fix progress marker for file transfer
2020-05-07 21:55 [PATCH] net: tftp: fix progress marker for file transfer Ravik Hasija
2020-05-23 5:07 ` Ramon Fried
@ 2020-06-12 21:16 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2020-06-12 21:16 UTC (permalink / raw)
To: u-boot
On Thu, May 07, 2020 at 02:55:32PM -0700, Ravik Hasija wrote:
> During packet sequence number wraparound the show_block_marker() API was
> not called, as a result the progress marker doesn't stay within column
> boundary. Use position in file instead of sequence number to align the
> marker.
>
> Signed-off-by: Ravik Hasija <rahasij@linux.microsoft.com>
> Reviewed-By: Ramon Fried <rfried.dev@gmail.com>
Applied to u-boot/next, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200612/cc11b8dc/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-12 21:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-07 21:55 [PATCH] net: tftp: fix progress marker for file transfer Ravik Hasija
2020-05-23 5:07 ` Ramon Fried
2020-06-12 21:16 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox