From nobody Tue Nov 07 15:47:24 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 4SPszd0K3yz50X11; Tue, 7 Nov 2023 15:47:25 +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 4SPszc5wSvz3JyS; Tue, 7 Nov 2023 15:47:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699372044; 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=MmGBjYJeXsToYwIFjVPc0HFxhwP90AA5K31thIWbamk=; b=eN3mLbhcFbjQvUT8Ks2lhBXxWksTytt2r9vJzFaeXtzY/DJxJDJfA39VZ2RFbOEGYbGicT G/R1o9VoGitTIJ7L0A375XAH71WpfkbxhfrG4YTr+EaLVq/+dzddaAuTR6QDlYrptW8W43 MBPaA67r17KSokzldUON/WKLHo8SCRZbDvoCBZeCTwcHhuugpR1GDUpghgrA1V6mFV024/ pW2jnuflnmjpYqDBIXsEnovz27om6pK911mLAKPlFp753WgXDNpK9vUVMIgT9QPpyy4P18 Q8ooewc/GpeodG2yD51IOWJ8dk1Yn4lr7cMrcACkE8a6GEHxjXGNd7Bxlwod9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699372044; 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=MmGBjYJeXsToYwIFjVPc0HFxhwP90AA5K31thIWbamk=; b=rmhwUdTfJXC+z+4pBvBPz+XiC4KX5yUAjNhWAW+HqTImj/90EZn5ng4o8ZvIDwVrL2M319 s5Tz7ekE92UcKfBoJHgdzTQPAbo+iL5humY5Xzvky7LO0MVxr6ovdyUJ9LyA4FrZ8y4R6r B9yOe7tem7k7RLUMUmymXQ+stUmjFtlNUo72SoSOdGiK1pB4biH1HVxbW5fIzCJm+2/+aj ZGm0LXFBsKQVFYHsZlWWlsazmJOAoXMNrGeG4dKKzgKAIxFOUfkoTdeEgQLYCBSxPdFzPX qcAoeiyw0A60unoEdtmEGAOCktCkNTrYA3aReC9YhDE6+0hAlLYJSzyuwMomYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699372044; a=rsa-sha256; cv=none; b=V7fD3OHVb0my4KRSd+/tpQ2lsHd9KY43TLmZnkrQw0CZgT0kzBswFr+2BjWHSZMr5dsjZi T0iDRAkrAjw4zRD32lnuOklecVToKnxBP2oy3/GlCYo9+HiPTElD+nd0pFXcl/ZA4F9HjF kjDvBvjarWvFGzzWPBySStaZiJGQy/j9oadQ4yt0znCAz8H7cJQygjFVmBgDC2IwU4EkJG RfZoephEO4pLFSKznR1vamrddT6LhT3xOHRWBW8VpDnZjyz07LK/tQ2LU2Kt2W4yt7uiwP CCfSYfY4dJHO2kLIoCV5NCLlch+kT1KTVAQg5iRw28HT1bQPtJUgNTDtRuUTbg== 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 4SPszc4xD0zwQ9; Tue, 7 Nov 2023 15:47:24 +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 3A7FlOw5069925; Tue, 7 Nov 2023 15:47:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A7FlOnh069922; Tue, 7 Nov 2023 15:47:24 GMT (envelope-from git) Date: Tue, 7 Nov 2023 15:47:24 GMT Message-Id: <202311071547.3A7FlOnh069922@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: dee71d8e6eab - stable/13 - pf tests: ensure that we generate all permutations for SCTP multihome 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: dee71d8e6eab162922d9fccf27511d05eef24cbb Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=dee71d8e6eab162922d9fccf27511d05eef24cbb commit dee71d8e6eab162922d9fccf27511d05eef24cbb Author: Kristof Provost AuthorDate: 2023-10-10 09:56:15 +0000 Commit: Kristof Provost CommitDate: 2023-11-07 15:25:02 +0000 pf tests: ensure that we generate all permutations for SCTP multihome The initial multihome implementation was a little simplistic, and failed to create all of the required states. Given a client with IP 1 and 2 and a server with IP 3 and 4 we end up creating states for 1 - 3 and 2 - 3, as well as 3 - 1 and 4 - 1, but not for 2 - 4. Check for this. MFC after: 1 week Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D42362 (cherry picked from commit 483d5c4075e06e52d5daa23aef2b4f4a2eb64443) --- tests/sys/netpfil/pf/sctp.py | 61 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tests/sys/netpfil/pf/sctp.py b/tests/sys/netpfil/pf/sctp.py index 5e6dca5dd64b..5db52dd993f2 100644 --- a/tests/sys/netpfil/pf/sctp.py +++ b/tests/sys/netpfil/pf/sctp.py @@ -360,6 +360,37 @@ class TestSCTP(VnetTestTemplate): states = ToolsHelper.get_output("/sbin/pfctl -ss") assert re.search(r"all sctp 192.0.2.1:.*192.0.2.3:1234.*SHUTDOWN", states) + + @pytest.mark.require_user("root") + def test_permutation(self): + # Test that we generate all permutations of src/dst addresses. + # Assign two addresses to each end, and check for the expected states + srv_vnet = self.vnet_map["vnet2"] + + ifname = self.vnet_map["vnet1"].iface_alias_map["if1"].name + ToolsHelper.print_output("/sbin/ifconfig %s inet alias 192.0.2.4/24" % ifname) + + ToolsHelper.print_output("/sbin/pfctl -e") + ToolsHelper.pf_rules([ + "block proto sctp", + "pass inet proto sctp to 192.0.2.0/24"]) + + # Sanity check, we can communicate with the primary address. + client = SCTPClient("192.0.2.3", 1234) + client.send(b"hello", 0) + rcvd = self.wait_object(srv_vnet.pipe) + print(rcvd) + assert rcvd['ppid'] == 0 + assert rcvd['data'] == "hello" + + # Check that we have a state for 192.0.2.3 and 192.0.2.2 to 192.0.2.1, but also to 192.0.2.4 + states = ToolsHelper.get_output("/sbin/pfctl -ss") + print(states) + assert re.search(r"all sctp 192.0.2.1:.*192.0.2.3:1234", states) + assert re.search(r"all sctp 192.0.2.1:.*192.0.2.2:1234", states) + assert re.search(r"all sctp 192.0.2.4:.*192.0.2.3:1234", states) + assert re.search(r"all sctp 192.0.2.4:.*192.0.2.2:1234", states) + class TestSCTPv6(VnetTestTemplate): REQUIRED_MODULES = ["sctp", "pf"] TOPOLOGY = { @@ -476,3 +507,33 @@ class TestSCTPv6(VnetTestTemplate): # Verify that the state is closing states = ToolsHelper.get_output("/sbin/pfctl -ss") assert re.search(r"all sctp 2001:db8::1\[.*2001:db8::3\[1234\].*SHUTDOWN", states) + + @pytest.mark.require_user("root") + def test_permutation(self): + # Test that we generate all permutations of src/dst addresses. + # Assign two addresses to each end, and check for the expected states + srv_vnet = self.vnet_map["vnet2"] + + ifname = self.vnet_map["vnet1"].iface_alias_map["if1"].name + ToolsHelper.print_output("/sbin/ifconfig %s inet6 alias 2001:db8::4/64" % ifname) + + ToolsHelper.print_output("/sbin/pfctl -e") + ToolsHelper.pf_rules([ + "block proto sctp", + "pass inet6 proto sctp to 2001:db8::0/64"]) + + # Sanity check, we can communicate with the primary address. + client = SCTPClient("2001:db8::3", 1234) + client.send(b"hello", 0) + rcvd = self.wait_object(srv_vnet.pipe) + print(rcvd) + assert rcvd['ppid'] == 0 + assert rcvd['data'] == "hello" + + # Check that we have a state for 2001:db8::3 and 2001:db8::2 to 2001:db8::1, but also to 2001:db8::4 + states = ToolsHelper.get_output("/sbin/pfctl -ss") + print(states) + assert re.search(r"all sctp 2001:db8::1\[.*2001:db8::2\[1234\]", states) + assert re.search(r"all sctp 2001:db8::1\[.*2001:db8::3\[1234\]", states) + assert re.search(r"all sctp 2001:db8::4\[.*2001:db8::2\[1234\]", states) + assert re.search(r"all sctp 2001:db8::4\[.*2001:db8::3\[1234\]", states)