From nobody Mon Mar 27 03:49:08 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 4PlJhh5hLhz41dKC; Mon, 27 Mar 2023 03:49: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 4PlJhh4z9Wz3mty; Mon, 27 Mar 2023 03:49:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679888948; 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=vaJIDPK0wmUuTOLCOLUWrtMdz+IniX4lTuuswfI6x2M=; b=VUWi/BR5YMFJKvpPmgUVY8tSuNftcRxJQoDb6Lg7rbMYHJPywgPY8UxH7uSBbMNL7BnYmo ZaxRL1GAiCC46+tbUR4eWB46RalNpSd+IKrqPDh4ld1hgZyX9eV7UZItMgkI9pC/bfzzRf DZ5jPK8MxemKeqiF/AGAAW+H2ZmJ3tjRaogk65zM8KheKoihdljvE5hGkJBLU11yxIVPfK YrNEGxs6sbG3kac3d6aXhj6200DuK3iPFXSptgi9M4M7WEs6tTsUoK2z05dkHfffpn2aqV KdEEJ3eFAUS3gm3l8XxyZb1QmzoRV78xg7jltB79Q0POZ05X3zsiFwGCrZbJVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679888948; 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=vaJIDPK0wmUuTOLCOLUWrtMdz+IniX4lTuuswfI6x2M=; b=EhgNh4AH0oQGtKX3OBuT2/TL9BfQSpKacR59o+ZsInineVW1p5mJe62VwG6aBb8rvXwFS6 GgNQ1TtUJihSVvOAXeCkjMbT638b5uHF7owp9QeKvtVkmuvyOq5kl2a1EkWasUuKHUVa31 F+baKhrbdJmmee3Xg/spCYYpw/ioU2xgpQMmPfEb3Lfw3x2DcuJK3b7IaJ3kueYBYgt7Vx KSaT3sD7/DbqDSs3GY6q3Hd8r2iKpHNqpRPX3PCm0vMMA5GMSIxqPjdZ8nz7zBJk3dIADG Cj0kecv6C3WXKiuAPND86R+0EfnwflvMZBFVXfCJmAjfAFs1GhFso3cGqyUuJg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679888948; a=rsa-sha256; cv=none; b=NivWe11t9dmkVw2rKmfIclpbOc62CrxfTIRovTMib0Adqbd4QCOiuY0MccDbGzoUhw4omB ALOrjXAWR6jjdwdVl4JPmW5GxkxIR3XOTy1JapCRKiCgAGC3bqt2qrSSlj83DvPaBvxyT/ Zpzgg8FKvZtVsPEdGPMG7vmNTKNmEtDI/212qsmAM9wh95jWtImMBxeighTWllT1ndragv dsmNWIZ5b3UD+ZfLcwtv4vtOwzX6Gpe48qoS4rBfvpdpWVfdKIUwhO2w0Q+GZLHdpSzZG2 V9uQfVBj5KxUQU/5ut93xeMqKgnoyChr36Uzz1y0GLZkqUT0fK41NDtoyGZB1w== 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 4PlJhh40Pqz16P0; Mon, 27 Mar 2023 03:49:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32R3n8fX002529; Mon, 27 Mar 2023 03:49:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32R3n8JL002528; Mon, 27 Mar 2023 03:49:08 GMT (envelope-from git) Date: Mon, 27 Mar 2023 03:49:08 GMT Message-Id: <202303270349.32R3n8JL002528@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Cy Schubert Subject: git: 9fc2d858b4e9 - main - ping tests: Add a regression test 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: cy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9fc2d858b4e9457a122a54c1a25715314032bf41 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=9fc2d858b4e9457a122a54c1a25715314032bf41 commit 9fc2d858b4e9457a122a54c1a25715314032bf41 Author: Jose Luis Duran AuthorDate: 2023-03-26 03:11:50 +0000 Commit: Cy Schubert CommitDate: 2023-03-27 02:54:29 +0000 ping tests: Add a regression test Test regression fixed in 4630a3252ac8. Add two tests that do not use the verbose flag, so the code path in question can be reached: 1. Respond with a proper ICMP destination host unreachable packet. 2. Respond with a doctored ICMP destination host unreachable packet, that has the ICMP Identifier field modified (+1 bit). Reviewed by: cy MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39244 --- sbin/ping/tests/test_ping.py | 61 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/sbin/ping/tests/test_ping.py b/sbin/ping/tests/test_ping.py index f1c961c5b551..79cde1f4936c 100644 --- a/sbin/ping/tests/test_ping.py +++ b/sbin/ping/tests/test_ping.py @@ -56,6 +56,9 @@ def build_response_packet(echo, ip, icmp, oip_ihl, special): # Build a package with a wrong last byte payload_no_last_byte = sc.bytes_hex(load)[:-2] load = (sc.hex_bytes(payload_no_last_byte)) + b"\x00" + if special == "not-mine": + # Modify the ICMP Identifier field + oicmp.id += 1 if icmp.type in icmp_id_seq_types: pkt = ip / icmp / load @@ -148,6 +151,7 @@ def pinger( # Miscellaneous arguments count: int = 1, dup: bool = False, + verbose: bool = True, ) -> subprocess.CompletedProcess: """P I N G E R @@ -173,8 +177,8 @@ def pinger( :type opts: str, optional :keyword oip_ihl: Inner packet's Internet Header Length, defaults to None :type oip_ihl: class:`scapy.fields.BitField`, optional - :keyword special: Send a special packet - one of `no-payload`, `tcp`, - `udp`, `wrong` or `warp`, defaults to None + :keyword special: Send a special packet - one of `no-payload`, `not-mine`, + `tcp`, `udp`, `wrong` or `warp`, defaults to None :type special: str, optional :keyword icmp_pptr: ICMP pointer, defaults to 0 :type icmp_pptr: class:`scapy.fields.ByteField` @@ -197,6 +201,8 @@ def pinger( :type count: int :keyword dup: Duplicate packets, defaults to `False` :type dup: bool + :keyword verbose: Turn on/off verbosity, defaults to `True` + :type verbose: bool :return: A class:`subprocess.CompletedProcess` with the output from the ping utility @@ -213,8 +219,9 @@ def pinger( str(count), "-t", str(count), - "-v", ] + if verbose: + command += ["-v"] if request == "mask": command += ["-Mm"] if request == "timestamp": @@ -1210,6 +1217,54 @@ ping: quoted data too short (28 bytes) from 192.0.2.2 }, id="_3_1_special_udp", ), + pytest.param( + { + "src": "192.0.2.1", + "dst": "192.0.2.2", + "icmp_type": 3, + "icmp_code": 1, + "verbose": False, + }, + { + "returncode": 2, + "stdout": """\ +PING 192.0.2.2 (192.0.2.2): 56 data bytes +92 bytes from 192.0.2.2: Destination Host Unreachable +Vr HL TOS Len ID Flg off TTL Pro cks Src Dst + 4 5 00 0054 0001 0 0000 40 01 f6a4 192.0.2.1 192.0.2.2 + + +--- 192.0.2.2 ping statistics --- +1 packets transmitted, 0 packets received, 100.0% packet loss +""", + "stderr": "", + "redacted": False, + }, + id="_3_1_verbose_false", + ), + pytest.param( + { + "src": "192.0.2.1", + "dst": "192.0.2.2", + "icmp_type": 3, + "icmp_code": 1, + "special": "not-mine", + "verbose": False, + }, + { + "returncode": 2, + "stdout": """\ +PATTERN: 0x01 +PING 192.0.2.2 (192.0.2.2): 56 data bytes + +--- 192.0.2.2 ping statistics --- +1 packets transmitted, 0 packets received, 100.0% packet loss +""", + "stderr": "", + "redacted": False, + }, + id="_3_1_special_not_mine_verbose_false", + ), pytest.param( { "src": "192.0.2.1",