问题
I am planning to use netlink for communication between two userland processes. Part of the reason being so picky about netlink is - Most of the processing for one of the process would eventually go in kernel space and netlink based communication can be used as it is (hopefully).
The approach I am taking is - define a new Generic Netlink family (I will have to write a kernel module just to support that family - as it appears so at the moment). That is fine, I was looking at some example code, where kernel was essentially only routing messages between different processes and not really doing any work - the actual population of those messages is handled by the processes.
My question is - is anyone using netlink in the similar manner in any of the projects? Also - does the above approach makes sense?
I read about a proposal about netlink based DBUS. But haven't found any implementation of that. That comes closest to my requirements.
Thanks.
回答1:
What you are looking for is NETLINK_USERSOCK
if you want to communicate between userspace processes.
Netlink documentation is awfully scarce unfortunately. This might help a bit: Who can give me the latest netlink programming samples?
Just make sure nl_pid is non-zero and matches what userspace peer is bind'ed to and that you're sending a unicast.
来源:https://stackoverflow.com/questions/26238160/is-anyone-using-netlink-for-ipc