Hi,
I have few questions in netlink,
I am experimenting netlink socket for kernel space to user space
communication in linux 2.6.32 kernel.
My intension is to perform,
kernel space --------------> user space
kernel space <------------- user space
i have few questions,
1) how to determine the pid of the userspace process, if kernel is going to
initiate the communication by sending the data.
Because, i have seen examples of netlink program where only user space
process initiates the data flow by requesting.
2) When netlink receives the data from user space, it invokes the handler
which runs in separate context, like below,
driver_init()
{
netlink_kernel_create(&init_
net, KNETLINK_UNIT, 0, knetlink_input, NULL, THIS_MODULE);
}
void knetlink_input( struct sk_buff * skb)
{
mutex_lock(&mut);
netlink_rcv_skb(skb, &knetlink_process);
mutex_unlock(&mut);
}
int knetlink_process( struct sk_buff * skb, struct nlmsghdr *nlh )
//receive data from userspace
{
//receive data .........
//data is only available here
}
while (some condition) {
my_function() //driver
{
get_data(data); -> where i get data
netlink_unicast(data); ---------> send data to userspace
// i have to process data here, and i do not have data availabe
here...
}
}
can this way possible to implement , if possible, how it can be done,
while (some condition) {
my_function () // driver
{
get_data(data); -> where i get data
netlink_unicast(data); ---------> send data to
userspace
netlink_receive(data); -----------> receive data
from userspace
process data(data); //some processing on data
printk ("data");
}
}
On Sat, Apr 3, 2010 at 6:55 AM, Radhesh Kamath <[email protected]> wrote:
> On Fri, Apr 2, 2010 at 5:27 PM, Mulyadi Santosa
> <[email protected]> wrote:
> > Hi Radhesh
> >
> > On Sat, Apr 3, 2010 at 06:27, Radhesh Kamath <[email protected]> wrote:
> >> The question is, is it possible to do epoll on a netlink socket ?
> >> The netlink socket is used to talk to modules that are built into the
> kernel.
> >
> > I am not familiar with netlink, but by looking at the code example in
> > "man netlink" which use recvmsg(), I am pretty confidence it is
> > epoll-able. Probably the exception is rtnetlink.
>
> Hi Mulyadi, thanks for the answer.
>
> Indeed netlink sockets are epoll-able -- I just got my code that does
> epoll on netlink sockets working.
>
> Best,
> Radhesh
>
> >
> > --
> > regards,
> >
> > Mulyadi Santosa
> > Freelance Linux trainer and consultant
> >
> > blog: the-hydra.blogspot.com
> > training: mulyaditraining.blogspot.com
> >
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to [email protected]
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>
--
Thanks and Regards,
Harish Kumar. V