/dev/tun and raw sockets; emulators loose

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,

this is potentially a dumb question, but I think not.

I've been struggling with how to accomplish some basic networking from
userland.

I'm familiar with /dev/tun (i once moved it into bsd, so I understand
how it works).  And I'm familiar with AF_PACKET.

I have a big application which emulates an entire computer.  It wants to
pretend it has a raw network interface.  Right now it uses AF_PACKET.
This works fine as long as you talk to a machine on the local wire.  But
it does *not* work if you want to talk to the computer which is running
the application.  A known problem.  A raw socket write shoots the packet
out to the ethernet driver and it never gets back into the local kernel.

The 'typical' setup is to assign the emulator application an IP address
which is on the local wire, often adjacent to the host which is running
the application.  i.e. if the linux host running the app is 192.168.1.1
the emulator app would be assigned 192.168.1.2.

So, I thought about /dev/tun.  This would work fine also, but would
require some routing work.  Both sides end up being a point-to-point
link, so you could use a host netmask (i.e. 255.255.255.255) and burn
one address but this is a pain.  It requires proxy arp and a route to
talk to hosts on the local wire.

Also the /dev/tun is only really needed in the case where we are talking
to the local host, so some 'switching' might be a solution (where
switching==hack).

It seems like the emulator network code could notice if it's talking to
the local host and if so use the /dev/tun and if not use the AF_PACKET
socket.

seems like a pain.

Not the first time I've run into this.  Most emulators with network
interfaces run into this on linux but not other os's.  It seems freebsd
does not have this problem.  perhaps there is a little code in freebsd
at the bottom of the AF_PACKET send code which notices if we are sending
to the mac address of the local host?

So, I was wondering if I'm missing something obvious.

In a perfect world the emulator application could co-exist on the local
ethernet interface *and* talk to the host computer as if it were another
host on the same wire.

any suggestions?

-brad

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux