From nobody Fri Aug 11 12:13:35 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 4RMjPW3bNHz4q0yc; Fri, 11 Aug 2023 12:13:35 +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 4RMjPW32R2z3gg8; Fri, 11 Aug 2023 12:13:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691756015; 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=k7yfR60hg9iuomtn+pd8pu3fAixI2kD2toRVy0keB9g=; b=m9XLx2ON3us9m+hX88hfTy3pghw5G3MISdB1PBC0/xhESGI8E6jZ8C+OVDVxl+03Av4SNb hWTHhMFeUQerrQWJ8r+sNWFLXob137YEPLvEyx7Y9DP7fG2SSvWIrL/qV8nEzUzWMJ8PT8 a+F1BWkrMUG0cKIdd7HVqrZHzZitFQa2AxPv4jkS+WblylYJFAc4qT5N/UpRzBFp+nUdDb RrmfhBQ0pfLEkFuJAflqZzshHP4sh9jOk5MuvlwaSLTn2V6FlsmSxlvTuM06iNSipTxKO3 cZeC+y//5ncpcKgQnEW97MFUtDKzcchiBsuSu/4x3TK9azrZD8LYeNp/0dZyIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691756015; 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=k7yfR60hg9iuomtn+pd8pu3fAixI2kD2toRVy0keB9g=; b=xHDrdLikYNKl8+H5WH5YBbUagM32WlH2s3O/8vP+i5445bKJ+rjsNiKU0xOYVZh76K/Chi I6nOMHC5gqxikPLURvS/kqHnovrRwJ7mnaB2ZrBh3IXUCa+Ko4Y2m4lBjhWwxnSWO4NLlG Hi+GGPQdsdCsEv0xGPFSvVPsY1MEazKAbG7cfhLkfg+eQclgs9S2AAbk0a6BRIy0CNjIjT qEFajA0hx7eIbaBuPMrRdcfdw/DnJ7kRqEQHGi9Ju1ORdsm2/hg2s17YllnZe9m4EwtZoZ GXAOXZZg9L2TS/d51Ge1LTni52uk0CH/QqBH1yw2kTCcyRO7QUz3ejgy6P1PqA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691756015; a=rsa-sha256; cv=none; b=ss1k4KRW0/Exa43gNp2WeDk3TbvSFSfUhFougHcGnKZtk+QpOBSrHmCSGaEVRxzxWSBVFf s9o0HeonE6MknJH7vN9tapOb/b/9su1T+j3Zo8CTa5v/YXvI/TBEaXqzTgISGVLrAQTxuf Wz9CS6lIvqMa8kucvLjDO5+cUHdjmFU8nN6JOsIjPdHn+ej+aiwtArgPdzEWjL+liXWK+m zZ1PIbTUvzppIeVL263FkOI9chESmQCKrXCi+LP+RODr7lbWAoOxvJdjVRZEB+cd53V10s prkC/tOYfvW9N7bEcAKMxtPf0sLhsAci0IK0bvXMMpQEwLXhvNinaUA9tyHGLw== 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 4RMjPW24JhzdgW; Fri, 11 Aug 2023 12:13:35 +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 37BCDZ9j008628; Fri, 11 Aug 2023 12:13:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37BCDZXV008625; Fri, 11 Aug 2023 12:13:35 GMT (envelope-from git) Date: Fri, 11 Aug 2023 12:13:35 GMT Message-Id: <202308111213.37BCDZXV008625@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: dc9da87bd334 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: dc9da87bd334906375eb35c3adaceaf0b6b4f2e3 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=dc9da87bd334906375eb35c3adaceaf0b6b4f2e3 commit dc9da87bd334906375eb35c3adaceaf0b6b4f2e3 Author: Kristof Provost AuthorDate: 2023-05-31 19:45:29 +0000 Commit: Kristof Provost CommitDate: 2023-08-11 12:13:09 +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 (cherry picked from commit 2d42aa9d7ba64fe7166f76234a595637f0c212cf) --- 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" }