1*a9d7ff4eSKristof Provost# 2*a9d7ff4eSKristof Provost# SPDX-License-Identifier: BSD-2-Clause 3*a9d7ff4eSKristof Provost# 4*a9d7ff4eSKristof Provost# Copyright (c) 2024 Rubicon Communications, LLC (Netgate) 5*a9d7ff4eSKristof Provost# 6*a9d7ff4eSKristof Provost# Redistribution and use in source and binary forms, with or without 7*a9d7ff4eSKristof Provost# modification, are permitted provided that the following conditions 8*a9d7ff4eSKristof Provost# are met: 9*a9d7ff4eSKristof Provost# 1. Redistributions of source code must retain the above copyright 10*a9d7ff4eSKristof Provost# notice, this list of conditions and the following disclaimer. 11*a9d7ff4eSKristof Provost# 2. Redistributions in binary form must reproduce the above copyright 12*a9d7ff4eSKristof Provost# notice, this list of conditions and the following disclaimer in the 13*a9d7ff4eSKristof Provost# documentation and/or other materials provided with the distribution. 14*a9d7ff4eSKristof Provost# 15*a9d7ff4eSKristof Provost# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16*a9d7ff4eSKristof Provost# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*a9d7ff4eSKristof Provost# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*a9d7ff4eSKristof Provost# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19*a9d7ff4eSKristof Provost# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20*a9d7ff4eSKristof Provost# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21*a9d7ff4eSKristof Provost# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22*a9d7ff4eSKristof Provost# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23*a9d7ff4eSKristof Provost# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24*a9d7ff4eSKristof Provost# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25*a9d7ff4eSKristof Provost# SUCH DAMAGE. 26*a9d7ff4eSKristof Provost 27*a9d7ff4eSKristof Provost. $(atf_get_srcdir)/utils.subr 28*a9d7ff4eSKristof Provost 29*a9d7ff4eSKristof Provostatf_test_case "basic" "cleanup" 30*a9d7ff4eSKristof Provostbasic_head() 31*a9d7ff4eSKristof Provost{ 32*a9d7ff4eSKristof Provost atf_set descr 'Basic get/clear status test case' 33*a9d7ff4eSKristof Provost atf_set require.user root 34*a9d7ff4eSKristof Provost} 35*a9d7ff4eSKristof Provost 36*a9d7ff4eSKristof Provostbasic_body() 37*a9d7ff4eSKristof Provost{ 38*a9d7ff4eSKristof Provost pft_init 39*a9d7ff4eSKristof Provost 40*a9d7ff4eSKristof Provost epair=$(vnet_mkepair) 41*a9d7ff4eSKristof Provost 42*a9d7ff4eSKristof Provost vnet_mkjail one ${epair}a 43*a9d7ff4eSKristof Provost jexec one ifconfig ${epair}a 192.0.2.1/24 up 44*a9d7ff4eSKristof Provost vnet_mkjail two ${epair}b 45*a9d7ff4eSKristof Provost jexec two ifconfig ${epair}b 192.0.2.2/24 up 46*a9d7ff4eSKristof Provost 47*a9d7ff4eSKristof Provost jexec one pfctl -e 48*a9d7ff4eSKristof Provost pft_set_rules one "pass" 49*a9d7ff4eSKristof Provost 50*a9d7ff4eSKristof Provost # Sanity check 51*a9d7ff4eSKristof Provost atf_check -s exit:0 -o ignore \ 52*a9d7ff4eSKristof Provost jexec two ping -c 1 192.0.2.1 53*a9d7ff4eSKristof Provost 54*a9d7ff4eSKristof Provost atf_check -s exit:0 -o not-match:'searches[[:space:]]+0' \ 55*a9d7ff4eSKristof Provost jexec one pfctl -si 56*a9d7ff4eSKristof Provost 57*a9d7ff4eSKristof Provost atf_check -s exit:0 -o ignore -e ignore \ 58*a9d7ff4eSKristof Provost jexec one pfctl -Fi 59*a9d7ff4eSKristof Provost 60*a9d7ff4eSKristof Provost atf_check -s exit:0 -o match:'searches[[:space:]]+0' \ 61*a9d7ff4eSKristof Provost jexec one pfctl -si 62*a9d7ff4eSKristof Provost} 63*a9d7ff4eSKristof Provost 64*a9d7ff4eSKristof Provostbasic_cleanup() 65*a9d7ff4eSKristof Provost{ 66*a9d7ff4eSKristof Provost pft_cleanup 67*a9d7ff4eSKristof Provost} 68*a9d7ff4eSKristof Provost 69*a9d7ff4eSKristof Provostatf_init_test_cases() 70*a9d7ff4eSKristof Provost{ 71*a9d7ff4eSKristof Provost atf_add_test_case "basic" 72*a9d7ff4eSKristof Provost} 73*a9d7ff4eSKristof Provost 74