Subject: Re: bpf write() to local host
To: Ignatios Souvatzis <ignatios@theory.cs.uni-bonn.de>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-net
Date: 01/21/2003 22:43:49
On Tue, Jan 21, 2003 at 11:55:55AM +0100, Ignatios Souvatzis wrote:
> Hi,
> 
> On Sat, Jan 18, 2003 at 10:10:00PM +0100, Manuel Bouyer wrote:
> 
> > This is to solve a problem with simh: it uses bpf writes to send packets,
> > which makes it impossible to send packets to the local machine.
> > With this change (and a fix to simh) I can NFS mount from a NetBSD/vax in simh
> > a partition of the NetBSD/i386 hosting it.
> 
> You know... somehow I feel the right solution to this would be a two-ended
> loopback interface instead of hacking some Ethernet interface. Sort of a
> network device version of socketpair().

Yes, this is my feeling too. My idea was to hack tun to add ethernet
emulation. But this is a longer project, and I still think that
packet passed to bpf_write should go to ether_input() if its destination
address is the local mac address, or copied to ether_input() for
multicast/broadcast addresses.
How does similar API in other OSes behaves ?

> 
> Even better (in terms of work to invest): Teach simh (does it simulate
> the network interface in software?) use /dev/tun and connect the
> hosting OS to tun0. But I guess this won't work because simh wants to
> talk to layer 2 .

Yes, and also we want to be able to bridge it to a real ethernet device.
In the simh context this would be an ideal solution, because we would then
have the choise to bridge it, route it or NAT it.

This would also allow to easily build ethernet VLAN over securised transports.

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 24 ans d'experience feront toujours la difference
--