From nobody Thu May 8 13:10:41 2025 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 4ZtXYs6pMLz5wJZd; Thu, 08 May 2025 13:10:41 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZtXYs4X5Jz3LwM; Thu, 08 May 2025 13:10:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746709841; 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=hpxsGKH79Rscomje3xqSQFH3mB1Pamg2DF6m10ZDsuU=; b=l/87d72AbgBfnORHaLfk/XRgyVNIojLFIRL6HFVG1uiOZfiGTy80oDfErsd5xACanqf6A3 XugPJ6PeKiJLe5h/3S3cXzFv0RQq/tVH4+++bU0zHJOUwxDnW9fG6wIFrl6z8LsKdUm7LD 6qBSz4og05Az/Bup1S5/HJ6T0KPzYaF6OXgMRvDGBJtupsbQ4LRbrQP48CJTi717LcfzGY 0hcbPf59lO4IxPRXkGW3eGiTi50fOH0aW4YsFJHyH1pzo1salI97ErNZYi5x817O3fah7y fL5/o4I0Hjdv1z0LZPHL3QV+FiTHkyfQBgeV7djwmwyXQptYsVS9ZjvImw+WlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746709841; 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=hpxsGKH79Rscomje3xqSQFH3mB1Pamg2DF6m10ZDsuU=; b=kF/yIGcZSCEPIwexDelb+iqmch0djFrCFYE7Sq9sFNcfQt/8QBcKive4Iiz5twjLfx0QHh r1tKPkbAz/4NLsnMaFYaI/fU7ixF4DDwyFc5n1FuPjZnHvUr2vugtqW1+Lt5ty+teQpQC4 GMPgrCha2WS+vrS+bvy6IB3Zq66u6LUhJbThivI95nLLM+g83Y8VezwbPkurwpKa92oPnY K73+4Cqc8k4yj8lchJ2F+mk31yROdgjFWi3nRrtf8CX3bJEmW7coXeDvFQBiBm9O9+JmSb MFv4fr2sdGS2mCsQKZg5XR+i3frqzo6oiNMpuLSt+r9oCq2cl9szQAv37SiRkA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746709841; a=rsa-sha256; cv=none; b=UyUTyMBcgGh2s4KGO+S32cWXdlD0p75c8dulNkNnf7umXMZLHNPqXXxDfVIF9BzBNl7c/b 8WacuXgEoVNVgcB+3BSDNDGwM5SpxSxOhAPn/gT1LT/rT2bih7N764ldc138fYS9/x9Er4 hW2vSh7FViOz/mw8ojiCLMkFgM+0cRGgDAhs+yMbS2bJdpOOtCHfuyqNWc1FnaC547aGbV lgYsgcSnEDJqHq1LYmcVHlaKLTbLzpT7Kt67k1u/m7zMweed81VNqqXH7gGLBdxuquE4id uGC9R+ObL1bFnO5rA8VUV01NMKFKR0ppGcIbxJXfOF4dDVOSk4zhBkgmDmOmMQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4ZtXYs43M6z1lh; Thu, 08 May 2025 13:10:41 +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 548DAfWI047101; Thu, 8 May 2025 13:10:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 548DAfQ4047098; Thu, 8 May 2025 13:10:41 GMT (envelope-from git) Date: Thu, 8 May 2025 13:10:41 GMT Message-Id: <202505081310.548DAfQ4047098@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: 681a04dbda0e - main - pf tests: verify we accept exactly one hop-by-hop header 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 681a04dbda0e06cccf2ecc1ab8cac1e9e2be78d2 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=681a04dbda0e06cccf2ecc1ab8cac1e9e2be78d2 commit 681a04dbda0e06cccf2ecc1ab8cac1e9e2be78d2 Author: Kristof Provost AuthorDate: 2025-05-06 10:07:23 +0000 Commit: Kristof Provost CommitDate: 2025-05-08 13:10:25 +0000 pf tests: verify we accept exactly one hop-by-hop header Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/frag6.py | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tests/sys/netpfil/pf/frag6.py b/tests/sys/netpfil/pf/frag6.py index c9a71f73c0cf..de14fec528fd 100644 --- a/tests/sys/netpfil/pf/frag6.py +++ b/tests/sys/netpfil/pf/frag6.py @@ -97,6 +97,96 @@ class TestFrag6(VnetTestTemplate): sp.send(pkts, inter = 0.1) +class TestFrag6HopHyHop(VnetTestTemplate): + REQUIRED_MODULES = ["pf"] + TOPOLOGY = { + "vnet1": {"ifaces": ["if1", "if2"]}, + "vnet2": {"ifaces": ["if1", "if2"]}, + "if1": {"prefixes6": [("2001:db8::1/64", "2001:db8::2/64")]}, + "if2": {"prefixes6": [("2001:db8:666::1/64", "2001:db8:1::2/64")]}, + } + + def vnet2_handler(self, vnet): + ifname = vnet.iface_alias_map["if1"].name + ToolsHelper.print_output("/sbin/sysctl net.inet6.ip6.forwarding=1") + ToolsHelper.print_output("/usr/sbin/ndp -s 2001:db8:1::1 00:01:02:03:04:05") + ToolsHelper.print_output("/sbin/pfctl -e") + ToolsHelper.print_output("/sbin/pfctl -x loud") + ToolsHelper.pf_rules([ + "scrub fragment reassemble min-ttl 10", + "pass", + ]) + + @pytest.mark.require_user("root") + @pytest.mark.require_progs(["scapy"]) + def test_hop_by_hop(self): + "Verify that we reject non-first hop-by-hop headers" + if1 = self.vnet.iface_alias_map["if1"].name + if2 = self.vnet.iface_alias_map["if2"].name + ToolsHelper.print_output("/sbin/route add -6 default 2001:db8::2") + ToolsHelper.print_output("/sbin/ping6 -c 1 2001:db8:1::2") + + # Import in the correct vnet, so at to not confuse Scapy + import scapy.all as sp + + # A hop-by-hop header is accepted if it's the first header + pkt = sp.IPv6(src="2001:db8::1", dst="2001:db8:1::1") \ + / sp.IPv6ExtHdrHopByHop() \ + / sp.ICMPv6EchoRequest(data=sp.raw(bytes.fromhex('f0') * 30)) + pkt.show() + + # Delay the send so the sniffer is running when we transmit. + s = DelayedSend(pkt) + + replies = sp.sniff(iface=if2, timeout=3) + found = False + for p in replies: + p.show() + ip6 = p.getlayer(sp.IPv6) + hbh = p.getlayer(sp.IPv6ExtHdrHopByHop) + icmp6 = p.getlayer(sp.ICMPv6EchoRequest) + + if not ip6 or not icmp6: + continue + assert ip6.src == "2001:db8::1" + assert ip6.dst == "2001:db8:1::1" + assert hbh + assert icmp6 + found = True + assert found + + # A hop-by-hop header causes the packet to be dropped if it's not the + # first extension header + pkt = sp.IPv6(src="2001:db8::1", dst="2001:db8:1::1") \ + / sp.IPv6ExtHdrFragment(offset=0, m=0) \ + / sp.IPv6ExtHdrHopByHop() \ + / sp.ICMPv6EchoRequest(data=sp.raw(bytes.fromhex('f0') * 30)) + pkt2 = sp.IPv6(src="2001:db8::1", dst="2001:db8:1::1") \ + / sp.ICMPv6EchoRequest(data=sp.raw(bytes.fromhex('f0') * 30)) + + # Delay the send so the sniffer is running when we transmit. + ToolsHelper.print_output("/sbin/ping6 -c 1 2001:db8:1::2") + + s = DelayedSend([ pkt2, pkt ]) + replies = sp.sniff(iface=if2, timeout=10) + found = False + for p in replies: + # Expect to find the packet without the hop-by-hop header, not the + # one with + p.show() + ip6 = p.getlayer(sp.IPv6) + hbh = p.getlayer(sp.IPv6ExtHdrHopByHop) + icmp6 = p.getlayer(sp.ICMPv6EchoRequest) + + if not ip6 or not icmp6: + continue + assert ip6.src == "2001:db8::1" + assert ip6.dst == "2001:db8:1::1" + assert not hbh + assert icmp6 + found = True + assert found + class TestFrag6_Overlap(VnetTestTemplate): REQUIRED_MODULES = ["pf"] TOPOLOGY = {