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 |
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. |
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 |
Hi
Quote:
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. |