From nobody Fri Jun 27 11:13:11 2025 X-Original-To: dev-commits-src-main@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 4bTCbC4vB2z5yf0k; Fri, 27 Jun 2025 11:13:11 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bTCbC3cTLz4LXn; Fri, 27 Jun 2025 11:13:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751022791; 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=J3mjlr8wNr8y3Bh70iNmRIFiu8EG+OkB6k9EMLOzBQo=; b=flwLMiLgjDSuUzeO1m7odBjTCF3kCK8dbel8NVbb912yAFY69kN/UZmXYt7cV5HE2HVHUw Cz0fbw8sMltazUBKRshfgTI0EwUAOIhnKBJZb4JCtOtjEl2QJiTg8OB9w6isedOUST9bLY 9TSOfo2tYUoZTEdU+xcKaSe6Z/kRMp3ocroet1JedXHyvneqcUexXEyiM09/hUZrVzqsIe 8ln3NwIoVTRAuqrQgMEfTiKXfge/kXGfmWDgasdqCYIrYhS7aqgHDKlfD+wyGYsPgQVtCZ rHFmfCZEkGbGcMbHaGt4HIYYIUI5ENMdX7v+9tj3aSvaTBhxqwq6/dCusoUbrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751022791; 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=J3mjlr8wNr8y3Bh70iNmRIFiu8EG+OkB6k9EMLOzBQo=; b=x2InJgTev/xf0F3ueZn/vRevUVPIjAZ6calEh95+v58b11CkDRLoZl8U7aPpaSDXbxRTgw gIvbArPavAl12HdnFXmRZvh+KAm9al0TZRcClVqd3tSe0zQocU3l+gLXwbqiuOrCEVOHO/ OOuoRW1rZefvSuVcwv/w9auhofxXOa9ykYCxgqzsN0ssnp3o/nWkeKb7snGlXZ13FFrck2 1FOv3L7Uaa1U/RVt+n2Huc358YAQZ3hN1ZLqNuL4yRgkzv/OeI+Wy/3j6Lckg/jDWZFfKY P3FqVS5rWD9OoFktNx5t9EffNtOKpwSYJ18IkvT9lBbvfO7qnI+YnU265bH5Ig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751022791; a=rsa-sha256; cv=none; b=Dxn0EU71cE+gOMZfMK34ClB4GdY8z8ir6xkL7ijPF2RJADzrzSURBcYD5eyQ96aXnVUdYy OvgbBin5wzo5aGwvMzjU+8sGiQ9X0viaK6lF5BIjzWCIXWnECFTgYh3lnZiQ1RI79cLpW0 GgEKr0zLt1wXT/KrfHGRybeNpJqPasgv2ohdskb8viV/FRII/6SdwFWfGNlLVQWWcLOx8n /mJJ48ueWCxuyaaECNBxSQUsmFuRuzGzCSEacQLP7y5KU5s799BE639PFKmdaNosq1YSr0 IZxEcDHPOUOyqRR8rqKNTFyHwjw7toIQ7AVEqgvZi+DnTAEiHfla7xyHgutSeQ== 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 4bTCbC2hqMzmLX; Fri, 27 Jun 2025 11:13:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 55RBDBf5098903; Fri, 27 Jun 2025 11:13:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55RBDBoF098901; Fri, 27 Jun 2025 11:13:11 GMT (envelope-from git) Date: Fri, 27 Jun 2025 11:13:11 GMT Message-Id: <202506271113.55RBDBoF098901@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 32f793e22976 - main - pf tests: test handling of ICMP echo requests with the same ID List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 32f793e2297619e1cb835c0938396ab6f6d0a6b3 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=32f793e2297619e1cb835c0938396ab6f6d0a6b3 commit 32f793e2297619e1cb835c0938396ab6f6d0a6b3 Author: Kristof Provost AuthorDate: 2025-06-27 08:18:18 +0000 Commit: Kristof Provost CommitDate: 2025-06-27 11:12:50 +0000 pf tests: test handling of ICMP echo requests with the same ID We previously broke this, so add a test to prevent regressions. Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/icmp.py | 77 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tests/sys/netpfil/pf/icmp.py b/tests/sys/netpfil/pf/icmp.py index 232c56a23dbf..83096886691e 100644 --- a/tests/sys/netpfil/pf/icmp.py +++ b/tests/sys/netpfil/pf/icmp.py @@ -175,3 +175,80 @@ class TestICMP(VnetTestTemplate): self.check_icmp_echo(sp, 128) self.check_icmp_echo(sp, 1464) self.check_icmp_echo(sp, 1468) + +class TestICMP_NAT(VnetTestTemplate): + REQUIRED_MODULES = [ "pf" ] + TOPOLOGY = { + "vnet1": {"ifaces": ["if1"]}, + "vnet2": {"ifaces": ["if1", "if2"]}, + "vnet3": {"ifaces": ["if2"]}, + "if1": {"prefixes4": [("192.0.2.2/24", "192.0.2.1/24")]}, + "if2": {"prefixes4": [("198.51.100.1/24", "198.51.100.2/24")]}, + } + + def vnet2_handler(self, vnet): + ifname = vnet.iface_alias_map["if1"].name + if2name = vnet.iface_alias_map["if2"].name + + ToolsHelper.print_output("/sbin/pfctl -e") + ToolsHelper.pf_rules([ + "set reassemble yes", + "set state-policy if-bound", + "nat on %s inet from 192.0.2.0/24 to any -> (%s)" % (if2name, if2name), + "block", + "pass inet proto icmp icmp-type echoreq", + ]) + + ToolsHelper.print_output("/sbin/sysctl net.inet.ip.forwarding=1") + ToolsHelper.print_output("/sbin/pfctl -x loud") + + def vnet3_handler(self, vnet): + ifname = vnet.iface_alias_map["if2"].name + ToolsHelper.print_output("/sbin/ifconfig %s inet alias 198.51.100.3/24" % ifname) + + @pytest.mark.require_user("root") + @pytest.mark.require_progs(["scapy"]) + def test_id_conflict(self): + """ + Test ICMP echo requests with the same ID from different clients. + Windows does this, and it can confuse pf. + """ + ifname = self.vnet.iface_alias_map["if1"].name + ToolsHelper.print_output("/sbin/route add default 192.0.2.1") + ToolsHelper.print_output("/sbin/ifconfig %s inet alias 192.0.2.3/24" % ifname) + + ToolsHelper.print_output("/sbin/ping -c 1 192.0.2.1") + ToolsHelper.print_output("/sbin/ping -c 1 198.51.100.1") + ToolsHelper.print_output("/sbin/ping -c 1 198.51.100.2") + ToolsHelper.print_output("/sbin/ping -c 1 198.51.100.3") + + # Import in the correct vnet, so at to not confuse Scapy + import scapy.all as sp + + # Address one + packet = sp.IP(src="192.0.2.2", dst="198.51.100.2", flags="DF") \ + / sp.ICMP(type='echo-request', id=42) \ + / sp.raw(bytes.fromhex('f0') * 16) + + p = sp.sr1(packet, timeout=3) + p.show() + ip = p.getlayer(sp.IP) + icmp = p.getlayer(sp.ICMP) + assert ip + assert icmp + assert ip.dst == "192.0.2.2" + assert icmp.id == 42 + + # Address one + packet = sp.IP(src="192.0.2.3", dst="198.51.100.2", flags="DF") \ + / sp.ICMP(type='echo-request', id=42) \ + / sp.raw(bytes.fromhex('f0') * 16) + + p = sp.sr1(packet, timeout=3) + p.show() + ip = p.getlayer(sp.IP) + icmp = p.getlayer(sp.ICMP) + assert ip + assert icmp + assert ip.dst == "192.0.2.3" + assert icmp.id == 42