[PATCH v2] net: tftp: Avoid sending extra ack on completion

Suneel Garapati suneelglinux at gmail.com
Wed Feb 3 21:57:56 CET 2021


On Wed, Feb 3, 2021 at 11:26 AM Ramon Fried <rfried.dev at gmail.com> wrote:
>
> in tftpboot, if ack was already sent previously for this
> packet, don't send again.
>
> Fixes: cc6b87ecaa96 ("net: tftp: Add client support for RFC 7440")
>
> Reported-by: Suneel Garapati <suneelglinux at gmail.com>
> Signed-off-by: Ramon Fried <rfried.dev at gmail.com>
> ---
> v2: Fix it so it actually works :)
>
>  net/tftp.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/net/tftp.c b/net/tftp.c
> index 03079ded34..6b781ccf67 100644
> --- a/net/tftp.c
> +++ b/net/tftp.c
> @@ -668,6 +668,12 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
>                         break;
>                 }
>
> +               if (len < tftp_block_size) {
> +                       tftp_send();
> +                       tftp_complete();
> +                       break;
> +               }
> +
>                 /*
>                  *      Acknowledge the block just received, which will prompt
>                  *      the remote for the next one.
> @@ -676,11 +682,6 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
>                         tftp_send();
>                         tftp_next_ack += tftp_windowsize;
>                 }
> -
> -               if (len < tftp_block_size) {
> -                       tftp_send();
> -                       tftp_complete();
> -               }
>                 break;
>
>         case TFTP_ERROR:
> --
> 2.17.1
>
Tested-by: Suneel Garapati <suneelglinux at gmail.com>


More information about the U-Boot mailing list