Kernel as client, User application as server using netlink

694 views Asked by At

I want to establish connection between kernel module and user application with the kernel as a client. In other words, kernel will send message to the user app, wait for reply, receive reply, and then continue execution.

For example, inside kernel I will send message and then wait for reply.

// inside kernel
nlmsg_unicast();

wait_until_user_reply();

/* process reply */
/* continue execution.. */

while inside user,

while (1) {
   // inside user
   recvmsg();

   /* assembly reply.. */

   sendmsg();
}

however, what netlink protocol does is invoking a callback function every time user sends message. What I want is to make kernel wait for a reply from user, then continue the execution. Is waiting in a busy loop on a global variable which is updated inside callback function feasible? I tried but I think that's not a very good solution.

Can I do something like "sleep until a reply come". Can I put the kernel to sleep?

1

There are 1 answers

3
Isa A On BEST ANSWER

I have resolved this problem using wait_for_completion. It turns out that it wasn't that hard.