FreeBSD/sys/net/netisr.c
/*
 * Remove the registration of a network protocol, which requires clearing
 * per-protocol fields across all workstreams, including freeing all mbufs in
 * the queues at time of unregister.  All work in netisr is briefly suspended
 * while this takes place.
 */
Remove the registration of a network protocol, which requires clearing
per-protocol fields across all workstreams, including freeing all mbufs in
the queues at time of unregister.  All work in netisr is briefly suspended
while this takes place.
Remove the registration of a network protocol which requires clearing per - protocol fields across all workstreams including freeing all mbufs in the queues at time of unregister . All work in netisr is briefly suspended while this takes place .
void
netisr_unregister(const struct netisr_handler *nhp)
{
	VNET_ITERATOR_DECL(vnet_iter);
	struct netisr_work *npwp;
#ifdef INVARIANTS
	const char *name;
#endif
	u_int i, proto;
	proto = nhp->nh_proto;
#ifdef INVARIANTS
	name = nhp->nh_name;
#endif
	KASSERT(proto < NETISR_MAXPROT,
	    ("%s(%u): protocol too big for %s", __func__, proto, name));
	NETISR_WLOCK();
	KASSERT(netisr_proto[proto].np_handler != NULL,
	    ("%s(%u): protocol not registered for %s", __func__, proto,
	    name));
#ifdef VIMAGE
	VNET_LIST_RLOCK_NOSLEEP();
	VNET_FOREACH(vnet_iter) {
		CURVNET_SET(vnet_iter);
		V_netisr_enable[proto] = 0;
		CURVNET_RESTORE();
	}
	VNET_LIST_RUNLOCK_NOSLEEP();
#endif
	netisr_proto[proto].np_name = NULL;
	netisr_proto[proto].np_handler = NULL;
	netisr_proto[proto].np_m2flow = NULL;
	netisr_proto[proto].np_m2cpuid = NULL;
	netisr_proto[proto].np_qlimit = 0;
	netisr_proto[proto].np_policy = 0;
	CPU_FOREACH(i) {
		npwp = &(DPCPU_ID_PTR(i, nws))->nws_work[proto];
		netisr_drain_proto(npwp);
		bzero(npwp, sizeof(*npwp));
	}
	NETISR_WUNLOCK();
}
void netisr_unregister ( const struct netisr_handler * nhp ) { VNET_ITERATOR_DECL ( vnet_iter ) ; struct netisr_work * npwp ; #ifdef INVARIANTS const char * name ; #endif u_int i , proto ; proto = nhp -> nh_proto ; #ifdef INVARIANTS name = nhp -> nh_name ; #endif KASSERT ( proto < NETISR_MAXPROT , ( " " , __func__ , proto , name ) ) ; NETISR_WLOCK ( ) ; KASSERT ( netisr_proto [ proto ] . np_handler != NULL , ( " " , __func__ , proto , name ) ) ; #ifdef VIMAGE VNET_LIST_RLOCK_NOSLEEP ( ) ; VNET_FOREACH ( vnet_iter ) { CURVNET_SET ( vnet_iter ) ; V_netisr_enable [ proto ] = 0 ; CURVNET_RESTORE ( ) ; } VNET_LIST_RUNLOCK_NOSLEEP ( ) ; #endif netisr_proto [ proto ] . np_name = NULL ; netisr_proto [ proto ] . np_handler = NULL ; netisr_proto [ proto ] . np_m2flow = NULL ; netisr_proto [ proto ] . np_m2cpuid = NULL ; netisr_proto [ proto ] . np_qlimit = 0 ; netisr_proto [ proto ] . np_policy = 0 ; CPU_FOREACH ( i ) { npwp = & ( DPCPU_ID_PTR ( i , nws ) ) -> nws_work [ proto ] ; netisr_drain_proto ( npwp ) ; bzero ( npwp , sizeof ( * npwp ) ) ; } NETISR_WUNLOCK ( ) ; }
Remove the registration of a network protocol, which requires clearing
 per-protocol fields across all workstreams, including freeing all mbufs in
 the queues at time of unregister.
Remove the registration of a network protocol which requires clearing per - protocol fields across all workstreams including freeing all mbufs in the queues at time of unregister .