Subject: Re: trying ethfoo on NetBSD 2.0 [was: Re: [cube@cubidou.net: Re: Moving ethfoo in the main tree]]
To: None <tech-kern@netbsd.org>
From: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
List: tech-kern
Date: 12/18/2004 14:04:25
--mYCpIKhGyMATD0i+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Wed, Dec 15, 2004 at 10:43:36PM +0100, Hubert Feyrer wrote:
> I guess the Offset would give the major/minor number, but -1 is probably
> not the right one. Also, unloading paniced the system (dunno how, I was in
> X).
I took the 1.15 from CVS, messed with it, and now I'm using it to bridge
my ethernet over udp over ipsec over wlan to my laptop:
gatekeeper: {3} modstat
Type Id Offset Loadaddr Size Info Rev Module Name
DEV 0 -1/165 c3840000 0008 c3841ae0 2 ethfoo
gatekeeper: {4} ifconfig ethfoo0
ethfoo0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
address: f0:0b:a4:63:06:c2
media: Ethernet autoselect
inet6 fe80::f20b:a4ff:fe63:6c2%ethfoo0 prefixlen 64 scopeid 0x7
gatekeeper: {5}
To make it compile I had to violently rip out parts of the driver and
put some stuff from -current in, but it seems to work except for
destroying the clone and unloading the module. I did not really
understand what I was doing, I just tried to get rid of compiler errors
and warnings.
It would be great to see ethfoo/tap in 2.1, it is a really useful
feature.
--
%SYSTEM-F-ANARCHISM, The operating system has been overthrown
--mYCpIKhGyMATD0i+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=ethfoo_diff
--- ethfoo/ethfoo/ethfoo_lkm.c 2004-12-18 14:06:41.000000000 +0100
+++ ethfoo-messed/ethfoo/ethfoo_lkm.c 2004-12-18 12:29:19.000000000 +0100
@@ -169,6 +169,9 @@
static int ethfoo_fops_poll(struct file *, int, struct proc *);
static int ethfoo_fops_kqfilter(struct file *, struct knote *);
+int fnullop_fcntl(struct file *, u_int, void *, struct proc *);
+int fbadop_stat(struct file *, struct stat *, struct proc *);
+
static const struct fileops ethfoo_fileops = {
ethfoo_fops_read,
ethfoo_fops_write,
@@ -181,7 +184,7 @@
};
/* Helper for cloning open() */
-static int ethfoo_dev_cloner(struct proc *);
+/*static int ethfoo_dev_cloner(struct proc *);*/
/* Character device routines */
static int ethfoo_cdev_open(dev_t, int, int, struct proc *);
@@ -251,7 +254,7 @@
struct if_clone ethfoo_cloners = IF_CLONE_INITIALIZER("ethfoo",
ethfoo_clone_create,
- ethfoo_clone_destroy);
+ (void (*)(struct ifnet *))ethfoo_clone_destroy);
/* Helper functionis shared by the two cloning code paths */
static struct ethfoo_softc * ethfoo_clone_creator(int);
@@ -731,7 +734,7 @@
cf->cf_unit = unit;
cf->cf_fstate = FSTATE_STAR;
- return (struct ethfoo_softc *)config_attach_pseudo(cf);
+ return (struct ethfoo_softc *)config_attach_pseudo(ethfoo_cd.cd_name, unit);
}
/*
@@ -785,10 +788,10 @@
ethfoo_cdev_open(dev_t dev, int flags, int fmt, struct proc *p)
{
struct ethfoo_softc *sc;
-
+/*
if (minor(dev) == ETHFOO_CLONER)
return ethfoo_dev_cloner(p);
-
+*/
sc = (struct ethfoo_softc *)device_lookup(ðfoo_cd, minor(dev));
if (sc == NULL)
return (ENXIO);
@@ -821,7 +824,7 @@
* externally accessed through the corresponding device node with the cdevsw
* interface.
*/
-
+/*
static int
ethfoo_dev_cloner(struct proc *p)
{
@@ -842,7 +845,7 @@
return fdclone(p, fp, fd, ðfoo_fileops, (void *)(intptr_t)sc->sc_dev.dv_unit);
}
-
+*/
/*
* While all other operations (read, write, ioctl, poll and kqfilter) are
* really the same whether we are in cdevsw or fileops mode, the close()
@@ -1494,3 +1497,20 @@
*--cp = 0;
return (dest);
}
+
+/* ARGSUSED */
+int
+fnullop_fcntl(struct file *fp, u_int cmd, void *data, struct proc *p)
+{
+ if (cmd == F_SETFL)
+ return 0;
+
+ return EOPNOTSUPP;
+}
+
+/* ARGSUSED */
+int
+fbadop_stat(struct file *fp, struct stat *sb, struct proc *p)
+{
+ return EOPNOTSUPP;
+}
--mYCpIKhGyMATD0i+--