Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/net Add a rump kernel component for the tap device.
details: https://anonhg.NetBSD.org/src/rev/a036422ed923
branches: trunk
changeset: 338532:a036422ed923
user: pooka <pooka%NetBSD.org@localhost>
date: Fri May 29 12:32:23 2015 +0000
description:
Add a rump kernel component for the tap device.
from Wei Liu <wei.liu2%citrix.com@localhost> via private email
diffstat:
sys/rump/net/Makefile.rumpnetcomp | 4 +-
sys/rump/net/lib/libtap/Makefile | 15 +++++++
sys/rump/net/lib/libtap/tap_component.c | 64 +++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+), 2 deletions(-)
diffs (103 lines):
diff -r 72b41117e677 -r a036422ed923 sys/rump/net/Makefile.rumpnetcomp
--- a/sys/rump/net/Makefile.rumpnetcomp Fri May 29 12:28:08 2015 +0000
+++ b/sys/rump/net/Makefile.rumpnetcomp Fri May 29 12:32:23 2015 +0000
@@ -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
diff -r 72b41117e677 -r a036422ed923 sys/rump/net/lib/libtap/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/net/lib/libtap/Makefile Fri May 29 12:32:23 2015 +0000
@@ -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>
diff -r 72b41117e677 -r a036422ed923 sys/rump/net/lib/libtap/tap_component.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/net/lib/libtap/tap_component.c Fri May 29 12:32:23 2015 +0000
@@ -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);
+}
Home |
Main Index |
Thread Index |
Old Index