165d553b0SKristof Provost# 2*4d846d26SWarner Losh# SPDX-License-Identifier: BSD-2-Clause 365d553b0SKristof Provost# 465d553b0SKristof Provost# Copyright (c) 2018 Kristof Provost <kp@FreeBSD.org> 565d553b0SKristof Provost# 665d553b0SKristof Provost# Redistribution and use in source and binary forms, with or without 765d553b0SKristof Provost# modification, are permitted provided that the following conditions 865d553b0SKristof Provost# are met: 965d553b0SKristof Provost# 1. Redistributions of source code must retain the above copyright 1065d553b0SKristof Provost# notice, this list of conditions and the following disclaimer. 1165d553b0SKristof Provost# 2. Redistributions in binary form must reproduce the above copyright 1265d553b0SKristof Provost# notice, this list of conditions and the following disclaimer in the 1365d553b0SKristof Provost# documentation and/or other materials provided with the distribution. 1465d553b0SKristof Provost# 1565d553b0SKristof Provost# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1665d553b0SKristof Provost# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1765d553b0SKristof Provost# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1865d553b0SKristof Provost# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1965d553b0SKristof Provost# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2065d553b0SKristof Provost# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2165d553b0SKristof Provost# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2265d553b0SKristof Provost# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2365d553b0SKristof Provost# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2465d553b0SKristof Provost# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2565d553b0SKristof Provost# SUCH DAMAGE. 26df5ceb3bSKristof Provost 27df5ceb3bSKristof Provost. $(atf_get_srcdir)/utils.subr 28df5ceb3bSKristof Provost 29df5ceb3bSKristof Provostatf_test_case "names" "cleanup" 30df5ceb3bSKristof Provostnames_head() 31df5ceb3bSKristof Provost{ 32df5ceb3bSKristof Provost atf_set descr 'Test overlapping names' 33df5ceb3bSKristof Provost atf_set require.user root 34df5ceb3bSKristof Provost} 35df5ceb3bSKristof Provost 36df5ceb3bSKristof Provostnames_body() 37df5ceb3bSKristof Provost{ 38df5ceb3bSKristof Provost pft_init 39df5ceb3bSKristof Provost 4006aac31aSKristof Provost epair=$(vnet_mkepair) 41df5ceb3bSKristof Provost 4206aac31aSKristof Provost vnet_mkjail alcatraz ${epair}b 43df5ceb3bSKristof Provost ifconfig ${epair}a name foo 44df5ceb3bSKristof Provost jexec alcatraz ifconfig ${epair}b name foo 45df5ceb3bSKristof Provost 46df5ceb3bSKristof Provost jail -r alcatraz 47df5ceb3bSKristof Provost ifconfig foo destroy 48df5ceb3bSKristof Provost} 49df5ceb3bSKristof Provost 50df5ceb3bSKristof Provostnames_cleanup() 51df5ceb3bSKristof Provost{ 52df5ceb3bSKristof Provost pft_cleanup 53df5ceb3bSKristof Provost} 54df5ceb3bSKristof Provost 55654e8d84SKristof Provostatf_test_case "group" "cleanup" 56654e8d84SKristof Provostgroup_head() 57654e8d84SKristof Provost{ 58654e8d84SKristof Provost atf_set descr 'Test group cleanup, PR257218' 59654e8d84SKristof Provost atf_set require.user root 60654e8d84SKristof Provost} 61654e8d84SKristof Provost 62654e8d84SKristof Provostgroup_body() 63654e8d84SKristof Provost{ 64654e8d84SKristof Provost pft_init 65654e8d84SKristof Provost 66654e8d84SKristof Provost vnet_mkjail alcatraz 67654e8d84SKristof Provost 68654e8d84SKristof Provost if [ -n "$(jexec alcatraz pfctl -sI | grep '^epair$')" ]; 69654e8d84SKristof Provost then 70654e8d84SKristof Provost atf_fail "Unexpected epair group" 71654e8d84SKristof Provost fi 72654e8d84SKristof Provost 73654e8d84SKristof Provost epair=$(vnet_mkepair) 74654e8d84SKristof Provost if [ -n "$(jexec alcatraz pfctl -sI | grep '^epair$')" ]; 75654e8d84SKristof Provost then 76654e8d84SKristof Provost atf_fail "Unexpected epair group" 77654e8d84SKristof Provost fi 78654e8d84SKristof Provost 79654e8d84SKristof Provost ifconfig ${epair}b vnet alcatraz 80654e8d84SKristof Provost if [ -z "$(jexec alcatraz pfctl -sI | grep '^epair$')" ]; 81654e8d84SKristof Provost then 82654e8d84SKristof Provost atf_fail "Failed to find epair group" 83654e8d84SKristof Provost fi 84654e8d84SKristof Provost 85654e8d84SKristof Provost ifconfig ${epair}a destroy 86654e8d84SKristof Provost 87654e8d84SKristof Provost if [ -n "$(jexec alcatraz pfctl -sI | grep '^epair$')" ]; 88654e8d84SKristof Provost then 89654e8d84SKristof Provost atf_fail "Unexpected epair group" 90654e8d84SKristof Provost fi 91654e8d84SKristof Provost} 92654e8d84SKristof Provost 93654e8d84SKristof Provostgroup_cleanup() 94654e8d84SKristof Provost{ 95654e8d84SKristof Provost pft_cleanup 96654e8d84SKristof Provost} 97654e8d84SKristof Provost 98df5ceb3bSKristof Provostatf_init_test_cases() 99df5ceb3bSKristof Provost{ 100df5ceb3bSKristof Provost atf_add_test_case "names" 101654e8d84SKristof Provost atf_add_test_case "group" 102df5ceb3bSKristof Provost} 103