是否有人使用netlink进行IPC? [英] Is anyone using netlink for IPC?
问题描述
我正计划使用netlink在两个userland进程之间进行通信.对netlink如此挑剔的部分原因是-该进程之一的大部分处理最终都将在内核空间中进行,并且可以(希望)按原样使用基于netlink的通信.
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).
我正在采用的方法是-定义一个新的Generic Netlink系列(我将不得不编写一个内核模块来支持该系列-目前看来如此).很好,我看了一些示例代码,其中内核实际上只是在不同进程之间路由消息,而实际上并没有做任何工作-这些消息的实际填充是由进程处理的.
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.
我的问题是-是否有人在任何项目中以类似方式使用netlink?另外-上述方法有意义吗?
My question is - is anyone using netlink in the similar manner in any of the projects? Also - does the above approach makes sense?
我阅读了有关基于Netlink的DBUS的建议.但尚未找到任何实现.这最符合我的要求.
I read about a proposal about netlink based DBUS. But haven't found any implementation of that. That comes closest to my requirements.
谢谢.
推荐答案
如果要在用户空间进程之间进行通信,您正在寻找的是NETLINK_USERSOCK
.
What you are looking for is NETLINK_USERSOCK
if you want to communicate between userspace processes.
很遗憾,Netlink文档非常匮乏.这可能会有所帮助:谁可以给我最新的netlink编程样品?
Netlink documentation is awfully scarce unfortunately. This might help a bit: Who can give me the latest netlink programming samples?
只需确保nl_pid为非零并匹配绑定到哪个用户空间对等端,并且您要发送单播.
Just make sure nl_pid is non-zero and matches what userspace peer is bind'ed to and that you're sending a unicast.
这篇关于是否有人使用netlink进行IPC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!