From nobody Sat Jan 17 04:09:27 2026 X-Original-To: dev-commits-src-all@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 4dtNX74nKZz6PKjD for ; Sat, 17 Jan 2026 04:09:27 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dtNX72dX5z3V7d for ; Sat, 17 Jan 2026 04:09:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768622967; 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=3JESiqG3z3tIXHb9Dh3nU9Z7xehuls9fQNsntXmwczg=; b=Wgg94ZcG/keJWmUDMiYc61c3rnINWNPlzQIQN25kR63HubFnWJb/2PggdxO/nQcDR9AJzP AtlgW6LVzFGqNrUzHECtWta1vtpIQPL19v7PDwofoCCHOS0NHbPxBNCPr6lxkGkabX7cEi AkZy+rg1UC2Wq6yeesWP3mt4nwmeJlKllAmNIA7Idp/K/LRlWEtPKgKDQx4ruEiw5GjMC8 TJ9Zpr5o6iiAQPsGTVrd8NroxUSIotGC0Xmp016a6Jo+qVF92uHbmovrgLCFKJPTaiaCfs Cf0w/lIQzVZGG9fwuwyqFL7EO6sZwj3QgJDSUpfg7bbiIzeMn5J2nz6Pk0rVdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768622967; 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=3JESiqG3z3tIXHb9Dh3nU9Z7xehuls9fQNsntXmwczg=; b=yHWMMBfYuNed+x/BmTJQVD0iCiP5IPgp1FWO97K+co37HgnI9Ynq3ft9EEcKyiz6tG3EZ/ bQAF+n4kUJxIgHi9n4/QnPOXQsR2/MxTbKvMHiRmP0Usy7NuD8wGYb/Wb6TxAeEsOs15+G R+H3bww7JcNjLv+ECoB+4OjZXF5FFveqkiOq1bdpuMuhZu123/XUBipgTjDwF+IRCKOaDS 0HIGgks5F2saJ+53oaw+so5FBM2NynCRYk8Cntd8ESNcvqNsTQMLDid9rrbaSflPYhz4JS k8kngFS0Ms9swdTFuqVGEEll5BAG/rMEYW5N/Ob46RI4f+ul+cl4EwpQSdXOjw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1768622967; a=rsa-sha256; cv=none; b=vIz6pEcGgYANm3G3ZIMQGiSOSkEqpcUtC6KVz7SOaRpJMJMxVC14TPU+VzYisf0vkQ7dot G9FrDpcbfYPIPaJ8fCLbzPKnJbAjn6bk89ilKMSaU+h0hpJb9qjFOMP3F4MRBj76W/n/Y1 i1H1Zfszdr83KZlJlFTWShJ0kAA6KnnGbcrzpeCgrC8tfQklDBZWXeH0MvyAtV+5VAhPd8 1nlHLwdUta3ACBLs+UA3eBjzdzjCQaqRBGSFtWG2OWuQ7MgKwDg2xMd1PCi/yEkFHFGlnl lrDheAIJVgvzCInKTrtoFR80ZhpDYqj8sxIUdU/MdkZSURASpDBu1gU27HK5Sg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dtNX728pKzkv7 for ; Sat, 17 Jan 2026 04:09:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 256da by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 17 Jan 2026 04:09:27 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 35caa56a329d - main - tests/ipfw: add a test for ipfw(4) log rules that write to bpf(4) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 35caa56a329deb0d13aa48ea1a6f7c1d5ebdb073 Auto-Submitted: auto-generated Date: Sat, 17 Jan 2026 04:09:27 +0000 Message-Id: <696b0b77.256da.64858562@gitrepo.freebsd.org> The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=35caa56a329deb0d13aa48ea1a6f7c1d5ebdb073 commit 35caa56a329deb0d13aa48ea1a6f7c1d5ebdb073 Author: Gleb Smirnoff AuthorDate: 2026-01-17 01:46:02 +0000 Commit: Gleb Smirnoff CommitDate: 2026-01-17 04:09:02 +0000 tests/ipfw: add a test for ipfw(4) log rules that write to bpf(4) --- tests/sys/netpfil/ipfw/Makefile | 1 + tests/sys/netpfil/ipfw/log.sh | 95 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/tests/sys/netpfil/ipfw/Makefile b/tests/sys/netpfil/ipfw/Makefile index 92a8c9fdb2cd..cf68a0e2882a 100644 --- a/tests/sys/netpfil/ipfw/Makefile +++ b/tests/sys/netpfil/ipfw/Makefile @@ -4,6 +4,7 @@ TESTSDIR= ${TESTSBASE}/sys/netpfil/ipfw ATF_TESTS_SH+= fwd \ divert \ + log \ table ${PACKAGE}FILES+= fwd_inetd.conf diff --git a/tests/sys/netpfil/ipfw/log.sh b/tests/sys/netpfil/ipfw/log.sh new file mode 100755 index 000000000000..7df5c69e4219 --- /dev/null +++ b/tests/sys/netpfil/ipfw/log.sh @@ -0,0 +1,95 @@ +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2026 Gleb Smirnoff +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +. $(atf_get_srcdir)/../common/utils.subr + +atf_test_case "bpf" "cleanup" +bpf_head() +{ + atf_set descr 'Creates several rules with log and probes bpf taps' + atf_set require.user root +} + +bpf_body() +{ + firewall_init "ipfw" + + epair=$(vnet_mkepair) + vnet_mkjail alcatraz ${epair}b + ifconfig ${epair}a 192.0.2.0/31 up + jexec alcatraz ifconfig ${epair}b 192.0.2.1/31 up + + # Create a bunch of statically and auto numbered logging rules + rules="100 200 201" + for r in ${rules}; do + jexec alcatraz \ + ipfw add ${r} count log udp from any to any 10${r} + done + auto=$(jexec alcatraz ipfw add count log udp from any to any 10666 \ + | awk '{print $1}' | sed -Ee 's/^0+//') + + pids="" + for r in ${rules} ${auto}; do + jexec alcatraz tcpdump --immediate-mode -i ipfw${r} \ + -w ${PWD}/${r}.pcap -c 1 & + pids="${pids} $!" + done + + # wait for tcpdumps to attach, include netstat(1) header in ${count} + count=$(( $(echo ${rules} ${auto} | wc -w) + 1)) + while [ $(jexec alcatraz netstat -B | wc -l) -ne ${count} ]; do + sleep 0.01; + done + + for p in ${rules} 666; do + echo foo | nc -u 192.0.2.1 10${p} -w 0 + done + + for p in ${pids}; do + atf_check -s exit:0 sh -c "wait $pid; exit $?" + done + + # statically numbered taps + for p in ${rules}; do + atf_check -o match:"192.0.2.0.[0-9]+ > 192.0.2.1.10${p}: UDP" \ + -e match:"reading from file [a-zA-Z0-9/.]+${p}.pcap" \ + tcpdump -nr ${PWD}/${p}.pcap + done + + # autonumbered tap with 10666 port + atf_check -o match:"192.0.2.0.[0-9]+ > 192.0.2.1.10666: UDP" \ + -e match:"reading from file [a-zA-Z0-9/.]+${auto}.pcap" \ + tcpdump -nr ${PWD}/${auto}.pcap +} + +bpf_cleanup() +{ + firewall_cleanup $1 +} + +atf_init_test_cases() +{ + atf_add_test_case "bpf" +}