Date: Thu, 24 Aug 2000 17:55:33 -0700 (PDT) From: Maksim Yevmenkin <m_evmenkin@yahoo.com> To: freebsd-current@freebsd.org Subject: patch: new DEVFS support for TAP driver Message-ID: <20000825005533.18338.qmail@web109.yahoomail.com>
index | next in thread | raw e-mail
[-- Attachment #1 --]
All,
please review, test and commit (if no objection :-) attached patch for
tap driver. this is to support new devfs.
thanks,
emax
__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/
[-- Attachment #2 --]
*** /sys/net/if_tap.c Wed Jul 26 20:38:46 2000
--- if_tap.c Thu Aug 24 20:39:59 2000
***************
*** 32,41 ****
/*
* $FreeBSD: src/sys/net/if_tap.c,v 1.3 2000/07/25 23:50:30 nsayer Exp $
! * $Id: if_tap.c,v 0.21 2000/07/23 21:46:02 max Exp $
*/
#include "opt_inet.h"
#include <sys/param.h>
#include <sys/conf.h>
--- 32,42 ----
/*
* $FreeBSD: src/sys/net/if_tap.c,v 1.3 2000/07/25 23:50:30 nsayer Exp $
! * $Id: if_tap.c,v 0.24 2000/08/25 01:39:59 max Exp $
*/
#include "opt_inet.h"
+ #include "opt_devfs.h"
#include <sys/param.h>
#include <sys/conf.h>
***************
*** 66,71 ****
--- 67,77 ----
#include <net/if_tapvar.h>
#include <net/if_tap.h>
+ #ifdef DEVFS
+ #include <sys/eventhandler.h>
+ #include <fs/devfs/devfs.h>
+ #endif
+
#define CDEV_NAME "tap"
#define CDEV_MAJOR 149
***************
*** 77,82 ****
--- 83,91 ----
/* module */
static int tapmodevent __P((module_t, int, void *));
+ #ifdef DEVFS
+ static void tapclone __P((void *, char *, int, dev_t *));
+ #endif
/* device */
static void tapcreate __P((dev_t));
***************
*** 132,157 ****
void *data;
{
static int attached = 0;
! struct ifnet *ifp = NULL;
! int unit, s;
switch (type) {
case MOD_LOAD:
if (attached)
return (EEXIST);
!
cdevsw_add(&tap_cdevsw);
attached = 1;
break;
! case MOD_UNLOAD:
if (taprefcnt > 0)
return (EBUSY);
cdevsw_remove(&tap_cdevsw);
- unit = 0;
- while (unit <= taplastunit) {
s = splimp();
TAILQ_FOREACH(ifp, &ifnet, if_link)
if ((strcmp(ifp->if_name, TAP) == 0) ||
--- 141,178 ----
void *data;
{
static int attached = 0;
! #ifdef DEVFS
! static eventhandler_tag eh_tag;
! #endif
switch (type) {
case MOD_LOAD:
if (attached)
return (EEXIST);
! #ifdef DEVFS
! eh_tag = EVENTHANDLER_REGISTER(devfs_clone, tapclone, 0, 1000);
! #else
cdevsw_add(&tap_cdevsw);
+ #endif
attached = 1;
break;
! case MOD_UNLOAD: {
! int unit;
!
if (taprefcnt > 0)
return (EBUSY);
+ #ifdef DEVFS
+ EVENTHANDLER_DEREGISTER(devfs_close, eh_tag);
+ #else
cdevsw_remove(&tap_cdevsw);
+ #endif
+
+ for (unit = 0; unit <= taplastunit; ) {
+ int s;
+ struct ifnet *ifp = NULL;
s = splimp();
TAILQ_FOREACH(ifp, &ifnet, if_link)
if ((strcmp(ifp->if_name, TAP) == 0) ||
***************
*** 179,185 ****
}
attached = 0;
! break;
default:
return (EOPNOTSUPP);
--- 200,207 ----
}
attached = 0;
! taplastunit = -1;
! } break;
default:
return (EOPNOTSUPP);
***************
*** 187,192 ****
--- 209,249 ----
return (0);
} /* tapmodevent */
+
+
+ #ifdef DEVFS
+ /*
+ * tapclone - DEVFS handler
+ *
+ * we need to support two kind of devices tap and vmnet
+ */
+ static void
+ tapclone(arg, name, namelen, dev)
+ void *arg;
+ char *name;
+ int namelen;
+ dev_t *dev;
+ {
+ int unit, minor;
+ char *device_name;
+
+ if (*dev != NODEV)
+ return;
+
+ device_name = TAP;
+ if (devfs_stdclone(name, NULL, device_name, &unit) != 1) {
+ device_name = VMNET;
+ if (devfs_stdclone(name, NULL, device_name, &unit) != 1)
+ return;
+ minor = (unit | VMNET_DEV_MASK);
+ }
+ else
+ minor = unit;
+
+ *dev = make_dev(&tap_cdevsw, minor,
+ UID_ROOT, GID_WHEEL, 0600, "%s%d", device_name, unit);
+ } /* tapclone */
+ #endif
/*
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000825005533.18338.qmail>
