124360d83SKristof Provost# 2*4d846d26SWarner Losh# SPDX-License-Identifier: BSD-2-Clause 324360d83SKristof Provost# 424360d83SKristof Provost# Copyright (c) 2022 Kristof Provost <kp@FreeBSD.org> 524360d83SKristof Provost# 624360d83SKristof Provost# Redistribution and use in source and binary forms, with or without 724360d83SKristof Provost# modification, are permitted provided that the following conditions 824360d83SKristof Provost# are met: 924360d83SKristof Provost# 1. Redistributions of source code must retain the above copyright 1024360d83SKristof Provost# notice, this list of conditions and the following disclaimer. 1124360d83SKristof Provost# 2. Redistributions in binary form must reproduce the above copyright 1224360d83SKristof Provost# notice, this list of conditions and the following disclaimer in the 1324360d83SKristof Provost# documentation and/or other materials provided with the distribution. 1424360d83SKristof Provost# 1524360d83SKristof Provost# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1624360d83SKristof Provost# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1724360d83SKristof Provost# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1824360d83SKristof Provost# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1924360d83SKristof Provost# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2024360d83SKristof Provost# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2124360d83SKristof Provost# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2224360d83SKristof Provost# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2324360d83SKristof Provost# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2424360d83SKristof Provost# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2524360d83SKristof Provost# SUCH DAMAGE. 2624360d83SKristof Provost 2724360d83SKristof Provost. $(atf_get_srcdir)/utils.subr 2824360d83SKristof Provost 2924360d83SKristof Provostatf_test_case "set_prio" "cleanup" 3024360d83SKristof Provostset_prio_head() 3124360d83SKristof Provost{ 3224360d83SKristof Provost atf_set descr 'Test setting VLAN PCP' 3324360d83SKristof Provost atf_set require.user root 3424360d83SKristof Provost} 3524360d83SKristof Provost 3624360d83SKristof Provostset_prio_body() 3724360d83SKristof Provost{ 3824360d83SKristof Provost pft_init 3924360d83SKristof Provost 4024360d83SKristof Provost epair=$(vnet_mkepair) 4124360d83SKristof Provost ifconfig ${epair}a.42 create 4224360d83SKristof Provost ifconfig ${epair}a up 4324360d83SKristof Provost ifconfig ${epair}a.42 192.0.2.1/24 up 4424360d83SKristof Provost ifconfig ${epair}a.42 vlandev ${epair}a vlan 42 4524360d83SKristof Provost echo ${epair}a.42 >> created_interfaces.lst 4624360d83SKristof Provost 4724360d83SKristof Provost vnet_mkjail alcatraz ${epair}b 4824360d83SKristof Provost jexec alcatraz ifconfig ${epair}b.42 create 4924360d83SKristof Provost jexec alcatraz ifconfig ${epair}b up 5024360d83SKristof Provost jexec alcatraz ifconfig ${epair}b.42 192.0.2.2/24 up 5124360d83SKristof Provost jexec alcatraz ifconfig ${epair}b.42 vlandev ${epair}b vlan 42 5224360d83SKristof Provost 5324360d83SKristof Provost jexec alcatraz sysctl net.link.vlan.mtag_pcp=1 5424360d83SKristof Provost 5524360d83SKristof Provost jexec alcatraz pfctl -e 5624360d83SKristof Provost pft_set_rules alcatraz \ 5724360d83SKristof Provost "pass out set prio 4" 5824360d83SKristof Provost 5924360d83SKristof Provost jexec alcatraz ping 192.0.2.1 & 6024360d83SKristof Provost 6124360d83SKristof Provost atf_check -e ignore -o match:'.*vlan 42, p 4.*' tcpdump -n -i ${epair}a -e -c 4 6224360d83SKristof Provost} 6324360d83SKristof Provost 6424360d83SKristof Provostset_prio_cleanup() 6524360d83SKristof Provost{ 6624360d83SKristof Provost pft_cleanup 6724360d83SKristof Provost} 6824360d83SKristof Provost 6924360d83SKristof Provostatf_init_test_cases() 7024360d83SKristof Provost{ 7124360d83SKristof Provost atf_add_test_case "set_prio" 7224360d83SKristof Provost} 73