From nobody Fri Jul 21 10:32:41 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 4R6m8v4gh4z4pG7N; Fri, 21 Jul 2023 10:32:42 +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 4R6m8n706jz3qSB; Fri, 21 Jul 2023 10:32:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689935562; 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=BByRj/jWOVSrRxNzc/OEiA2UzjTIAb7lCtVvyGqVTxs=; b=ffdtnAq7a9wAt+GYUILJYbMNpVMXS7gNXsPJrwDyTnwL6EQD7Qb3rOCVKvCo5q20o3cHJ4 UJ3sQ5a+4TUIwgfO3bC+cDNsMGh9cBa8uHjpdNNLXkJCPAa8ZK5n22a58VrOsE/PGSPVUN DY+LRs5vskiOxjaWYd4gnIlLn/JIDceelus+OZCDhP6yJhgH6R5CcXvJ5KnvVaZKiYGRqu OS/9myBPEB8984YI5Kb7YXlpsDHxz+9djgWtJ5hFWrc5mkEk63Kgo2EShW0QCVdvxkTKm6 r5LvwR1xzA9kcM9AxO9X09d3d2q4TPLp066GjJ2gmzybfNv79otkzLyCZ/qULA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689935562; 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=BByRj/jWOVSrRxNzc/OEiA2UzjTIAb7lCtVvyGqVTxs=; b=YrP+9yhbSDED2q8wIi6Wf62/btocXu4TAJug+2smNPLqFDJ2z6XeWfQgm02qvayr4rbhcb PaY3nLt31lPaGEXrLSyeLSXqmDEUKXskwbvisje9CLr4t4dKsW3ahBFPFvlAY640BJXrZP rkkN/UOvPoGq9+23TZi54Wa2+qzkV/MIcGoSiA9M6+vzQuW+/gLnvnduuSadI7Cyjy0o1D glU7K6Mys0V0mELecmeZtQzKYbRHrzF9oh4UAneQk1P/3QE0r+Rrg9r8rg2qQSJIx93mCQ EekBDtpcmV1IjTxEaTknnh5vlKrewj6PxI3DE//uM0+KhZyRiMlO4TA1rM1Egw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689935562; a=rsa-sha256; cv=none; b=gejsZ8wDG6+tVwQefSSYLfQ49mqe9IQSuL66sVi69MTM77PkgTV7I8U3crNZTOCOAR6QuG CAozMHzihEGcU3IQfp8B9j5ujkF1bPABjfU2EpeaZYFZcL72wRDFSDS8ngiV6Rz5WPuOXD vClsVykBmx631ZIVBC5MHcYV52rcMVz+IqNEs8DUPqUE/n6oxP0WnSNzZDkEIojM6ZjH8u rs1URgEEY1LISKtM5JnyBG+MvbntaMNgnteCghyJs9SGZQ80erM4+di6czqbRuJb0AvhAf k2dLDnstWurgOsRRVJqn74bzq+pCNY46dkXJ7pFM25eSQ96imeatqV40KBrQrA== 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 4R6m8n565xz18Tb; Fri, 21 Jul 2023 10:32:41 +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 36LAWf5A010573; Fri, 21 Jul 2023 10:32:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36LAWfMC010572; Fri, 21 Jul 2023 10:32:41 GMT (envelope-from git) Date: Fri, 21 Jul 2023 10:32:41 GMT Message-Id: <202307211032.36LAWfMC010572@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: 2d42aa9d7ba6 - main - pf tests: test SCTP 'return' 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/main X-Git-Reftype: branch X-Git-Commit: 2d42aa9d7ba64fe7166f76234a595637f0c212cf Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2d42aa9d7ba64fe7166f76234a595637f0c212cf commit 2d42aa9d7ba64fe7166f76234a595637f0c212cf Author: Kristof Provost AuthorDate: 2023-05-31 19:45:29 +0000 Commit: Kristof Provost CommitDate: 2023-07-21 10:32:18 +0000 pf tests: test SCTP 'return' Ensure that we send a correct abort message for 'block return' rules. Test this by validating that nc doesn't sit around waiting for a connection. It should give up immediately when it receives the abort. MFC after: 3 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D40865 --- tests/sys/netpfil/pf/sctp.sh | 117 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/tests/sys/netpfil/pf/sctp.sh b/tests/sys/netpfil/pf/sctp.sh index 5064fe316e5e..59697ad37be2 100644 --- a/tests/sys/netpfil/pf/sctp.sh +++ b/tests/sys/netpfil/pf/sctp.sh @@ -182,9 +182,126 @@ basic_v6_cleanup() pft_cleanup } +atf_test_case "abort_v4" "cleanup" +abort_v4_head() +{ + atf_set descr 'Test sending ABORT messages' + atf_set require.user root +} + +abort_v4_body() +{ + sctp_init + + j="sctp:abort_v4" + epair=$(vnet_mkepair) + + vnet_mkjail ${j}a ${epair}a + vnet_mkjail ${j}b ${epair}b + + jexec ${j}a ifconfig ${epair}a 192.0.2.1/24 up + jexec ${j}b ifconfig ${epair}b 192.0.2.2/24 up + + # Sanity check + atf_check -s exit:0 -o ignore \ + jexec ${j}a ping -c 1 192.0.2.2 + + jexec ${j}a pfctl -e + pft_set_rules ${j}a \ + "block return in proto sctp to port 1234" + + echo "foo" | jexec ${j}a nc --sctp -N -l 1234 & + + # Wait for the server to start + sleep 1 + + # If we get the abort we'll exit immediately, if we don't timeout will + # stop nc. + out=$(jexec ${j}b timeout 3 nc --sctp -N 192.0.2.1 1234) + if [ $? -eq 124 ]; then + atf_fail 'Abort not received' + fi + if [ "$out" == "foo" ]; then + atf_fail "block failed entirely" + fi + + # Without 'return' we will time out. + pft_set_rules ${j}a \ + "block in proto sctp to port 1234" + + out=$(jexec ${j}b timeout 3 nc --sctp -N 192.0.2.1 1234) + if [ $? -ne 124 ]; then + atf_fail 'Abort sent anyway?' + fi +} + +abort_v4_cleanup() +{ + pft_cleanup +} + +atf_test_case "abort_v6" "cleanup" +abort_v4_head() +{ + atf_set descr 'Test sending ABORT messages over IPv6' + atf_set require.user root +} + +abort_v6_body() +{ + sctp_init + + j="sctp:abort_v6" + epair=$(vnet_mkepair) + + vnet_mkjail ${j}a ${epair}a + vnet_mkjail ${j}b ${epair}b + + jexec ${j}a ifconfig ${epair}a inet6 2001:db8::a/64 no_dad + jexec ${j}b ifconfig ${epair}b inet6 2001:db8::b/64 no_dad + + # Sanity check + atf_check -s exit:0 -o ignore \ + jexec ${j}a ping -6 -c 1 2001:db8::b + + jexec ${j}a pfctl -e + pft_set_rules ${j}a \ + "block return in proto sctp to port 1234" + + echo "foo" | jexec ${j}a nc -6 --sctp -N -l 1234 & + + # Wait for the server to start + sleep 1 + + # If we get the abort we'll exit immediately, if we don't timeout will + # stop nc. + out=$(jexec ${j}b timeout 3 nc --sctp -N 2001:db8::a 1234) + if [ $? -eq 124 ]; then + atf_fail 'Abort not received' + fi + if [ "$out" == "foo" ]; then + atf_fail "block failed entirely" + fi + + # Without 'return' we will time out. + pft_set_rules ${j}a \ + "block in proto sctp to port 1234" + + out=$(jexec ${j}b timeout 3 nc --sctp -N 2001:db8::a 1234) + if [ $? -ne 124 ]; then + atf_fail 'Abort sent anyway?' + fi +} + +abort_v4_cleanup() +{ + pft_cleanup +} atf_init_test_cases() { atf_add_test_case "basic_v4" atf_add_test_case "basic_v6" + atf_add_test_case "abort_v4" + atf_add_test_case "abort_v6" }