PDA

View Full Version : TCP/IP stack bypass



wyliek
08-12-2009, 02:28 PM
Hi there,

I have an embedded device running linux which has 2 ethernet interfaces (eth0, eth1).

I need to decouple the linux tcp/ip stack from eth1 so that I can access the drivers for this device directly. Then I will have an external tcp/ip stack using eth1.

I am just doing some preliminary information gathering on the cleanest way to do this.

My first thought was to use raw sockets to do this, but i feel that this may cause some issues and that accessing eth1 directly would be cleaner than:
external stack->linux stack(raw sockets)->eth1

Does anyone know how to:
1) stop the linux stack from accessing eth1? Is it as simple as "ifdown eth1"?
2)find the API to use to access eth1 directly? I looked at using a library like libpcap, but it only supports reading packets from the device and not sending.

Thanks,
Kyle

matsp
08-12-2009, 06:45 PM
Can you describe, in a different way, what you are trying to do.

What does "external tcp/ip stack" mean? A "non-kernel" tcp/ip stack?

Why do you want to do that? What would the end result be?

Have you considered that many modern ehternet controllers do some parts of the IP stack work in hardware - so you may not be able to turn it off.

I think ifconfig eth1 down will actually unload the driver entirely, which would not be what you want to do...

--
Mats

wyliek
08-13-2009, 12:51 AM
Hi Mats,

You are correct. By "external" I mean, non kernel. Provided by a third party. Our customer does not want to use the linux stack. They have implemented their own stack that they want us to use.

The end result:
The embedded device will boot up linux and run the customers software. For ip connectivity they will be using their own stack which will interface to a ethernet driver. I will have to write a wrapper to the linux ethernet driver so fit the customers specified API. It sounds crazy not to use the stack thats already there, but the customer is insisting.

The level at which their stack interfaces with the ethernet interface is quite simple. We need to pass up packets received but the ethernet device to the stack. Send out packets given to us by the stack. Set multicast filters etc.

Hope that clears it up a little

khn
08-16-2009, 07:29 AM
Create a TAP interface, this will pass all ethernet frames directly to that interface and you are able to pocess them in any way you want.

wyliek
08-19-2009, 02:14 PM
Hi knh,

I thought a TUN/TAP was a virtual ethernet interface driver. So in my basic understanding, a TUN/TAP, instead of receiving packets from a physical
media, receives them from user space program and instead of sending
packets via physical media sends them to the user space program. I don't see how I can use this to get ethernet packets from say "eth1" and pass them to the external stack as opposed to the linux stack. Could you maybe elaborate?

-kyle