if_tuntap: use ifnet_rename_event instead of ifnet_arrival_event

This commit is contained in:
Gleb Smirnoff
2025-12-21 15:57:12 -08:00
parent 0bd0c3295a
commit b275907fa3
+6 -12
View File
@@ -179,7 +179,7 @@ struct tuntap_softc {
* which are static after setup. * which are static after setup.
*/ */
static struct mtx tunmtx; static struct mtx tunmtx;
static eventhandler_tag arrival_tag; static eventhandler_tag rename_tag;
static eventhandler_tag clone_tag; static eventhandler_tag clone_tag;
static int tuntap_osd_jail_slot; static int tuntap_osd_jail_slot;
static const char tunname[] = "tun"; static const char tunname[] = "tun";
@@ -741,7 +741,7 @@ tun_uninit(const void *unused __unused)
struct tuntap_softc *tp; struct tuntap_softc *tp;
int i; int i;
EVENTHANDLER_DEREGISTER(ifnet_arrival_event, arrival_tag); EVENTHANDLER_DEREGISTER(ifnet_rename_event, rename_tag);
EVENTHANDLER_DEREGISTER(dev_clone, clone_tag); EVENTHANDLER_DEREGISTER(dev_clone, clone_tag);
CURVNET_SET(vnet0); CURVNET_SET(vnet0);
@@ -833,13 +833,10 @@ tuntapmodevent(module_t mod, int type, void *data)
[PR_METHOD_REMOVE] = tuntap_prison_remove, [PR_METHOD_REMOVE] = tuntap_prison_remove,
}; };
tuntap_osd_jail_slot = osd_jail_register(NULL, methods); tuntap_osd_jail_slot = osd_jail_register(NULL, methods);
arrival_tag = EVENTHANDLER_REGISTER(ifnet_arrival_event, rename_tag = EVENTHANDLER_REGISTER(ifnet_rename_event,
tunrename, 0, 1000); tunrename, NULL, EVENTHANDLER_PRI_ANY);
if (arrival_tag == NULL) clone_tag = EVENTHANDLER_REGISTER(dev_clone, tunclone, NULL,
return (ENOMEM); EVENTHANDLER_PRI_ANY);
clone_tag = EVENTHANDLER_REGISTER(dev_clone, tunclone, 0, 1000);
if (clone_tag == NULL)
return (ENOMEM);
break; break;
case MOD_UNLOAD: case MOD_UNLOAD:
/* See tun_uninit(). */ /* See tun_uninit(). */
@@ -1080,9 +1077,6 @@ tunrename(void *arg __unused, struct ifnet *ifp)
struct tuntap_softc *tp; struct tuntap_softc *tp;
int error; int error;
if ((ifp->if_flags & IFF_RENAMING) == 0)
return;
if (tuntap_driver_from_ifnet(ifp) == NULL) if (tuntap_driver_from_ifnet(ifp) == NULL)
return; return;