From nobody Tue Jun 28 11:59:38 2022 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 5EA7786381B; Tue, 28 Jun 2022 11:59:39 +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 4LXNSB48qJz3QjM; Tue, 28 Jun 2022 11:59:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656417578; 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=XqWjxsdJaXssjcKAlrFUDeR0lK0nNkStIgDUDxBXQ0g=; b=qc+KMmTKa1LSQkNTsHzKqq1OpCP8xZR7ngGdCNcyzrlabF6u34VYp0FheZmanGrxb8Htxj ERhgU0Om6wuAallGRbwyaiwJXi0inf386Jy2uByZldQyd2vCNeHNcklY8aUlK3qayTA/EM FDSam59xMzcqlO42/EX1hzjfCX+TRm/k9C8N/G3GzG9Al6TD5aGcBA53FjqgW0/JtbyW4z o7/VCtnEG51GJMi7fRBg+MTtjM0lr92SOib3C7WuBIGCONpHi96C6ubob59JvxoQBPd2Jd 3QQfW+nuLIkxYk14lfmjyv4RuhcVhLbQTwgoF6Iuw7iriOKUMqTAPjJ2VCHLLw== 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 493E61C90B; Tue, 28 Jun 2022 11:59:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25SBxcvP055711; Tue, 28 Jun 2022 11:59:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25SBxcAq055710; Tue, 28 Jun 2022 11:59:38 GMT (envelope-from git) Date: Tue, 28 Jun 2022 11:59:38 GMT Message-Id: <202206281159.25SBxcAq055710@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: c09e62cd910e - main - if_ovpn tests: test pf's route-to 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: c09e62cd910efc52dcaa25bebf1412bd1aba0b79 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656417578; 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=XqWjxsdJaXssjcKAlrFUDeR0lK0nNkStIgDUDxBXQ0g=; b=KMjZYBxXd74VeTnqcCAMlllYE/oTROOB7s3CH/RhAUEP3BHpSa0AdAke9MzM1zAF0aHEvO nK/gohplPepzg/q6x/NoGmcxexoE2FKghcGfKRM6Wrz46qzPP3t7ua4tUL6lwZkBomQFsG cbvWClIf19d80j/wtLaa9wnhhSTiSC6zK3Y3NC9O4AJ62eU+10lnNWf3HVxFLmsiedkzss jtKanvYz7p5uT9HPfpQGivDn+DQIgwestNG/FvE00BxNUTOnqOBaqMHMqT/GDyu9k/iwni RFmx0iFYMzKBs4Zbet9ma1tuWgAuLu467dE6J9G3UFTq2C55qEYYMTANDJZHgg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656417578; a=rsa-sha256; cv=none; b=t529sNV4dMYUdoF+KsxBJnnYsX3EoadIup7/C/QEhyjv3Kl6R7zdNKcEvguyyQyVl2H4eX dee3mAwMVkRGv4NyaUF24pamAzqL9MDTo67jw9q8L6UTPLlmidAZB3TlxlFsNew2JnLwCt iAjxZgmlj8E0wfMjDt/LphUdW998p5G6215Kn+gUPMN9D3ZzP5tdnXvZgEH0Hoh2dmo6ST vFAxMSlgb9C8M35J34PixlxVw71M6tob02nV8BIgEVGe0uFcdQ//d1tpK8cg75a4sE46yV ydGFpzL+vPi5LggxT/N64Nb6m5kOHbZtaOG0jgG/AXku+4tKIMbQzex1qp8ing== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=c09e62cd910efc52dcaa25bebf1412bd1aba0b79 commit c09e62cd910efc52dcaa25bebf1412bd1aba0b79 Author: Kristof Provost AuthorDate: 2022-06-09 15:07:12 +0000 Commit: Kristof Provost CommitDate: 2022-06-28 11:51:24 +0000 if_ovpn tests: test pf's route-to Ensure that pf's route-to works with if_ovpn. Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/net/if_ovpn/if_ovpn.sh | 90 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tests/sys/net/if_ovpn/if_ovpn.sh b/tests/sys/net/if_ovpn/if_ovpn.sh index b7c91af5d010..7d8031f551de 100644 --- a/tests/sys/net/if_ovpn/if_ovpn.sh +++ b/tests/sys/net/if_ovpn/if_ovpn.sh @@ -25,6 +25,7 @@ # SUCH DAMAGE. . $(atf_get_srcdir)/utils.subr +. $(atf_get_srcdir)/../../netpfil/pf/utils.subr atf_test_case "4in4" "cleanup" 4in4_head() @@ -400,6 +401,94 @@ timeout_client_cleanup() ovpn_cleanup } +atf_test_case "route_to" "cleanup" +route_to_head() +{ + atf_set descr "Test pf's route-to with OpenVPN tunnels" + atf_set require.user root + atf_set require.progs openvpn +} + +route_to_body() +{ + pft_init + ovpn_init + + l=$(vnet_mkepair) + n=$(vnet_mkepair) + + vnet_mkjail a ${l}a + jexec a ifconfig ${l}a 192.0.2.1/24 up + jexec a ifconfig ${l}a inet alias 198.51.100.254/24 + vnet_mkjail b ${l}b ${n}a + jexec b ifconfig ${l}b 192.0.2.2/24 up + jexec b ifconfig ${n}a up + + # Sanity check + atf_check -s exit:0 -o ignore jexec a ping -c 1 192.0.2.2 + + ovpn_start a " + dev ovpn0 + dev-type tun + proto udp4 + + cipher AES-256-GCM + auth SHA256 + + local 192.0.2.1 + server 198.51.100.0 255.255.255.0 + ca $(atf_get_srcdir)/ca.crt + cert $(atf_get_srcdir)/server.crt + key $(atf_get_srcdir)/server.key + dh $(atf_get_srcdir)/dh.pem + + mode server + script-security 2 + auth-user-pass-verify /usr/bin/true via-env + topology subnet + + keepalive 100 600 + " + ovpn_start b " + dev tun0 + dev-type tun + + client + + remote 192.0.2.1 + auth-user-pass $(atf_get_srcdir)/user.pass + + ca $(atf_get_srcdir)/ca.crt + cert $(atf_get_srcdir)/client.crt + key $(atf_get_srcdir)/client.key + dh $(atf_get_srcdir)/dh.pem + + keepalive 100 600 + " + + # Give the tunnel time to come up + sleep 10 + + # Check the tunnel + atf_check -s exit:0 -o ignore jexec b ping -c 1 198.51.100.1 + atf_check -s exit:0 -o ignore jexec b ping -c 1 198.51.100.254 + + # Break our routes so that we need a route-to to make things work. + jexec b ifconfig ${n}a 198.51.100.3/24 + atf_check -s exit:2 -o ignore jexec b ping -c 1 -t 1 -S 198.51.100.2 198.51.100.254 + + jexec b pfctl -e + pft_set_rules b \ + "pass out route-to (tun0 198.51.100.1) proto icmp from 198.51.100.2 " + atf_check -s exit:0 -o ignore jexec b ping -c 3 -S 198.51.100.2 198.51.100.254 +} + +route_to_cleanup() +{ + ovpn_cleanup + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "4in4" @@ -407,4 +496,5 @@ atf_init_test_cases() atf_add_test_case "6in6" atf_add_test_case "4in6" atf_add_test_case "timeout_client" + atf_add_test_case "route_to" }