# SPDX-License-Identifier: BSD-2-Clause1#2# Copyright (c) 2026 Gleb Smirnoff <[email protected]>3#4# Redistribution and use in source and binary forms, with or without5# modification, are permitted provided that the following conditions6# are met:7# 1. Redistributions of source code must retain the above copyright8# notice, this list of conditions and the following disclaimer.9# 2. Redistributions in binary form must reproduce the above copyright10# notice, this list of conditions and the following disclaimer in the11# documentation and/or other materials provided with the distribution.12#13# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23# SUCH DAMAGE.2425. $(atf_get_srcdir)/../common/utils.subr2627atf_test_case "fuzz" "cleanup"28fuzz_head()29{30atf_set descr 'Create couple tables and fuzzes them'31atf_set require.user root32}3334fuzz_body()35{36firewall_init "ipfw"3738epair=$(vnet_mkepair)39vnet_mkjail sender ${epair}a40jexec sender ifconfig ${epair}a 192.0.2.0/31 up41jexec sender route add 10.0.0.0/8 192.0.2.14243vnet_mkjail receiver ${epair}b44jexec receiver ifconfig lo0 127.0.0.1/8 up45jexec receiver ifconfig ${epair}b 192.0.2.1/31 up46jexec receiver route add 10.0.0.0/8 -blackhole -iface lo04748jexec receiver ipfw add 100 count ip from any to table\(tb0\)49jexec receiver ipfw add 200 count ip from any to table\(tb1\)5051( jexec sender sh -c \52'while true; do \53oct=$(od -An -N1 -tu1 < /dev/urandom); \54oct=$(echo $oct); \55ping -c 5 -i .01 -W .01 10.0.0.${oct} >/dev/null; \56done' ) &57pinger=$!5859( jexec receiver sh -c \60'while true; do \61set -- $(od -An -N2 -tu1 < /dev/urandom); \62ipfw -q table tb$(($1 % 2)) add 10.0.0.$2; \63done' ) &64adder=$!6566( jexec receiver sh -c \67'while true; do \68set -- $(od -An -N2 -tu1 < /dev/urandom); \69ipfw -q table tb$(($1 % 2)) del 10.0.0.$2; \70done' ) &71deleter=$!7273( jexec receiver sh -c \74'while true; do \75ipfw table tb0 swap tb1; \76sleep .25; \77done' ) &78swapper=$!7980sleep 3081kill $pinger82kill $adder83kill $deleter84kill $swapper85}8687fuzz_cleanup()88{89firewall_cleanup $190}9192atf_init_test_cases()93{94atf_add_test_case "fuzz"95}969798