From nobody Mon Nov 06 16:45:54 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 4SPHKb1MRfz50FBf; Mon, 6 Nov 2023 16:45:55 +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 4SPHKb0p0Dz4GyZ; Mon, 6 Nov 2023 16:45:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699289155; 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=WQFp91ljFAWg1kWp+d79Zxc/DwCLIBP6T4G74g2tELU=; b=jpl3botur9dBdmzyaIUb8R21IMMAJy0sH47L8TZKm7jqLZNc3qoUI7muqs5SD/+pWYZZkN BAG/9D0JmN/3yVxbpLX8u7H4cIa63xhGuCCjhwrVU7aI9d3zSdHXlspZ02wcfmvQZZTYLn SDHsYkGKlT7gOLl6ykoibwc3NxWI9P+qsiPryxUnZ0RKMxIpAzTYX1EI/b0R4iBf5oz7vF a8dV2ukBdNDkbv7t+JV95Mtbsg+AqOX+12nYbjJu7Uy6HAifiJtdVvBrSVW3Vk3Pw9rRhE BgSgPnaZj/VWVlGEGFNU+zloFCBgmNVWBoueJ9b2HNxlrBcFR7E/TtF2XI9qgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699289155; 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=WQFp91ljFAWg1kWp+d79Zxc/DwCLIBP6T4G74g2tELU=; b=xoOBQyzAi9+iijDbdKExgeN6eDE/g5lkxeYhiG/JpFAq5yXsKzEfv3vzKL7iB6OvVSIRju bYfaV2jqWM+Q8aAvPQvXkSTYD0iZGXu2uXSVzGdMNjR4Sw6NgLZE8wjpWDD65z/waxiMvk Scj/4OSjchRU9iqJrQ9Zrgzaao5+T4wsu6q2FOoQS0oz39pNbPybEb8wcMk+2YUBOQGzzT OerPRu5HO5PfqsrMAdCO1jdSm7D0Si8VzvNXA9zcyeeHH8eBOksX44Gsc6iBewgCMJdZBn 7KgGFCgO+wEdJyi2UhbhH2Bnz1Vs6HGTVUnwTQduTtkuEe6+/HlYkPTzoCFNOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699289155; a=rsa-sha256; cv=none; b=xHUWo59Jgn3z5f9OLMJ7IY19mH1IilaKScuZPmOZUXNSj0WISeRBX3F6mIk4KA1/+pdezV 4ujr6jSkAR9MjKs0+4hrrEaIUYzuGUJfDShlXJTM1HQPXaU+7j3JdlLy1ccxH5wrq3i6M3 uiPOaAFUmoMhqO+xkuuV26Rw0FjyyGkWIn1bZubIovifnzppZKmM1zK77r8jdQkTl8neh6 P6l0NS6NsJvaAzO4AYsZptpMsAMwODCTzCeaYCpmVNiHqIEKvr2XFPgjwzyRp12RCfqlj9 5pRpL746jMAATSQ5PFL3PvJVUWV/vl0v3lb//b6PCtdTohP/1YSCmZHWn47vkg== 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 4SPHKZ6z1nzsk; Mon, 6 Nov 2023 16:45:54 +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 3A6GjsUX058482; Mon, 6 Nov 2023 16:45:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A6GjsHB058479; Mon, 6 Nov 2023 16:45:54 GMT (envelope-from git) Date: Mon, 6 Nov 2023 16:45:54 GMT Message-Id: <202311061645.3A6GjsHB058479@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 0c74823f5c13 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 0c74823f5c135a039832f62dd50b79625f26f0fe Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0c74823f5c135a039832f62dd50b79625f26f0fe commit 0c74823f5c135a039832f62dd50b79625f26f0fe Author: Jose Luis Duran AuthorDate: 2023-04-10 16:58:42 +0000 Commit: Mark Johnston CommitDate: 2023-11-06 16:45:44 +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 (cherry picked from commit 8db2c5802abe14543504e17ab5ed6325088a63f3) --- 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 52be1c7f91ae..00ddbbd63723 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)