Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 03 Mar 2024 14:50:11 +0000
From:      bugzilla-noreply@freebsd.org
To:        net@FreeBSD.org
Subject:   [Bug 277435] [Feature request] Add an option to destroy the tap/tun interface when the descriptor is closed
Message-ID:  <bug-277435-7501-MgXNwxRPTb@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-277435-7501@https.bugs.freebsd.org/bugzilla/>
References:  <bug-277435-7501@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277435

--- Comment #4 from Nikolay Borodin <monsterovich@gmail.com> ---
(In reply to Kyle Evans from comment #3)
> though you can destroy it, you just have to close it first

You can't. If you try to do this via SIOCIFDESTROY inside an application wh=
ich
uses the descriptor, the application will hang, even if you do ioctl after
close(fd)

The sample code from my application:

JFUNC(void, close) {
    close(getFd(env, this));

    struct ifreq ifr;
    memset(&ifr, 0, sizeof(ifr));
    strcpy(ifr.ifr_name, "tap0");
    int sock =3D socket(PF_INET, SOCK_STREAM, 0);
    ioctl(sock, SIOCIFDESTROY, &ifr); // hangs
}

After that, you can only terminate the application via kill -9 <pid>.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-277435-7501-MgXNwxRPTb>