Add a rump kernel component for the tap device.
from Wei Liu <wei.liu2@citrix.com> via private email
This commit is contained in:
parent
53e91c3012
commit
1c07d29649
|
@ -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
|
||||
|
|
|
@ -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>
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue