LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-11-2009, 11:00 PM   #1
zman2245
LQ Newbie
 
Registered: Mar 2009
Location: San Francisco, CA
Posts: 26

Rep: Reputation: 15
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
 
Old 04-12-2009, 02:43 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
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.
 
Old 04-12-2009, 10:19 PM   #3
zman2245
LQ Newbie
 
Registered: Mar 2009
Location: San Francisco, CA
Posts: 26

Original Poster
Rep: Reputation: 15
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
 
Old 01-29-2010, 07:39 PM   #4
sidharaj
LQ Newbie
 
Registered: Jan 2010
Posts: 1

Rep: Reputation: 0
Hi

Quote:
Originally Posted by zman2245 View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel-User space communication bonzi200x Programming 3 02-27-2009 08:17 AM
Sharing Memory between driver space and user space ian b davidson Programming 1 11-10-2008 06:35 AM
communication between user space and kernel space bhk Linux - General 2 06-25-2008 05:16 AM
kernel user space communication mbm Linux - Kernel 1 10-17-2007 08:21 PM
Communication between the Kernel- and User-Space Siva4Linux Linux - Kernel 3 11-30-2006 03:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration