"ping URL -w 6" always fail (1.31.x until now)

Denys Vlasenko vda.linux at googlemail.com
Sun Dec 20 10:17:24 UTC 2020


Fixed, thanks!

On Sat, Dec 19, 2020 at 7:50 PM Justin Jiang <jiangjun.jking at gmail.com> wrote:
>
> Please any busybox maintainers help to assess and merge the following patch for ping.c, thanks.
>
> https://bugs.busybox.net/show_bug.cgi?id=13401
>
> ping someurl with -w arguments, it always failed
>
> ### EXAMPLE OUTPUT
> =========================
> $ ./busybox ping www.baidu.com -w 6
> PING www.baidu.com (180.101.49.11): 56 data bytes
> 64 bytes from 180.101.49.11: seq=0 ttl=51 time=10.078 ms
> 64 bytes from 180.101.49.11: seq=1 ttl=51 time=10.097 ms
> 64 bytes from 180.101.49.11: seq=2 ttl=51 time=10.109 ms
> 64 bytes from 180.101.49.11: seq=3 ttl=51 time=10.124 ms
> 64 bytes from 180.101.49.11: seq=4 ttl=51 time=10.104 ms
> 64 bytes from 180.101.49.11: seq=5 ttl=51 time=10.084 ms
>
> --- www.baidu.com ping statistics ---
> 7 packets transmitted, 6 packets received, 14% packet loss
> round-trip min/avg/max = 10.078/10.099/10.124 ms
>
> ------------------
>
> From above, the transmitted packets number is always bigger than the packets received by 1.
>
>
> ### SUGGESTED FIX:
> =====================
>
>
> diff --git a/networking/ping.c b/networking/ping.c
> index a47342f..b8d1a14 100644
> --- a/networking/ping.c
> +++ b/networking/ping.c
> @@ -468,7 +468,6 @@ static void sendping_tail(void (*sp)(int), int size_pkt)
>     int sz;
>
>     CLR((uint16_t)G.ntransmitted % MAX_DUP_CHK);
> -   G.ntransmitted++;
>
>     size_pkt += datalen;
>
> @@ -478,6 +477,8 @@ static void sendping_tail(void (*sp)(int), int size_pkt)
>             print_stats_and_exit(0);
>     }
>
> +   G.ntransmitted++;
> +
>     /* sizeof(pingaddr) can be larger than real sa size, but I think
>      * it doesn't matter */
>     sz = xsendto(pingsock, G.snd_packet, size_pkt, &pingaddr.sa, sizeof(pingaddr));
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list