Subject: Re: Sample (but possibly useful) LKM: fake Ethernet device
To: Manuel Bouyer <firstname.lastname@example.org>
From: Neil Ludban <email@example.com>
Date: 11/07/2003 17:36:32
Manuel Bouyer wrote:
> On Tue, Nov 04, 2003 at 06:54:33PM +0100, Quentin Garnier wrote:
>>Because I kind of needed it at work (anyone who had to deal with FlexML
>>will understand), I wrote that tiny LKM that fakes an Ethernet device.
>>I think it can be useful as a sample LKM, because it uses some of the
>>neat (and clean, too) features of the kernel.
>>I'd like to have some input on it, since it is likely that some
>>errors remain in the comments notably. Then I will either commit it
>>somewhere under sys/lkm (just as an example, of course), or make it
>>available through a site, maybe with Benedikt Meurer's fine guide .
> This is nice.
> I'd like such a device that would allow to read back the ethernet frames
> from userland, or inject ethernet frames to the device (somewhat like
> tun(4) but for ethernet).
> This would be nice for things like simh, and also to build virtual ethernet
> networks on encrypted IP tunnels.
I've done some hacking on tun to support this. Reading the character
device with hexdump(1) was showing correct packets (ping from another
window), then the project got sidelined by real work before I could test
writes. I think BPF was working as well.
Several options if anybody wants to see this:
1) ask and I'll forward source files (from 1.6W)
2) I can rename and simplify into an ethernet only version
3) take more time and figure out how to rewrite as a generic tun
The hacked version:
- uses minor number to determine if new clone type is IP or ethernet
- doesn't require super-user privileges (uses device permissions)
- doesn't delete routes when device is closed
- removed support for ALTQ
- may have other bugs :)
The generic rewrite is mostly waiting for me to dig into some more code
to figure out what state an interface must be in between the time the
clone is created and configured with a link type (or reconfiguring).
Are there any good examples of interfaces supporting multiple link