Re: netlink sockets

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

 



Jonathan Khoo wrote:

Hi guys,

I am working on a kernel module which needs to transfer information
between user space and the kernel. I was referring to a linux journal
article (http://www.linuxjournal.com/article/7356).

I am using netlink_unicast to copy a series of strings (<=80bytes) to
user space. I am stuck after a few calls. The code I used is almost
similar to that in the linux journal article. The user space program
will wait at recvmsg for the message.

Is there anything that I am suppose to do but it was not mentioned in
the article?

Many thanks for any advices!
I've faced the same problem my self
The artivle in the Linux journal states that calling "wake_up_interruptible" from the callback function is enough to wake up the blocking receive process but testing it out didn't worked I've read the code of "skb_recv_datagram" and the code of "wake_up_interruptible" and everything seemed to be logical .. if anyone could read them out and find out why it's not working it will be more logical The solution I've used my self is a little tricky .. whenever any peace of code in my kernel module wants to send a request to user space it puts a unique sequence number in the nlmsghdr->nlmgs_seq and states a buffer to receive the reply in and put it self on a waiting list then it sends the request and do "down_interruptible" on a semaphore .. whenever data arrive to kernel "whenever the callback function is called" it looks for a request in the waiting_list with a sequence number as the reply has> once such a request is found the message is copied to the buffer stated by the sender and "up" is called on the semaphore that the sending is waiting on it's a little bit complicated but it's working ... anyone has better solutions ??
MHD


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux