FreeBSD/contrib/netbsd-tests/net/if_loop/t_pr.c
/*
 * Turn on checksums on loopback interfaces
 */
Turn on checksums on loopback interfaces
Turn on checksums on loopback interfaces
static int
enable_locsums(void)
{
	struct sysctlnode q, ans[256];
	int mib[5], enable;
	size_t alen;
	unsigned i;
	mib[0] = CTL_NET;
	mib[1] = PF_INET;
	mib[2] = IPPROTO_IP;
	mib[3] = CTL_QUERY;
	alen = sizeof(ans);
	memset(&q, 0, sizeof(q));
	q.sysctl_flags = SYSCTL_VERSION;
	if (rump_sys___sysctl(mib, 4, ans, &alen, &q, sizeof(q)) == -1)
		return -1;
	for (i = 0; i < __arraycount(ans); i++)
		if (strcmp("do_loopback_cksum", ans[i].sysctl_name) == 0)
			break;
	if (i == __arraycount(ans)) {
		errno = ENOENT;
		return -1;
	}
	mib[3] = ans[i].sysctl_num;
	enable = 1;
	if (rump_sys___sysctl(mib, 4, NULL, NULL, &enable,
	    sizeof(enable)) == -1)
		return errno;
	return 0;
}
static int enable_locsums ( void ) { struct sysctlnode q , ans [ 256 ] ; int mib [ 5 ] , enable ; size_t alen ; unsigned i ; mib [ 0 ] = CTL_NET ; mib [ 1 ] = PF_INET ; mib [ 2 ] = IPPROTO_IP ; mib [ 3 ] = CTL_QUERY ; alen = sizeof ( ans ) ; memset ( & q , 0 , sizeof ( q ) ) ; q . sysctl_flags = SYSCTL_VERSION ; if ( rump_sys___sysctl ( mib , 4 , ans , & alen , & q , sizeof ( q ) ) == -1 ) return -1 ; for ( i = 0 ; i < __arraycount ( ans ) ; i ++ ) if ( strcmp ( " " , ans [ i ] . sysctl_name ) == 0 ) break ; if ( i == __arraycount ( ans ) ) { errno = ENOENT ; return -1 ; } mib [ 3 ] = ans [ i ] . sysctl_num ; enable = 1 ; if ( rump_sys___sysctl ( mib , 4 , NULL , NULL , & enable , sizeof ( enable ) ) == -1 ) return errno ; return 0 ; }
Turn on checksums on loopback interfaces
Turn on checksums on loopback interfaces