LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Communication between NIC driver and user space app. (https://www.linuxquestions.org/questions/linux-kernel-70/communication-between-nic-driver-and-user-space-app-718532/)

zman2245 04-11-2009 11:00 PM

Communication between NIC driver and user space app.
 
Hello experts,

I am modifying a network driver and would like the ability to send packets up to user space and back down to driver. I have been reading a bit about message queues, but it appears read() and write() aren't available for network drivers. Is that correct? What would be the best way to to do this with a network driver?

Ideally, I would like to pass pointers to buffers containing the packets across the user/kernel space boundary. The buffers would already be mapped to user space at init time.

I have considered netlink sockets, but heard they weren't reliable and also it seems like it would be nicer if read()/write() were available.

I am also investigating how I could allocate/map an SKB pool at init time so that I wouldn't have to map buffers on the fly. Perhaps I'll post more questions about that part later so as not to bloat the scope of this post. :)

Thanks,
Zack

Mara 04-12-2009 02:43 PM

Why is pcap-equivalent not enough for you? Do you have specific requirements?

Read and write are not available by default. However, if you register an entry in /dev and configure everything correctly, it can be added. If that's a function that you want for long, that way may be the one to take. If that's only for debug or such, I'd rather do it via /proc.

zman2245 04-12-2009 10:19 PM

Hey Mara,

I can't use pcap because I need to process packet headers before passing traffic up the linux stack. This processing needs to be done in userspace since the code doing this is expected to be complex (i.e. I don't want bugs in this code bringing down the kernel).

I also can't use pcap because it is my understanding pcap would copy packets from kernel to userspace. Due to performance concerns, I need to avoid copying data.

I'm not sure what you meant by "configure everything correctly." Would this be a large effort to add read(), write() queues to network driver?

Thanks,
Zack

sidharaj 01-29-2010 07:39 PM

Hi
 
Quote:

Originally Posted by zman2245 (Post 3506904)
Hey Mara,

I can't use pcap because I need to process packet headers before passing traffic up the linux stack. This processing needs to be done in userspace since the code doing this is expected to be complex (i.e. I don't want bugs in this code bringing down the kernel).

I also can't use pcap because it is my understanding pcap would copy packets from kernel to userspace. Due to performance concerns, I need to avoid copying data.

I'm not sure what you meant by "configure everything correctly." Would this be a large effort to add read(), write() queues to network driver?

Thanks,
Zack


You can use UDP/Netlink Sockets to achieve User-kernel communication.

Thanks,
Sidharaj.


All times are GMT -5. The time now is 08:50 PM.