/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
if ((s = rump_sys_socket(PF_ROUTE, SOCK_RAW, 0)) == -1)
atf_tc_fail_errno("routing socket");
/*
* set MTU for interface so that route MTU doesn't
* get overridden by it.
*/
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, "lo0");
ifr.ifr_mtu = 1300;
if (rump_sys_ioctl(s, SIOCSIFMTU, &ifr) == -1)
atf_tc_fail_errno("set mtu");
/*
* 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;
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;
}