Module Name: src Committed By: pooka Date: Wed May 27 23:41:20 UTC 2009
Modified Files: src/sys/rump/librump/rumpnet: rump_net_private.h src/sys/rump/net/lib: Makefile.inc src/sys/rump/net/lib/libvirtif: if_virt.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/rump/librump/rumpnet/rump_net_private.h cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/Makefile.inc cvs rdiff -u -r1.9 -r1.10 src/sys/rump/net/lib/libvirtif/if_virt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/rump/librump/rumpnet/rump_net_private.h diff -u src/sys/rump/librump/rumpnet/rump_net_private.h:1.1 src/sys/rump/librump/rumpnet/rump_net_private.h:1.2 --- src/sys/rump/librump/rumpnet/rump_net_private.h:1.1 Wed Oct 15 13:00:40 2008 +++ src/sys/rump/librump/rumpnet/rump_net_private.h Wed May 27 23:41:20 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_net_private.h,v 1.1 2008/10/15 13:00:40 pooka Exp $ */ +/* $NetBSD: rump_net_private.h,v 1.2 2009/05/27 23:41:20 pooka Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -31,4 +31,6 @@ void rump_net_init(void); void rump_netisr_init(void); +void rump_dummyif_create(void); + #endif /* _SYS_RUMP_NET_PRIVATE_H_ */ Index: src/sys/rump/net/lib/Makefile.inc diff -u src/sys/rump/net/lib/Makefile.inc:1.2 src/sys/rump/net/lib/Makefile.inc:1.3 --- src/sys/rump/net/lib/Makefile.inc:1.2 Thu Jan 1 19:43:58 2009 +++ src/sys/rump/net/lib/Makefile.inc Wed May 27 23:41:20 2009 @@ -1,7 +1,7 @@ -# $NetBSD: Makefile.inc,v 1.2 2009/01/01 19:43:58 pooka Exp $ +# $NetBSD: Makefile.inc,v 1.3 2009/05/27 23:41:20 pooka Exp $ # RUMPTOP= ${.CURDIR}/../../.. -CPPFLAGS+= -I${RUMPTOP}/librump/rumpnet/opt +CPPFLAGS+= -I${RUMPTOP}/librump/rumpnet -I${RUMPTOP}/librump/rumpnet/opt .include "${RUMPTOP}/Makefile.rump" Index: src/sys/rump/net/lib/libvirtif/if_virt.c diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.9 src/sys/rump/net/lib/libvirtif/if_virt.c:1.10 --- src/sys/rump/net/lib/libvirtif/if_virt.c:1.9 Tue May 26 19:03:05 2009 +++ src/sys/rump/net/lib/libvirtif/if_virt.c Wed May 27 23:41:20 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_virt.c,v 1.9 2009/05/26 19:03:05 pooka Exp $ */ +/* $NetBSD: if_virt.c,v 1.10 2009/05/27 23:41:20 pooka Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.9 2009/05/26 19:03:05 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.10 2009/05/27 23:41:20 pooka Exp $"); #include <sys/param.h> #include <sys/condvar.h> @@ -48,6 +48,7 @@ #include <rump/rumpuser.h> #include "rump_private.h" +#include "rump_net_private.h" /* * Virtual interface for userspace purposes. Uses tap(4) to @@ -253,3 +254,49 @@ mutex_exit(softnet_lock); } + +/* + * dummyif is a nada-interface. + * As it requires nothing external, it can be used for testing + * interface configuration. + */ +static int dummyif_init(struct ifnet *); +static void dummyif_start(struct ifnet *); + +void +rump_dummyif_create() +{ + struct ifnet *ifp; + struct ethercom *ec; + uint8_t enaddr[ETHER_ADDR_LEN] = { 0xb2, 0x0a, 0x00, 0x0b, 0x0e, 0x01 }; + + enaddr[2] = arc4random() & 0xff; + enaddr[5] = arc4random() & 0xff; + + ec = kmem_zalloc(sizeof(*ec), KM_SLEEP); + + ifp = &ec->ec_if; + strlcpy(ifp->if_xname, "dummy0", sizeof(ifp->if_xname)); + ifp->if_softc = ifp; + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_init = dummyif_init; + ifp->if_ioctl = virtif_ioctl; + ifp->if_start = dummyif_start; + + if_attach(ifp); + ether_ifattach(ifp, enaddr); +} + +static int +dummyif_init(struct ifnet *ifp) +{ + + ifp->if_flags |= IFF_RUNNING; + return 0; +} + +static void +dummyif_start(struct ifnet *ifp) +{ + +}