Subject: Re: kernel-internal interface changes?
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 03/25/2005 08:08:29
--x+RZeZVNR8VILNfK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Mar 24, 2005 at 08:16:28PM -0500, der Mouse wrote:
> I (quoted and) wrote
>=20
> >>> 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!
>=20
> 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".

In my opinion, there are a lot of things you don't *want* to
understand.  I worked hard to make this available to 2.0 in a simple
way, which is through pkgsrc.

> 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.

Well, the 2004Q1 branch is long obsoleted anyway.

> 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
>=20
> =3D=3D=3D> Error: The package tools installed on this system are out of d=
ate.
> =3D=3D=3D> The installed package tools are dated 2004/01/15 and you must =
update
> =3D=3D=3D> them to at least 2005/02/04 using the following command:
> [...]
>=20
> This isn't my idea of "it works with 2.0".

You should have done what pkgsrc was telling you (after all, it's only
one single command it's asking you to do!).

> 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)
>=20
> defpseudo tap:		ifnet, ether
>=20
> file	net/if_tap.c			tap			needs-flag
> file	net/if_tap_stub.c		tap			needs-flag
>=20
> and a line to /sys/conf/majors
>=20
> device-major	tap		char 144		tap

You should have looked at how things are done in -current/-3:

defpseudo tap {[unit =3D -1]}:            ifnet, ether, bpf_filter

The reason why there is a locator is to get config(8) to generate
the CFDRIVER_DECL() line in ioconf.c.

[...]
> 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.

For the LKM, I do the CFDRIVER_DECL() by myself (look at all the
autoconf(9) glue in if_tap_lkm.c).

The fun thing about this is that tap(4) (back when it was the very
simple and straightforward ethfoo(4)) was specifically written to be
an example of a LKM.  I really thought I explained enough, or at
least gave enough background, to the autoconf(9) APIs, in the
commentaries if if_tap_lkm.c.

--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"When I find the controls, I'll go where I like, I'll know where I want
to be, but maybe for now I'll stay right here on a silent sea."
KT Tunstall, Silent Sea, Eye to the Telescope, 2004.

--x+RZeZVNR8VILNfK
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)

iQEVAwUBQkO47dgoQloHrPnoAQKiewgAnUOi9c6suFJODZZT2b9/cus2GHSAT+ia
9ifEAQkzyDkf44R7IEePugqkk7BOhKpngPEppl/6uuygdDcFTdwODTNKsUHa956R
Vom+lYRgR3YrRWzPztg8s4jKgAcuqZrDv3ULk4mQwSYGHEiCm4S4xfhQePQF/W/2
B+CY/EXBbCsTA7EkSspvw/dCdtt64sx51wl5dAPlUJNB31ACvyt2nLj+CG0xvX8j
duDOAAQhg9jewfONOnwrbTZkk60Nldmp/NMnuxaJvBXizt7PjA/qANusGUCDn/1/
bSPzdSnZZh1U8WooxZ9Z/yn+iP+BozZy6Iu5GPfs1XMmm+TEzq/V/Q==
=bVQ5
-----END PGP SIGNATURE-----

--x+RZeZVNR8VILNfK--