Wed May 27 23:41:20 2009 UTC ()
Add a dummyif, which doesn't actually traffic any cargo, but since
it has no backend it can always be attached and is therefore
convenient for testing ifconfig.


(pooka)
diff -r1.1 -r1.2 src/sys/rump/librump/rumpnet/rump_net_private.h
diff -r1.2 -r1.3 src/sys/rump/net/lib/Makefile.inc
diff -r1.9 -r1.10 src/sys/rump/net/lib/libvirtif/if_virt.c

cvs diff -r1.1 -r1.2 src/sys/rump/librump/rumpnet/rump_net_private.h (expand / switch to unified diff)

--- src/sys/rump/librump/rumpnet/rump_net_private.h 2008/10/15 13:00:40 1.1
+++ src/sys/rump/librump/rumpnet/rump_net_private.h 2009/05/27 23:41:20 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rump_net_private.h,v 1.1 2008/10/15 13:00:40 pooka Exp $ */ 1/* $NetBSD: rump_net_private.h,v 1.2 2009/05/27 23:41:20 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2008 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -21,14 +21,16 @@ @@ -21,14 +21,16 @@
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28#ifndef _SYS_RUMP_NET_PRIVATE_H_ 28#ifndef _SYS_RUMP_NET_PRIVATE_H_
29#define _SYS_RUMP_NET_PRIVATE_H_ 29#define _SYS_RUMP_NET_PRIVATE_H_
30 30
31void rump_net_init(void); 31void rump_net_init(void);
32void rump_netisr_init(void); 32void rump_netisr_init(void);
33 33
 34void rump_dummyif_create(void);
 35
34#endif /* _SYS_RUMP_NET_PRIVATE_H_ */ 36#endif /* _SYS_RUMP_NET_PRIVATE_H_ */

cvs diff -r1.2 -r1.3 src/sys/rump/net/lib/Makefile.inc (expand / switch to unified diff)

--- src/sys/rump/net/lib/Makefile.inc 2009/01/01 19:43:58 1.2
+++ src/sys/rump/net/lib/Makefile.inc 2009/05/27 23:41:20 1.3
@@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
1# $NetBSD: Makefile.inc,v 1.2 2009/01/01 19:43:58 pooka Exp $ 1# $NetBSD: Makefile.inc,v 1.3 2009/05/27 23:41:20 pooka Exp $
2# 2#
3 3
4RUMPTOP= ${.CURDIR}/../../.. 4RUMPTOP= ${.CURDIR}/../../..
5CPPFLAGS+= -I${RUMPTOP}/librump/rumpnet/opt 5CPPFLAGS+= -I${RUMPTOP}/librump/rumpnet -I${RUMPTOP}/librump/rumpnet/opt
6 6
7.include "${RUMPTOP}/Makefile.rump" 7.include "${RUMPTOP}/Makefile.rump"

cvs diff -r1.9 -r1.10 src/sys/rump/net/lib/libvirtif/if_virt.c (expand / switch to unified diff)

--- src/sys/rump/net/lib/libvirtif/if_virt.c 2009/05/26 19:03:05 1.9
+++ src/sys/rump/net/lib/libvirtif/if_virt.c 2009/05/27 23:41:20 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_virt.c,v 1.9 2009/05/26 19:03:05 pooka Exp $ */ 1/* $NetBSD: if_virt.c,v 1.10 2009/05/27 23:41:20 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2008 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -16,48 +16,49 @@ @@ -16,48 +16,49 @@
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.9 2009/05/26 19:03:05 pooka Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.10 2009/05/27 23:41:20 pooka Exp $");
30 30
31#include <sys/param.h> 31#include <sys/param.h>
32#include <sys/condvar.h> 32#include <sys/condvar.h>
33#include <sys/fcntl.h> 33#include <sys/fcntl.h>
34#include <sys/kmem.h> 34#include <sys/kmem.h>
35#include <sys/kthread.h> 35#include <sys/kthread.h>
36#include <sys/mutex.h> 36#include <sys/mutex.h>
37#include <sys/sockio.h> 37#include <sys/sockio.h>
38#include <sys/socketvar.h> 38#include <sys/socketvar.h>
39 39
40#include <net/if.h> 40#include <net/if.h>
41#include <net/if_ether.h> 41#include <net/if_ether.h>
42#include <net/if_tap.h> 42#include <net/if_tap.h>
43 43
44#include <netinet/in.h> 44#include <netinet/in.h>
45#include <netinet/in_var.h> 45#include <netinet/in_var.h>
46 46
47#include <rump/rump.h> 47#include <rump/rump.h>
48#include <rump/rumpuser.h> 48#include <rump/rumpuser.h>
49 49
50#include "rump_private.h" 50#include "rump_private.h"
 51#include "rump_net_private.h"
51 52
52/* 53/*
53 * Virtual interface for userspace purposes. Uses tap(4) to 54 * Virtual interface for userspace purposes. Uses tap(4) to
54 * interface with the kernel and just simply shovels data 55 * interface with the kernel and just simply shovels data
55 * to/from /dev/tap. 56 * to/from /dev/tap.
56 */ 57 */
57 58
58#define VIRTIF_BASE "virt" 59#define VIRTIF_BASE "virt"
59 60
60static int virtif_init(struct ifnet *); 61static int virtif_init(struct ifnet *);
61static int virtif_ioctl(struct ifnet *, u_long, void *); 62static int virtif_ioctl(struct ifnet *, u_long, void *);
62static void virtif_start(struct ifnet *); 63static void virtif_start(struct ifnet *);
63static void virtif_stop(struct ifnet *, int); 64static void virtif_stop(struct ifnet *, int);
@@ -243,13 +244,59 @@ virtif_sender(void *arg) @@ -243,13 +244,59 @@ virtif_sender(void *arg)
243 io[i].iov_base = mtod(m, void *); 244 io[i].iov_base = mtod(m, void *);
244 io[i].iov_len = m->m_len; 245 io[i].iov_len = m->m_len;
245 m = m->m_next; 246 m = m->m_next;
246 } 247 }
247 if (i == 16) 248 if (i == 16)
248 panic("lazy bum"); 249 panic("lazy bum");
249 rumpuser_writev(sc->sc_tapfd, io, i, &error); 250 rumpuser_writev(sc->sc_tapfd, io, i, &error);
250 m_freem(m0); 251 m_freem(m0);
251 mutex_enter(&sc->sc_sendmtx); 252 mutex_enter(&sc->sc_sendmtx);
252 } 253 }
253 254
254 mutex_exit(softnet_lock); 255 mutex_exit(softnet_lock);
255} 256}
 257
 258/*
 259 * dummyif is a nada-interface.
 260 * As it requires nothing external, it can be used for testing
 261 * interface configuration.
 262 */
 263static int dummyif_init(struct ifnet *);
 264static void dummyif_start(struct ifnet *);
 265
 266void
 267rump_dummyif_create()
 268{
 269 struct ifnet *ifp;
 270 struct ethercom *ec;
 271 uint8_t enaddr[ETHER_ADDR_LEN] = { 0xb2, 0x0a, 0x00, 0x0b, 0x0e, 0x01 };
 272
 273 enaddr[2] = arc4random() & 0xff;
 274 enaddr[5] = arc4random() & 0xff;
 275
 276 ec = kmem_zalloc(sizeof(*ec), KM_SLEEP);
 277
 278 ifp = &ec->ec_if;
 279 strlcpy(ifp->if_xname, "dummy0", sizeof(ifp->if_xname));
 280 ifp->if_softc = ifp;
 281 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 282 ifp->if_init = dummyif_init;
 283 ifp->if_ioctl = virtif_ioctl;
 284 ifp->if_start = dummyif_start;
 285
 286 if_attach(ifp);
 287 ether_ifattach(ifp, enaddr);
 288}
 289
 290static int
 291dummyif_init(struct ifnet *ifp)
 292{
 293
 294 ifp->if_flags |= IFF_RUNNING;
 295 return 0;
 296}
 297
 298static void
 299dummyif_start(struct ifnet *ifp)
 300{
 301
 302}