Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net/config * add interface for virtif creation (in add...
details: https://anonhg.NetBSD.org/src/rev/a9d8043d21a7
branches: trunk
changeset: 757171:a9d8043d21a7
user: pooka <pooka%NetBSD.org@localhost>
date: Tue Aug 17 12:04:34 2010 +0000
description:
* add interface for virtif creation (in addition to the already present shmif)
* don't leak sockets
diffstat:
tests/net/config/netconfig.c | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
diffs (85 lines):
diff -r 946879baf12f -r a9d8043d21a7 tests/net/config/netconfig.c
--- a/tests/net/config/netconfig.c Tue Aug 17 11:47:27 2010 +0000
+++ b/tests/net/config/netconfig.c Tue Aug 17 12:04:34 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netconfig.c,v 1.5 2010/08/09 15:39:41 pooka Exp $ */
+/* $NetBSD: netconfig.c,v 1.6 2010/08/17 12:04:34 pooka Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: netconfig.c,v 1.5 2010/08/09 15:39:41 pooka Exp $");
+__RCSID("$NetBSD: netconfig.c,v 1.6 2010/08/17 12:04:34 pooka Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -54,7 +54,7 @@
#include "../../h_macros.h"
-static void
+static void __unused
netcfg_rump_makeshmif(const char *busname, char *ifname)
{
int rv, ifnum;
@@ -65,7 +65,18 @@
sprintf(ifname, "shmif%d", ifnum);
}
-static void
+static void __unused
+netcfg_rump_makevirtif(int ifnum, char *ifname)
+{
+ int rv;
+
+ if ((rv = rump_pub_virtif_create(ifnum)) != 0) {
+ atf_tc_fail("makeshmif: rump_pub_virtif_create %d", rv);
+ }
+ sprintf(ifname, "virt%d", ifnum);
+}
+
+static void __unused
netcfg_rump_if(const char *ifname, const char *addr, const char *mask)
{
struct ifaliasreq ia;
@@ -175,6 +186,7 @@
struct icmp icmp;
socklen_t slen;
int s;
+ bool rv = false;
s = rump_sys_socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
if (s == -1)
@@ -183,7 +195,7 @@
tv.tv_usec = 1000 * (ms_timo % 1000);
if (rump_sys_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,
&tv, sizeof(tv)) == -1)
- return false;
+ goto out;
memset(&sin, 0, sizeof(sin));
sin.sin_len = sizeof(sin);
@@ -197,12 +209,16 @@
slen = sizeof(sin);
if (rump_sys_sendto(s, &icmp, sizeof(icmp), 0,
- (struct sockaddr *)&sin, slen) == -1)
- return false;
+ (struct sockaddr *)&sin, slen) == -1) {
+ goto out;
+ }
if (rump_sys_recvfrom(s, &icmp, sizeof(icmp), 0,
(struct sockaddr *)&sin, &slen) == -1)
- return false;
+ goto out;
- return true;
+ rv = true;
+ out:
+ rump_sys_close(s);
+ return rv;
}
Home |
Main Index |
Thread Index |
Old Index