From nobody Fri Jul 21 10:32:44 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 4R6m8x44wkz4pFxm; Fri, 21 Jul 2023 10:32:47 +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 4R6m8r6JgHz3qGC; Fri, 21 Jul 2023 10:32:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689935564; 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=qz2gAS2Dd4BefHhpjvC2ORfIWZbakjKbFjsqe6W46ic=; b=u2SOannug5pzaA8d3mMSdSDTG/4vYUqOipygWwum6yPp+o7DX6DxKPPiBJ6eaGcfCjfI2z ixs7Q9dPOdSAOCvgBftqk+oc1g4NZlxfPPVU6E26TLWQs84FUoHAW4DP+2+iv3gS4ma8qQ z4S6vKIKGANZK2UA0DR8zYvBR/XTikjKqp5xV//RZ0X17Xzh65He4WdONJWX/5pj0baCAO bQYHtUXWEDyu1Z55SlIghWw8S3mIo+FF4bmedYqzlNWwGCPRfvjKLbAPxshJc8kWQQY2qg 50gyVjm2gNr/CMbLDxw1BeSfBRqFCKGyd7FeO35g0bIfVgd0vjXs2zXgQ5QZOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689935564; 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=qz2gAS2Dd4BefHhpjvC2ORfIWZbakjKbFjsqe6W46ic=; b=GYxPdny2+t5alB4O/UWgZ5zGXFelDyTb2QxWHUvqsVku10kP2zW5xpqVxdkVg7+Ml663KC Di8g9lCBLUbY4KwK/bHlTx5wuN93tquwyEkZOIYPEBiwCXPQ5WzGf+4vQAGbQNa8RFH5Us m6hKFlFHoBw+QlXCvvtjWWgYWYxdhQfv38J3/wN2qmEDdYbx94biwwT+mUJ1CocnZDwwOq WmMAIQCAvscs2Pr8fpNWVgM1QnUEFrsK5rtAjBOuBGW/znOAiXOgmDJapwhrDjz314yUgJ 7m74hpj+P4XVMKaQJZC1x7UyCipLnMlBCHkHOiA5M0WnyhzhVFfQ4h/0xqUhSw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689935564; a=rsa-sha256; cv=none; b=aNYwp3SHUibTezJucqsaqAp/+APRXW9Dzstsu5Rl1huevdFgHPl9/edQzcLaUX0G6eXWtu 1YDk8UMIQ11pGFbu/1wn71NpYr4VH8wKZnXhT/u3l4vyhrXQJXIXvHgOU1t75OlpaJd+/R x1MnekW8omjLcd0v/fppQqWS2uTKvdxEvek2EuRKtg24ZxLlaPOlZcRx2qHhH8UPuDxADi w1+/23sgrXB7S3JxBn5dvqmwfV50USIx2XvTC9hUF4eRuSGTA9+5pP+3nMzNfqL+XbyYOV Bk7ABcih/ZAwi1KEWtTEMFdIOZDRPcS3g4Vwhty0hsFOOC9h0xdhTtmoqRhFRw== 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 4R6m8r4ydBz18S0; Fri, 21 Jul 2023 10:32:44 +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 36LAWi9E010635; Fri, 21 Jul 2023 10:32:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36LAWivD010634; Fri, 21 Jul 2023 10:32:44 GMT (envelope-from git) Date: Fri, 21 Jul 2023 10:32:44 GMT Message-Id: <202307211032.36LAWivD010634@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: 4369a57514f2 - main - pf tests: test 'rdr' for SCTP 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: 4369a57514f227c989d4de87d1ce54470279ba41 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4369a57514f227c989d4de87d1ce54470279ba41 commit 4369a57514f227c989d4de87d1ce54470279ba41 Author: Kristof Provost AuthorDate: 2023-06-01 16:03:07 +0000 Commit: Kristof Provost CommitDate: 2023-07-21 10:32:19 +0000 pf tests: test 'rdr' for SCTP Explicitly test that we cannot change the port number with rdr. That's not a desireable feature on SCTP, because it could break multihomed connections. MFC after: 3 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D40868 --- tests/sys/netpfil/pf/sctp.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/sys/netpfil/pf/sctp.sh b/tests/sys/netpfil/pf/sctp.sh index 659c11c62113..2c736017f9fa 100644 --- a/tests/sys/netpfil/pf/sctp.sh +++ b/tests/sys/netpfil/pf/sctp.sh @@ -402,6 +402,73 @@ nat_v6_cleanup() pft_cleanup } +atf_test_case "rdr_v4" "cleanup" +rdr_v4_head() +{ + atf_set descr 'Test rdr SCTP over IPv4' + atf_set require.user root +} + +rdr_v4_body() +{ + sctp_init + + j="sctp:rdr_v4" + epair_c=$(vnet_mkepair) + epair_srv=$(vnet_mkepair) + + vnet_mkjail ${j}srv ${epair_srv}a + vnet_mkjail ${j}gw ${epair_srv}b ${epair_c}a + vnet_mkjail ${j}c ${epair_c}b + + jexec ${j}srv ifconfig ${epair_srv}a 198.51.100.1/24 up + # No default route in srv jail, to ensure we're NAT-ing + jexec ${j}gw ifconfig ${epair_srv}b 198.51.100.2/24 up + jexec ${j}gw ifconfig ${epair_c}a 192.0.2.1/24 up + jexec ${j}gw sysctl net.inet.ip.forwarding=1 + jexec ${j}c ifconfig ${epair_c}b 192.0.2.2/24 up + jexec ${j}c route add default 192.0.2.1 + + jexec ${j}gw pfctl -e + pft_set_rules ${j}gw \ + "rdr pass on ${epair_srv}b proto sctp from 198.51.100.0/24 to any port 1234 -> 192.0.2.2 port 1234" \ + "pass" + + echo "foo" | jexec ${j}c nc --sctp -N -l 1234 & + + # Wait for the server to start + sleep 1 + + out=$(jexec ${j}srv nc --sctp -N -w 3 198.51.100.2 1234) + if [ "$out" != "foo" ]; then + atf_fail "SCTP connection failed" + fi + + # Despite configuring port changes pf will not do so. + echo "bar" | jexec ${j}c nc --sctp -N -l 1234 & + + pft_set_rules ${j}gw \ + "rdr pass on ${epair_srv}b proto sctp from 198.51.100.0/24 to any port 1234 -> 192.0.2.2 port 4321" \ + "pass" + + # This will fail + out=$(jexec ${j}srv nc --sctp -N -w 3 198.51.100.2 4321) + if [ "$out" == "bar" ]; then + atf_fail "Port was unexpectedly changed." + fi + + # This succeeds + out=$(jexec ${j}srv nc --sctp -N -w 3 198.51.100.2 1234) + if [ "$out" != "bar" ]; then + atf_fail "Port was unexpectedly changed." + fi +} + +rdr_v4_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "basic_v4" @@ -410,4 +477,5 @@ atf_init_test_cases() atf_add_test_case "abort_v6" atf_add_test_case "nat_v4" atf_add_test_case "nat_v6" + atf_add_test_case "rdr_v4" }