From nobody Thu Feb 19 02:54:54 2026 X-Original-To: dev-commits-src-main@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 4fGdJt56jtz6S6QS for ; Thu, 19 Feb 2026 02:54:54 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fGdJt4VJBz3RGq for ; Thu, 19 Feb 2026 02:54:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1771469694; 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=MseofinPBJ2yRLGvQT3AcgiO1EYzUDDmSY8KMjXJAgE=; b=bRBEMQJc30Man/juNfHDM2L2KzFYNsD1rqiQ4yNfR493zFuqdtHAIf9oPqSVhlrPvcxYIG +D7yMFKRPMGkHL3ILYudotoiyphWDCsjkEBO/xOTRPgK5TKYjaTaYTV6xN/sbRhBNpAJjq TY3OpHdBblrzKq8SgZcCrBUFSPw0O2wUU3KmZX+hZWXNNRwzQX/YvqcAM3PxiG377HUnvv wgb0JgDgZCpMZp8446/4wliUQE+VI3MOHaBTcS6l77fTkCLg+jeXDvr5qzaibsYmln/CkX pyo4J79RnemvLzqbd74soYkoG27amMc5gemjMq+3R2ZMkDoChIrnQ/3Z7JTTaA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1771469694; a=rsa-sha256; cv=none; b=MJ+Z8MWmrzaxvLHr20H08UMoqNbIm1PVfxn4JH0UsalTodGM2EEEFUJ9wm8NoDQQY69fd6 keyv2oJaQTZyx58vv23ef+lc4nK1DuzsS6+PwnjCn5aWG+a2rVGFn+dRNrY0zhy6zsFQdC EB3wk5z9ALLAqSxKiDKt8ZG2LsEvy2Zib3oEt5KUxVwLRTaeKFo1hmGVCBWlA9MScyMJ2f wKYzAh7YWTmLmSNw69x7qlU1REd0LGduZLO2Cz7lEydJsx6a+FuuWDZO/AXWoxFQEaKKrP qMVrVNTPfc08R9GvL5HKLo0q8r0wwrPB9BUbM98AfSA1x9MhbR3AbPaJVQTj6g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1771469694; 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=MseofinPBJ2yRLGvQT3AcgiO1EYzUDDmSY8KMjXJAgE=; b=sdT4nddLMZE/CVJljeMIH5K02w3Du0NpzjzNxr38AEIxQ7+/uDPQA+dJFaTqkVg9DjBByp 7LW1euz3G7085NktsqAIZk9ebuhu5Yve28IN/LpXc9mVkYKP7wsngEUiZKAs/v9Yx4l1O4 NcWDiFzrDDpMUy7aXaSbMDus1WXAnj6lSJHGmU0yHknJk/W3cR42vGTotSgSmzCElmm18s QOaf1+XsNf4cxjp2kK+khzMCf2hNwybwNoDGmZ9w82EUyxIuYUWcvSvQnlOqbcInG77lye 8ii0oMO5cp8Kfa3m9zBKM7nI/Reky4yEFiiby+FxXI6gpLi7Lp1sf7lrxuny+A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fGdJt3mLhz7yP for ; Thu, 19 Feb 2026 02:54:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1e435 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 19 Feb 2026 02:54:54 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 38edf96b1787 - main - tests/ipfw: fix log:bpf test flakyness List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 38edf96b1787ce3d8c00e4466348dab891c7a9ea Auto-Submitted: auto-generated Date: Thu, 19 Feb 2026 02:54:54 +0000 Message-Id: <69967b7e.1e435.602c8299@gitrepo.freebsd.org> The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=38edf96b1787ce3d8c00e4466348dab891c7a9ea commit 38edf96b1787ce3d8c00e4466348dab891c7a9ea Author: Gleb Smirnoff AuthorDate: 2026-02-19 02:39:00 +0000 Commit: Gleb Smirnoff CommitDate: 2026-02-19 02:53:16 +0000 tests/ipfw: fix log:bpf test flakyness There were several problems: o Using 'netstat -B' is not a reliable way to make sure that all tcpdumps have attached to bpf(4). The problem is that tcpdump (via libpcap) does several ioctl(2)s after the attach including two BIOCSETF. Each of them flushes the input buffer. So we can see tcpdump attached in 'netstat -B' and start sending packets and the packet will be captured by bpf(4) before BIOCSETF and freed and tcpdump won't read anything. Instead of using netstat(1), use ps(1) and make sure each tcpdump is blocked on the "bpf" wait channel, which guarantees it is done with ioctl(2)s and is now blocked in read(2). o Using 'nc -w 0' sets timeout not only on the connect(2) (as documented) but also on poll(2), which is not documented. There is a race in shell that will make stdin not yet filled by 'echo foo' when nc(1) does poll(2). With zero timeout, this poll(2) will immediately return and nc will exit. o The waiting loop had two errors: using wrong variable name as well as invoking a subshell, that actually can't wait on the pid. o The reading tcpdump was lacking '-q' option, that prevents any protocol interpretations. Sometimes, when random port chosen by nc(1) would match some well-known (to tcpdump) port, the output would differ from the expected. PR: 293241 --- tests/sys/netpfil/ipfw/log.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/sys/netpfil/ipfw/log.sh b/tests/sys/netpfil/ipfw/log.sh index 7df5c69e4219..cde909e25d1e 100755 --- a/tests/sys/netpfil/ipfw/log.sh +++ b/tests/sys/netpfil/ipfw/log.sh @@ -57,31 +57,34 @@ bpf_body() 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; + # wait for tcpdumps to fully attach and block in bpfread() + for p in ${pids}; do + while [ $(ps -o wchan ${p} | tr "\n" " " | cut -w -f 2) != \ + "bpf" ]; do + sleep 0.01; + done done for p in ${rules} 666; do - echo foo | nc -u 192.0.2.1 10${p} -w 0 + echo foo | nc -u 192.0.2.1 10${p} done for p in ${pids}; do - atf_check -s exit:0 sh -c "wait $pid; exit $?" + wait ${p} + atf_check_equal 0 $? 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 + tcpdump -qnr ${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 + tcpdump -qnr ${PWD}/${auto}.pcap } bpf_cleanup()