From nobody Wed Oct 11 18:01:07 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S5LDN0Wpbz4wTht; Wed, 11 Oct 2023 18:01:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S5LDM72NSz4Pqm; Wed, 11 Oct 2023 18:01:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697047268; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VreEXkOytXb3xwQAMlM6AKJKNCBJ+uGx9J6FHaZvuMY=; b=IiS4jnS4Q2mPZCPIBDvJtkBMKAsyLwW1uqcaJbZeQ0vrvcjLn3kxZqTtIqup+/KOhMRrQ/ xGnCw63DiofmI1gZ73ufNkoWDXIoRnc7AND+1ydPe/5N9tj1FKQXfJqWZudJg4nu4U5hKO GZ1OoTMVm7oZwfimtcsKY+pMHDgMa5SzPjYUTRrJz5Hy03EVtaxJ33QctRikNnv7Mg0Iky PBZUrTvEwUbZrCMOgx6qq5aKvvtXYzm7eeZ0f6b0bwGLsBNB31qFD4GgAtyDqTxSRkZ1vp xN4Wkx/GDQA9w8gbPLO6EjQPgOh9dzrZCRKvsGkRGE36s57yAVIr1kx1RTPSQg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697047268; a=rsa-sha256; cv=none; b=MkKWJoPWt6DNVA6Z4twl38m9G4FpUvDml1l/lr/0RL6T7v+SekQ/ZkhFYvrjFc07h4T/H0 LAFyAmszBkPL4CmiAGJopiknvxQ1qjhXxGxBZrR2tUPuXOF5mAQM4qzXuR9daUqZhfImTQ Oly07uRkvY6dY7YLuT27bOsY8yQFJN5kKPEMWQg7aGwyTxd6XuB+qaXHAsBWudEJJCPfGp TLK8M5VoYOCn+QKs3DrHFQ3Sag+rc0w79Yo0hvXAvYRczWmqv8BAxpS/i6v2leQPFqBFGM TSYf8Km/bMMCWlR4HMVLqD1m/8GiZZ9uP0KzNMV4hfRhAhkTPJ1QHHySHeoXfg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697047268; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VreEXkOytXb3xwQAMlM6AKJKNCBJ+uGx9J6FHaZvuMY=; b=tDCDgo1V7cWjASB9TT0slVdK9hpeTRtZ1yP2M3GGlOTESwlUwPwodTIH+jO5D5xCxlPlg8 B1s/fIXuuffnotkxwrX1K8AEOqHtzLBf9hb3wrVpnaQcOYcae3SaCkKRCOsYnXeVyk8Op+ uOWEG5poq7XOUiacvyfKt0Ujq7HDEFyybf8h8W7k2hFgnXuIOBQSa9VoNJzM8yQV7W+Jfv esc4JVBpCmD1/6LreGylLT3r744d40CyIzsFS40CRBE+ERgttLaMkz5lo5vut69OM+3ztL 76TkVyaEf6x4DO1bZjBu5vIATBi52/oxrcHNQzLb+FLO4tGIhBwSzYdOmjzCWA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S5LDM680NzWt3; Wed, 11 Oct 2023 18:01:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39BI173r053867; Wed, 11 Oct 2023 18:01:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39BI17k2053864; Wed, 11 Oct 2023 18:01:07 GMT (envelope-from git) Date: Wed, 11 Oct 2023 18:01:07 GMT Message-Id: <202310111801.39BI17k2053864@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 8db2c5802abe - main - ping: Fix the spacing between the time stamp and cp/dp List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8db2c5802abe14543504e17ab5ed6325088a63f3 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8db2c5802abe14543504e17ab5ed6325088a63f3 commit 8db2c5802abe14543504e17ab5ed6325088a63f3 Author: Jose Luis Duran AuthorDate: 2023-04-10 16:58:42 +0000 Commit: Mark Johnston CommitDate: 2023-10-11 17:48:28 +0000 ping: Fix the spacing between the time stamp and cp/dp When an echo reply packet is received, the data is compared with the sent data. When a wrong byte is detected the command displays a report with the differences. The first row (the first 8-bytes of data after the ICMP header) should include the time stamp (if data is at least 8-bytes), this value is not taken into consideration for the comparison. The remaining rows represent the data (padded pattern) received/sent, with each byte being compared for differences. Print the space before (not after), to add an extra space after cp:/dp: for better readability when the first time stamp octet is not zero-padded, and to remove trailing spaces in the output. Before: cp:99 0 0 c 1 5 c 0␣ ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd␣ ... After: cp: 99 0 0 c 1 5 c 0 ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd ... Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D39492 --- sbin/ping/ping.c | 4 ++-- sbin/ping/tests/test_ping.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index bbb103a7361f..fcc27d34ee54 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1261,14 +1261,14 @@ pr_pack(char *buf, ssize_t cc, struct sockaddr_in *from, struct timespec *tv) for (i = 0; i < datalen; ++i, ++cp) { if ((i % 16) == 8) (void)printf("\n\t"); - (void)printf("%2x ", *cp); + (void)printf(" %2x", *cp); } (void)printf("\ndp:"); cp = &outpack[ICMP_MINLEN]; for (i = 0; i < datalen; ++i, ++cp) { if ((i % 16) == 8) (void)printf("\n\t"); - (void)printf("%2x ", *cp); + (void)printf(" %2x", *cp); } break; } diff --git a/sbin/ping/tests/test_ping.py b/sbin/ping/tests/test_ping.py index c51823103133..545e680fbc9f 100644 --- a/sbin/ping/tests/test_ping.py +++ b/sbin/ping/tests/test_ping.py @@ -275,6 +275,8 @@ def redact(output): ("hlim=[0-9]*", "hlim="), ("ttl=[0-9]*", "ttl="), ("time=[0-9.-]*", "time="), + ("cp: .*", "cp: xx xx xx xx xx xx xx xx"), + ("dp: .*", "dp: xx xx xx xx xx xx xx xx"), ("\(-[0-9\.]+[0-9]+ ms\)", "(- ms)"), ("[0-9\.]+/[0-9.]+", "/"), ] @@ -1401,6 +1403,39 @@ ping: time of day goes back (- ms), clamping time to 0 }, id="_0_0_special_warp", ), + pytest.param( + { + "src": "192.0.2.1", + "dst": "192.0.2.2", + "icmp_type": 0, + "icmp_code": 0, + "special": "wrong", + }, + { + "returncode": 0, + "stdout": """\ +PATTERN: 0x01 +PING 192.0.2.2 (192.0.2.2): 56 data bytes +64 bytes from: icmp_seq=0 ttl= time= ms +wrong data byte #55 should be 0x1 but was 0x0 +cp: xx xx xx xx xx xx xx xx + 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 +dp: xx xx xx xx xx xx xx xx + 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + +--- 192.0.2.2 ping statistics --- +1 packets transmitted, 1 packets received, 0.0% packet loss +round-trip min/avg/max/stddev = /// ms +""", + "stderr": "", + "redacted": True, + }, + id="_0_0_special_wrong", + ), ] @pytest.mark.parametrize("pinger_kargs, expected", pinger_testdata)