From nobody Fri Aug 11 12:13:37 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 4RMjPZ07tPz4q0yk; Fri, 11 Aug 2023 12:13:38 +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 4RMjPY4z14z4BYg; Fri, 11 Aug 2023 12:13:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691756017; 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=c5gOVszV00O3KMbLGoN0k0gbLMqoI9IN4fi3Kc0S2ow=; b=Uc+KzNZS6m7SnMYk5HOj98yMr0FdyZOgOhsgFSsIYOrOtOQAiO98e6r2721ImuGsT/ru8V jrBqUoZRf1B+RoBqRvsx427RteEN2WdNtvY9A/MgmzuC8k3fZDQwbvqsTLPyw+JP560lOL LTW00tOypJoPC0tnA7Fp2B8xugW6u7SA+uPBAcS7U/ktT8cSK7PEEismGXq/n0yZtu3aW9 qQ5C6LZBtEeJPuIrK3utZr0WZ/C9j+V6dq7BjbnEFVhbc9SMbDpYA0wsLjVhJLrg5vIZ5k 5xj8rBM6Pq8LS5U3IvcWp8dE1vorhz204qM8ay4VxgShQtIHFPKC9Ac/eniNOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691756017; 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=c5gOVszV00O3KMbLGoN0k0gbLMqoI9IN4fi3Kc0S2ow=; b=MMBSWfhem4AA9Kc3MVKhS8XczRsOnG7dZAFuBJb4g3RSwdW2HFslDiRCbnzqkGGkmuT+cC gbft/ygEl2VwUKLklmFSr9+WJEM3zWaMdyDAPHfkXe0Z63o5ffRxqAG7bH6tM6PNBVU39a aJObMW1SV0lFxqVmuajS0XEDApfcyR3K/YXYyaWz+j6Q5JP2yNclx2qwWJsUoDSYqDm5/+ 5OPYhGTodhbgkkG5/60cUNx9h1wvljMI76bgGjWNLX0mIgmke0BOrYay3UezMfeojy9ft/ UEfZHdxeAjfIgs+oYTkU/V5SYIEwdEYmD1bqy0NpPSiKfHCbqwItsiqQXaxTRw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691756017; a=rsa-sha256; cv=none; b=Fk0d/y+RWNuoE58pPV59vJIKemkUCH8HTF4oheShLYkR6s+2V84rRX3ThTMD8P9WrSvbas ZnJP7sOBjLhaR0E89ZB+mc57Y9LEjeF6W26cZZHoTy5XFV1xhKGclyY7VRMbCsUzOcjmYM S5HD2U0e4UxC6sENIItWRbW2vwSvTR8LU+tJLwq9zNo2TJXjPSV+sm+IVevLDbz3imLd00 tZCVV4nEwCgWBTyiHcTMxFrVfTUhgojXrfRo6D1JirltCx/CXEmxb6WyDpIesIohi7iJna 7GwOb3nHmQYKI9hkYOg88Ur3qjVhCTnOhBS5aG96FP2nVMfuSrMeLVuD5ED4iQ== 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 4RMjPY3lMbzdgX; Fri, 11 Aug 2023 12:13:37 +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 37BCDb3X008724; Fri, 11 Aug 2023 12:13:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37BCDb4k008721; Fri, 11 Aug 2023 12:13:37 GMT (envelope-from git) Date: Fri, 11 Aug 2023 12:13:37 GMT Message-Id: <202308111213.37BCDb4k008721@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: dc0a6fb58471 - stable/13 - pf tests: test SCTP NAT 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: dc0a6fb5847149fd55d5bbb21c0e2c532e51be76 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=dc0a6fb5847149fd55d5bbb21c0e2c532e51be76 commit dc0a6fb5847149fd55d5bbb21c0e2c532e51be76 Author: Kristof Provost AuthorDate: 2023-06-01 13:28:58 +0000 Commit: Kristof Provost CommitDate: 2023-08-11 12:13:10 +0000 pf tests: test SCTP NAT MFC after: 3 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D40867 (cherry picked from commit 1e02b7cb07ce31ad3c9e8c8be806d2825febb5ab) --- tests/sys/netpfil/pf/sctp.sh | 106 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/tests/sys/netpfil/pf/sctp.sh b/tests/sys/netpfil/pf/sctp.sh index 59697ad37be2..659c11c62113 100644 --- a/tests/sys/netpfil/pf/sctp.sh +++ b/tests/sys/netpfil/pf/sctp.sh @@ -298,10 +298,116 @@ abort_v4_cleanup() pft_cleanup } +atf_test_case "nat_v4" "cleanup" +nat_v4_head() +{ + atf_set descr 'Test NAT-ing SCTP over IPv4' + atf_set require.user root +} + +nat_v4_body() +{ + sctp_init + + j="sctp:nat_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 \ + "nat on ${epair_srv}b from 192.0.2.0/24 -> (${epair_srv}b)" \ + "pass" + + # Sanity check + atf_check -s exit:0 -o ignore \ + jexec ${j}c ping -c 1 198.51.100.1 + + echo "foo" | jexec ${j}srv nc --sctp -N -l 1234 & + + # Wait for the server to start + sleep 1 + + out=$(jexec ${j}c nc --sctp -N -w 3 198.51.100.1 1234) + if [ "$out" != "foo" ]; then + atf_fail "SCTP connection failed" + fi +} + +nat_v4_cleanup() +{ + pft_cleanup +} + +atf_test_case "nat_v6" "cleanup" +nat_v6_head() +{ + atf_set descr 'Test NAT-ing SCTP over IPv6' + atf_set require.user root +} + +nat_v6_body() +{ + sctp_init + + j="sctp:nat_v6" + 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 inet6 2001:db8::1/64 up no_dad + # No default route in srv jail, to ensure we're NAT-ing + jexec ${j}gw ifconfig ${epair_srv}b inet6 2001:db8::2/64 up no_dad + jexec ${j}gw ifconfig ${epair_c}a inet6 2001:db8:1::1/64 up no_dad + jexec ${j}gw sysctl net.inet6.ip6.forwarding=1 + jexec ${j}c ifconfig ${epair_c}b inet6 2001:db8:1::2/64 up no_dad + jexec ${j}c route add -6 default 2001:db8:1::1 + + jexec ${j}gw pfctl -e + pft_set_rules ${j}gw \ + "nat on ${epair_srv}b from 2001:db8:1::/64 -> (${epair_srv}b)" \ + "pass" + + # Sanity check + atf_check -s exit:0 -o ignore \ + jexec ${j}c ping -6 -c 1 2001:db8::1 + + echo "foo" | jexec ${j}srv nc -6 --sctp -N -l 1234 & + + # Wait for the server to start + sleep 1 + + out=$(jexec ${j}c nc --sctp -N -w 3 2001:db8::1 1234) + if [ "$out" != "foo" ]; then + atf_fail "SCTP connection failed" + fi +} + +nat_v6_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" + atf_add_test_case "nat_v4" + atf_add_test_case "nat_v6" }