Bug 290575 - sys/net/if_tun_test:transient test fails intermittently in CI
Summary: sys/net/if_tun_test:transient test fails intermittently in CI
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: tests (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Kyle Evans
URL: https://ci.freebsd.org/view/Test/job/...
Keywords: regression
Depends on:
Blocks:
 
Reported: 2025-10-27 14:26 UTC by Siva Mahadevan
Modified: 2025-11-05 00:32 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Siva Mahadevan freebsd_committer freebsd_triage 2025-10-27 14:26:59 UTC
The 'sys/net/if_tun_test:transient' testcase is now failing in CI:


===> sys/net/if_tun_test:transient
Result:     failed: Test case body timed out

Standard output:
Executing command [ jexec one ifconfig tun0 ]


I can reproduce this error locally using Bricoler with 100 runs for good measure:

$ bricoler run freebsd-src-regression-suite --param freebsd-src:url=/usr/src --param freebsd-src:branch= --param freebsd-src-regression-suite:hypervisor=bhyve --param freebsd-src-regression-suite:memory=4096 --param freebsd-src-regression-suite:ncpus=2 --param freebsd-src-regression-suite:parallelism=1 --param freebsd-src-regression-suite:count=100 --param freebsd-src-regression-suite:tests='sys/net/if_tun_test:transient'

@kib, I have bisected the failure to your commit https://cgit.freebsd.org/src/commit/?id=4dbe6628179d8e6bf400bfdb4bfa869bdc102a56 (devfs: make destroy_dev() a release barrier for cdevpriv destructors runs). Please triage as necessary.

@kevans, cc'd you since you added the tests in commit https://cgit.freebsd.org/src/commit/?id=a1174b3b1174754b1f69406bff4456d002e8f583 (tun(4)/tap(4): allow devices to be configured as transient).
Comment 1 Kyle Evans freebsd_committer freebsd_triage 2025-10-27 14:30:15 UTC
Yeah, I could see that... I'll take this one.
Comment 2 Kyle Evans freebsd_committer freebsd_triage 2025-10-27 14:32:25 UTC
(The problem is that transient tunnels will destroy the cloner and thus, the cdev, from the dtor; thus, we can't make any progress)
Comment 3 Kyle Evans freebsd_committer freebsd_triage 2025-10-29 01:11:09 UTC
I have a change prepared that moves removal of the tun device into a taskqueue, I'm just working through the different bits we need to consider.  The test is probably technically flakey after this if left untouched because we no longer 'guarantee' (it was never a written one) that the interface has been removed by the time close(2) returns.  I'm not sure how much I care in practice: if you want it to be transient anyways, you might as well take advantage of /dev/tun cloning to avoid relying on an arbitrary unit number.
Comment 4 Kyle Evans freebsd_committer freebsd_triage 2025-10-29 15:19:17 UTC
https://reviews.freebsd.org/D53438
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-11-05 00:28:28 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=96c1d8db39dfeea78ea3f27d67649252a39bbf2e

commit 96c1d8db39dfeea78ea3f27d67649252a39bbf2e
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2025-11-05 00:28:02 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2025-11-05 00:28:02 +0000

    if_tuntap: defer transient destroy_dev() to a taskqueue

    We're in the dtor, so we can't destroy it now without deadlocking after
    recent changes to make destroy_dev() provide a barrier.  However, we
    know there isn't any other dtor to run, so we can go ahead and clean up
    our state and just prevent a use-after-free if someone races to open
    the device while we're trying to destroy it.  tunopen() now uses the
    net epoch to protect against softc release by a concurrent
    tun_destroy().

    While we're here, allow a destroy operation to proceed if we caught a
    signal in cv_wait_sig() but tun_busy dropped to 0 while we were waiting
    to acquire the lock.

    This was more of an inherent design flaw, rather than a bug in the
    below-refed commit.

    PR:             290575
    Fixes:  4dbe6628179d ("devfs: make destroy_dev() a release [...]")
    Reviewed by:    kib, markj
    Differential Revision:  https://reviews.freebsd.org/D53438

 sys/net/if_tuntap.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 57 insertions(+), 6 deletions(-)
Comment 6 Kyle Evans freebsd_committer freebsd_triage 2025-11-05 00:32:19 UTC
The bug hasn't been MFC'd and the fix has landed in main; thanks for the report-