Subject: Re: kernel-internal interface changes?
To: None <tech-kern@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 03/24/2005 20:16:28
I (quoted and) wrote

>>> For that matter, does anyone know of an already-existing tap driver
>>> for 2.0 I could just pick up and use?
>> In pkgsrc, net/netbsd-tap.  It is the exact same as the one in
>> -current and -3, with the relevant hooks to make it work on 2.0.
> So it's safe to take the -current package and use it on 2.0?  I'll
> have a stab at doing that.  Thanks!

My stab seems to have missed.  I suspect there's something I don't
understand about packages and something I don't understand about 2.0,
and they're adding up to "it doesn't work".

As I mentioned in my other message, 2.0 pkgsrc doesn't have any
net/netbsd-tap as far as I can see.  So I pulled over the pkgsrc
tarball from ftp.netbsd.org and looked in there.  Sure enough, it has a
net/netbsd-tap.

But what it has is a directory with a bunch of files in it, and pkg_add
wants a single tarball.  So instead I cd into the directory and type
make, and get

===> Error: The package tools installed on this system are out of date.
===> The installed package tools are dated 2004/01/15 and you must update
===> them to at least 2005/02/04 using the following command:
[...]

This isn't my idea of "it works with 2.0".

But in files/ I saw if_tap{,_stub}.{c,h}.  I copied them into /sys/net
and added lines to /sys/conf/files (near the similar lines for tun)

defpseudo tap:		ifnet, ether

file	net/if_tap.c			tap			needs-flag
file	net/if_tap_stub.c		tap			needs-flag

and a line to /sys/conf/majors

device-major	tap		char 144		tap

config(8) was happy.  When I tried to build a kernel, everything went
fine until the final link, at which point I got undefined-reference
errors, looking for tap_cd:

ld -T ../../../../arch/i386/conf/kern.ldscript -Ttext c0100000 -e start -X -o netbsd ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
if_tap.o(.text+0xd): In function `tapattach':
: undefined reference to `tap_cd'
if_tap.o(.text+0x22): In function `tapattach':
: undefined reference to `tap_cd'
if_tap.o(.text+0x36): In function `tapattach':
: undefined reference to `tap_cd'
if_tap.o(.text+0x5d0): In function `tap_clone_create':
: undefined reference to `tap_cd'
if_tap.o(.text+0x5f3): In function `tap_clone_creator':
: undefined reference to `tap_cd'
if_tap.o(.text+0x675): more undefined references to `tap_cd' follow
*** Error code 1

Stop.

I clearly did something wrong when trying to hook it all into the
kernel; if_tap.c imports tap_cd, but it's not at all clear where from.
Based on looking at other drivers, I get the feeling that *_cd are
related to a device's attachment in the autoconfig device tree,
generated by config via ioconf.c, and as such they make no sense for
pseudo-devices - but the code clearly depends on having tap_cd, despite
supposedly working under 2.0.  So I confess myself mystified.  I even
looked over the rest of the package, looking for scripts that might
modify the files when installing them.  I found nothing, but of course
I don't know whether that's because there was nothing to find, because
I just didn't look in the right place, or perhaps even because I saw it
but didn't recognize it.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B