Module Name: src Committed By: pooka Date: Fri May 29 12:32:23 UTC 2015
Modified Files: src/sys/rump/net: Makefile.rumpnetcomp Added Files: src/sys/rump/net/lib/libtap: Makefile tap_component.c Log Message: Add a rump kernel component for the tap device. from Wei Liu <wei.l...@citrix.com> via private email To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/rump/net/Makefile.rumpnetcomp cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libtap/Makefile \ src/sys/rump/net/lib/libtap/tap_component.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/net/Makefile.rumpnetcomp diff -u src/sys/rump/net/Makefile.rumpnetcomp:1.10 src/sys/rump/net/Makefile.rumpnetcomp:1.11 --- src/sys/rump/net/Makefile.rumpnetcomp:1.10 Sat Nov 16 14:00:57 2013 +++ src/sys/rump/net/Makefile.rumpnetcomp Fri May 29 12:32:23 2015 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile.rumpnetcomp,v 1.10 2013/11/16 14:00:57 rmind Exp $ +# $NetBSD: Makefile.rumpnetcomp,v 1.11 2015/05/29 12:32:23 pooka Exp $ # .include <bsd.own.mk> RUMPNETCOMP= agr bridge net net80211 netbt netinet netinet6 -RUMPNETCOMP+= netmpls npf local shmif +RUMPNETCOMP+= netmpls npf local shmif tap .if ${MKSLJIT} != "no" RUMPNETCOMP+= bpfjit Added files: Index: src/sys/rump/net/lib/libtap/Makefile diff -u /dev/null src/sys/rump/net/lib/libtap/Makefile:1.1 --- /dev/null Fri May 29 12:32:23 2015 +++ src/sys/rump/net/lib/libtap/Makefile Fri May 29 12:32:23 2015 @@ -0,0 +1,15 @@ +# $NetBSD: Makefile,v 1.1 2015/05/29 12:32:23 pooka Exp $ +# + +.PATH: ${.CURDIR}/../../../../net + +LIB= rumpnet_tap + +SRCS= if_tap.c + +SRCS+= tap_component.c + +CPPFLAGS+= -I${.CURDIR}/../libnet/opt -I${.CURDIR}/../../../librump/rumpvfs + +.include <bsd.lib.mk> +.include <bsd.klinks.mk> Index: src/sys/rump/net/lib/libtap/tap_component.c diff -u /dev/null src/sys/rump/net/lib/libtap/tap_component.c:1.1 --- /dev/null Fri May 29 12:32:23 2015 +++ src/sys/rump/net/lib/libtap/tap_component.c Fri May 29 12:32:23 2015 @@ -0,0 +1,64 @@ +/* $NetBSD: tap_component.c,v 1.1 2015/05/29 12:32:23 pooka Exp $ */ + +/* + * Copyright (c) 2015 Wei Liu. 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 AUTHOR ``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 AUTHOR 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. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: tap_component.c,v 1.1 2015/05/29 12:32:23 pooka Exp $"); + +#include <sys/param.h> +#include <sys/device.h> +#include <sys/stat.h> + +#include "rump_private.h" +#include "rump_net_private.h" +#include "rump_vfs_private.h" + +CFDRIVER_DECL(tap, DV_IFNET, NULL); + +void tapattach(int); + +RUMP_COMPONENT(RUMP_COMPONENT_NET_IF) +{ + extern const struct cdevsw tap_cdevsw; + devmajor_t bmaj, cmaj; + int error; + + config_cfdriver_attach(&tap_cd); + tapattach(0); + + bmaj = cmaj = NODEVMAJOR; + error = devsw_attach("tap", NULL, &bmaj, &tap_cdevsw, &cmaj); + if (error != 0) + panic("tap devsw attach failed: %d", error); + + error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/tap", cmaj, 0xfffff); + if (error != 0) + panic("cannot create tap device node: %d", error); + + error = rump_vfs_makedevnodes(S_IFCHR, "/dev/tap", '0', cmaj, 0, 4); + if (error != 0) + panic("cannot create tap[0-4] device node: %d", error); +}