FreeBSD/sys/net/netisr.c
/*
 * Sysctl monitoring for netisr: query a list of registered protocols.
 */
Sysctl monitoring for netisr: query a list of registered protocols.
Sysctl monitoring for netisr : query a list of registered protocols .
static int
sysctl_netisr_proto(SYSCTL_HANDLER_ARGS)
{
	struct rm_priotracker tracker;
	struct sysctl_netisr_proto *snpp, *snp_array;
	struct netisr_proto *npp;
	u_int counter, proto;
	int error;
	if (req->newptr != NULL)
		return (EINVAL);
	snp_array = malloc(sizeof(*snp_array) * NETISR_MAXPROT, M_TEMP,
	    M_ZERO | M_WAITOK);
	counter = 0;
	NETISR_RLOCK(&tracker);
	for (proto = 0; proto < NETISR_MAXPROT; proto++) {
		npp = &netisr_proto[proto];
		if (npp->np_name == NULL)
			continue;
		snpp = &snp_array[counter];
		snpp->snp_version = sizeof(*snpp);
		strlcpy(snpp->snp_name, npp->np_name, NETISR_NAMEMAXLEN);
		snpp->snp_proto = proto;
		snpp->snp_qlimit = npp->np_qlimit;
		snpp->snp_policy = npp->np_policy;
		snpp->snp_dispatch = npp->np_dispatch;
		if (npp->np_m2flow != NULL)
			snpp->snp_flags |= NETISR_SNP_FLAGS_M2FLOW;
		if (npp->np_m2cpuid != NULL)
			snpp->snp_flags |= NETISR_SNP_FLAGS_M2CPUID;
		if (npp->np_drainedcpu != NULL)
			snpp->snp_flags |= NETISR_SNP_FLAGS_DRAINEDCPU;
		counter++;
	}
	NETISR_RUNLOCK(&tracker);
	KASSERT(counter <= NETISR_MAXPROT,
	    ("sysctl_netisr_proto: counter too big (%d)", counter));
	error = SYSCTL_OUT(req, snp_array, sizeof(*snp_array) * counter);
	free(snp_array, M_TEMP);
	return (error);
}
static int sysctl_netisr_proto ( SYSCTL_HANDLER_ARGS ) { struct rm_priotracker tracker ; struct sysctl_netisr_proto * snpp , * snp_array ; struct netisr_proto * npp ; u_int counter , proto ; int error ; if ( req -> newptr != NULL ) return ( EINVAL ) ; snp_array = malloc ( sizeof ( * snp_array ) * NETISR_MAXPROT , M_TEMP , M_ZERO | M_WAITOK ) ; counter = 0 ; NETISR_RLOCK ( & tracker ) ; for ( proto = 0 ; proto < NETISR_MAXPROT ; proto ++ ) { npp = & netisr_proto [ proto ] ; if ( npp -> np_name == NULL ) continue ; snpp = & snp_array [ counter ] ; snpp -> snp_version = sizeof ( * snpp ) ; strlcpy ( snpp -> snp_name , npp -> np_name , NETISR_NAMEMAXLEN ) ; snpp -> snp_proto = proto ; snpp -> snp_qlimit = npp -> np_qlimit ; snpp -> snp_policy = npp -> np_policy ; snpp -> snp_dispatch = npp -> np_dispatch ; if ( npp -> np_m2flow != NULL ) snpp -> snp_flags |= NETISR_SNP_FLAGS_M2FLOW ; if ( npp -> np_m2cpuid != NULL ) snpp -> snp_flags |= NETISR_SNP_FLAGS_M2CPUID ; if ( npp -> np_drainedcpu != NULL ) snpp -> snp_flags |= NETISR_SNP_FLAGS_DRAINEDCPU ; counter ++ ; } NETISR_RUNLOCK ( & tracker ) ; KASSERT ( counter <= NETISR_MAXPROT , ( " " , counter ) ) ; error = SYSCTL_OUT ( req , snp_array , sizeof ( * snp_array ) * counter ) ; free ( snp_array , M_TEMP ) ; return ( error ) ; }
Sysctl monitoring for netisr: query a list of registered protocols.
Sysctl monitoring for netisr : query a list of registered protocols .