Your message dated Fri, 19 Mar 2021 23:02:07 +0000
with message-id <[email protected]>
and subject line Bug#920434: fixed in iputils 3:20180629-2+deb10u2
has caused the Debian Bug report #920434,
regarding ping does not round correctly
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
920434: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=920434
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: iputils-ping
Version: 3:20180629-2

Usually, ping reports times like 17.1 ms, but every once in a while it 
reports a trip time of, say, 17.10 ms. I expect to always get 3 
significant digits, not sometimes 4. Here is a transcript:

$ ping 1.1.1.1
(...)
64 bytes from 1.1.1.1: icmp_seq=5318 ttl=53 time=16.4 ms
64 bytes from 1.1.1.1: icmp_seq=5319 ttl=53 time=17.1 ms
64 bytes from 1.1.1.1: icmp_seq=5320 ttl=53 time=13.8 ms
64 bytes from 1.1.1.1: icmp_seq=5321 ttl=53 time=17.10 ms
64 bytes from 1.1.1.1: icmp_seq=5322 ttl=53 time=13.9 ms
(...)

I traced this back to function gather_statistics in file ping_common.c. 
The current rounding is in these lines:

$ grep -n 'triptime >= 10000)' -B 3 -A 9 ping_common.c
855-            if (timing) {
856-                    if (triptime >= 100000)
857-                            printf(" time=%ld ms", (triptime+500)/1000);
858:                    else if (triptime >= 10000)
859-                            printf(" time=%ld.%01ld ms", triptime/1000,
860-                                   ((triptime%1000)+50)/100);
861-                    else if (triptime >= 1000)
862-                            printf(" time=%ld.%02ld ms", triptime/1000,
863-                                   ((triptime%1000)+5)/10);
864-                    else
865-                            printf(" time=%ld.%03ld ms", triptime/1000,
866-                                   triptime%1000);
867-            }

The bug happens for example with triptime = 17981:
    triptime/1000 = 17981/1000
                  = 17 (seconds)
    (triptime%1000)+50)/100 = (17981%1000)+50)/100
                            = (  981      +50)/100
                            =   1031          /100
                            =   10 (tenths of a second)

So, while 17981 ms should have been converted to 18.0 seconds, it is 
converted to 17.10 seconds.

One way of fixing it:

                if (timing) {
                        if (triptime >= 100000 - 50)
                                printf(" time=%ld ms", (triptime+500)/1000);
                        else if (triptime >= 10000 - 5)
                                printf(" time=%ld.%01ld ms", (triptime+50)/1000,
                                       ((triptime+50)%1000)/100);
                        else if (triptime >= 1000)
                                printf(" time=%ld.%02ld ms", (triptime+5)/1000,
                                       ((triptime+5)%1000)/10);
                        else
                                printf(" time=%ld.%03ld ms", triptime/1000,
                                       triptime%1000);
                }

I fixed the triptime thresholds so the output is consistent, added the 
+50/+5 to the whole milliseconds so it gets rounded as well, and moved 
the +50/+5 of the fractional milliseconds to the correct place.

The code is far less readable, so may I suggest that you consider 
rewriting the code so it is better maintainable than my suggested fix?

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
Source: iputils
Source-Version: 3:20180629-2+deb10u2
Done: Noah Meyerhans <[email protected]>

We believe that the bug you reported is fixed in the latest version of
iputils, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Noah Meyerhans <[email protected]> (supplier of updated iputils package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Mon, 08 Mar 2021 11:46:59 -0800
Source: iputils
Architecture: source
Version: 3:20180629-2+deb10u2
Distribution: buster
Urgency: medium
Maintainer: Noah Meyerhans <[email protected]>
Changed-By: Noah Meyerhans <[email protected]>
Closes: 920434 976277
Changes:
 iputils (3:20180629-2+deb10u2) buster; urgency=medium
 .
   * Backport upstream fix for ping rounding errors (Closes: #920434)
   * Backport upstream fix for tracepath target corruption
     (Closes: #976277)
Checksums-Sha1:
 5de843c984c7ca9dcaeaa7d212212aeb8fab905d 2125 iputils_20180629-2+deb10u2.dsc
 ad5dfa2146acadbb0df940c3d3dc1081e94cbd08 14144 
iputils_20180629-2+deb10u2.debian.tar.xz
 fe950becc492dbcb81328338958505d10bbe93e0 6049 
iputils_20180629-2+deb10u2_source.buildinfo
Checksums-Sha256:
 e13bc2f1cc3e306f3075d6fafc48e5615081b5b5a3b05a4679e5b4440b8c962b 2125 
iputils_20180629-2+deb10u2.dsc
 67453f496c473e4b33938bf63b522cf7289242443b9f69243cbdcfb95175b2bb 14144 
iputils_20180629-2+deb10u2.debian.tar.xz
 7c52180ee5e33a2d21ea12aaa26cece8c85de0e66987bfae99419d0770175a6b 6049 
iputils_20180629-2+deb10u2_source.buildinfo
Files:
 171c1d01c6eb96ccff3a775057007e12 2125 net optional 
iputils_20180629-2+deb10u2.dsc
 b9fb15a552ecd26800ea62386d0d79f5 14144 net optional 
iputils_20180629-2+deb10u2.debian.tar.xz
 5b9697849fc9a2c9b4978d1d7b5d96e5 6049 net optional 
iputils_20180629-2+deb10u2_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJFBAEBCgAvFiEE65xaF5r2LDCTz+zyV68+Bn2yWDMFAmBTek4RHG5vYWhtQGRl
Ymlhbi5vcmcACgkQV68+Bn2yWDMQ+A//ZladMDFXKGgd/0TiD1AGZa3QZa6l2PHP
4q1X5VUafjABAlskoChYDiC4XbdY127GUntLJOWVDV1O2OZZbbjBKMc/dUqzoROP
t2Bq+7cz7AnHxnw97AuPe/MBjLEnV+617K+BE5935Zuon9lXUTedMr1ZvSU/Gcrq
VnPKks0fXEiMQUJCnPac1qxx/QVSIMky5lJLKyGSr/BYk7HyWCF+gPVHG2RzbqoH
C9wqVupN33O/nFRKBP6d6qh5DJzAPCRjD/XqzVH+TyCPohOHbdNBYvVRLMBl5nbJ
NUNRNesDPIWG26ZE8Zff96HId0tEIZwd7v+YkT7Z+Jfa6aSJdt41Bvg8dXy70teu
umS+EhCx0iAaOSdGBJechIh/UdIcsviLRYeK41YUOl3oUOxJTnZFZp+ghp4K5v1F
2J29yanm0jdpPrx4VCWcuJ7SCseq5RHO4FQbGrA5GfiXP/oFvToj3gSwDO9I3UNc
L2pGgJqP+FfdYeA1W7MU71Rk5gdOxpUvOeSXf0Z8HSZkGwmBDIpuuCO+X9TpafbK
l23AmjmNmEcSOa7whVjzc0BBPPqB4vqK3n7xzkb1P1xcC4wo+b2Xm1LYeYji5gyk
kBexk75QOjQ2Ax2TIOUHgw3OhnnxUGldL2y2/Jm/cgmm+jFwtTAzInvu4mv9hq0M
cS+1PSqzanE=
=ygZf
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to