Grabbing raw ethernet frames from eth0 and creating virtual net devices.

From: Daniel Shane (daniel@insu.com)
Date: Tue May 23 2000 - 21:27:49 EST


Is is possible, for a kernel module, to grab raw ethernet
frames from a network device (like eth0)? Is there a hook
that can be used to intercept the ethernet frames at the
link layer?

I would like to write a small module that will grab
ethernet frames and duplicates them to other interfaces
(ie, ethertap devices) so as to simulate two network
cards that are on the same ethernet segment.

I tried doing this but it doesnt seem to work.

ifconfig eth0 192.168.0.1 netmask 255.255.255.0 dev eth0
ifconfig tap0 10.5.1.1 netmask 255.255.255.0 dev tap0

ping 10.5.1.2 (another machine)....
tap0 gets the ping put it doesnt get redirected to eth0
(obviously since theres no route)

So I do a

route del -net 10.5.1.0 netmask 255.255.255.0 dev tap0
route add -net 10.5.1.0 netmask 255.255.255.0 dev eth0

Now everything works but nothing gets in tap0 so all
my applications that use tap0 directly at the ethernet
level are non-functional.

Should I use iproute2 to specify a different route
when the packets come in? It seems simpler just to
leave the default route to tap0 and write a small
module to link eth0 to tap0 directly at the link
layer (like a bridge, but where I can still use eth0
and tap0 instead of only one interface br0 as with
the current bridging code). This also would not
require to put the devices in promiscuous mode
as with the current bridging code.

The second solution seems better since both eth0
and tap0 would receive the ethernet frames
and therefore I could put 10.5.1.x ip addresses on
eth0:xx as well if I wanted to (although I dont know
why I would).

What do you all think about this problem of
creating a virtual network device thats
connected to some other real physical device
like the vmnet modules from vmware?

Daniel Shane

--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:11 EST