From nobody Fri Jul 21 10:32:43 2023 X-Original-To: dev-commits-src-main@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 4R6m8v4cqDz4pG7M; Fri, 21 Jul 2023 10:32:43 +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 4R6m8q5htTz3qSF; Fri, 21 Jul 2023 10:32:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689935563; 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=/1WVKJvcjQ7LdxavE/jnsi2LGXOZSW6GP9jR0fn+KUk=; b=DlTMjluUg/nfsZ8LCgjJiCZWuAtr6XpS33M5kZgV2iCKXscUxBCZflctcX+4ZcRkvLG+Ip 0HOfnxMAWCjW9BM6yufxsFE6O+8/z0FAVkKggEN7t/ghuR5yh+Tyr86Dnnu1cbEHQBewxY TF7vzLdYAMCiq7AJBYD9TWa868KXg8H+Kij3Z53nkpz3lH0fK+G58dRthycYv3A5+4EjOm 1VX0B3sBfWZUf9ni0vGcKRaUm7GbYk2fQwBqy8JacqaVJvECK8cFD2YgTYJOqwwtpEtD4w 1F9REOFZGKbXFpToSj++PPpfzFrTb0K1RNFZYoY3+xwOxPukKRfO4Kil/LBY0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689935563; 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=/1WVKJvcjQ7LdxavE/jnsi2LGXOZSW6GP9jR0fn+KUk=; b=eUszE6Le0LPrLHcSUbqMkmVAIIwSQJBH1TU/6ZExq/BNCEvTw4TYAKg7+O0jFwGol8QjWj icMeWZhC/g6UbQYmDJODQRBBc1x6atXf5LL1OedwgXnC6LQq60zk2Ngg116d48JAUJ9L2o 0rAn+ykkksCMS9cditvIkGxWH16qcuDnvu/bVv66mXAPyUXb81fVXL/bTY6RhHRJ8+Zrz4 ITAzTkX8XJX0RBM97/lBO0AyqUR9cur6F7jGkUROhvrrLU7rW8/YRDUuOUMvsT9O0eVxDh GGGxBby+E7qV5TKQkCWe1I0IC6ZADzrgPY/BWgfgrrE+fmu94rlfdBLfZQ0jdQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689935563; a=rsa-sha256; cv=none; b=iXUvPjqJwfA+tvk9ze2FqZqs6RTqP5AhBwVh2aYmvPN6vxiqbQw6JHeoi7ecx8FSMMsSxD SALbv4c2rtGQQS6FDk6IbnRICUjgFkFKJxA9oHc3yKYIbnPvBSK2mP+AExp/HDQBTeXhoO 5qi6HQgPFLfOs/e0nv9pyrid7eKMs4Gwglg1cKG21ypK7hoq+fpCvU9P8weHWZBBHpR46l E59EyB8oyYKnMUqphQm6l5oiSeXIVh7oPwkLsb0Sf9TqwIXhBQ8KVau3B4Ji6ZsxbRMrKB 3I/RGIaDAHtmz4Ggz1aH9i6PA1sI8g7Ht1fZxnkpSUHC+GYKl14H6NToQi2rYw== 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 4R6m8q4KCLz18Cv; Fri, 21 Jul 2023 10:32:43 +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 36LAWhJh010615; Fri, 21 Jul 2023 10:32:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36LAWhbj010614; Fri, 21 Jul 2023 10:32:43 GMT (envelope-from git) Date: Fri, 21 Jul 2023 10:32:43 GMT Message-Id: <202307211032.36LAWhbj010614@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: 1e02b7cb07ce - main - pf tests: test SCTP NAT List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 1e02b7cb07ce31ad3c9e8c8be806d2825febb5ab Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=1e02b7cb07ce31ad3c9e8c8be806d2825febb5ab commit 1e02b7cb07ce31ad3c9e8c8be806d2825febb5ab Author: Kristof Provost AuthorDate: 2023-06-01 13:28:58 +0000 Commit: Kristof Provost CommitDate: 2023-07-21 10:32:19 +0000 pf tests: test SCTP NAT MFC after: 3 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D40867 --- 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" }