I have written a user-space program that polls for the status of the available Ethernet interfaces for their operational status using netlink
sockets with NETLINK_ROUTE
protocol.
But now I want to write a kernel module which uses the NETLINK_ROUTE channel to send customized notification message to this user-space program.
After reading the man page for netlink
and rtnetlink
I cannot conclude if it is doable. Any suggestions will be highly appreciated.
我编写了一个用户空间程序,它使用带有NETLINK_ROUTE协议的netlink套接字轮询可用以太网接口的运行状态状态。但是现在我想编写一个内核模块,它使用NETLINK_ROUTE通道向这个用户空间程序发送自定义通知消息。在阅读netlink和rtnetlink的手册页后,我无法断定它是否可行。任何建议将受到高度赞赏。
1 个解决方案
#1
1
NETLINK_ROUTE is not a protocol - it's one of the netlink families. From manpage:
NETLINK_ROUTE不是协议 - 它是netlink系列之一。从联机帮助页:
netlink_family selects the kernel module or netlink group to communicate with.
netlink_family选择要与之通信的内核模块或netlink组。
Netlink was initially developed for fast and easy messaging about routing info and that's why NETLINK_ROUTE is first family and have own manpages, manuals, etc. But later other families were added to send other than routing info, e.g. NETLINK_SELINUX and NETLINK_FIREWALL.
Netlink最初是为了快速简便地发送有关路由信息的消息而开发的,这就是为什么NETLINK_ROUTE是第一个系列并拥有自己的联机帮助页,手册等等。但是后来添加了其他系列以发送除路由信息以外的其他信息。 NETLINK_SELINUX和NETLINK_FIREWALL。
After some time developers saw that there are way too many specific families. If somebody wants to use that fancy netlink protocol he needs to declare another family and make it even worse. So they added last family - NETLINK_GENERIC that works like multiplexer. There is a great manual about generic netlink on lwn - http://lwn.net/Articles/208755/. If you want working examples you can look at my code (https://github.com/dzeban/keymon)
经过一段时间,开发人员发现有太多特定的家庭。如果有人想使用那种花哨的netlink协议,他需要申报另一个家庭并使其更糟糕。所以他们添加了最后一个家族 - NETLINK_GENERIC就像多路复用器一样。关于lwn的通用netlink有一本很棒的手册 - http://lwn.net/Articles/208755/。如果你想要工作的例子,你可以查看我的代码(https://github.com/dzeban/keymon)
So, if your notifications related to any specific netlink family like NETLINK_ROUTE - then use it. But if you want to just send your very own and custom info - use generic netlink.
因此,如果您的通知与NETLINK_ROUTE等任何特定的netlink系列相关,那么请使用它。但是,如果您只想发送自己的自定义信息 - 请使用通用netlink。
#1
1
NETLINK_ROUTE is not a protocol - it's one of the netlink families. From manpage:
NETLINK_ROUTE不是协议 - 它是netlink系列之一。从联机帮助页:
netlink_family selects the kernel module or netlink group to communicate with.
netlink_family选择要与之通信的内核模块或netlink组。
Netlink was initially developed for fast and easy messaging about routing info and that's why NETLINK_ROUTE is first family and have own manpages, manuals, etc. But later other families were added to send other than routing info, e.g. NETLINK_SELINUX and NETLINK_FIREWALL.
Netlink最初是为了快速简便地发送有关路由信息的消息而开发的,这就是为什么NETLINK_ROUTE是第一个系列并拥有自己的联机帮助页,手册等等。但是后来添加了其他系列以发送除路由信息以外的其他信息。 NETLINK_SELINUX和NETLINK_FIREWALL。
After some time developers saw that there are way too many specific families. If somebody wants to use that fancy netlink protocol he needs to declare another family and make it even worse. So they added last family - NETLINK_GENERIC that works like multiplexer. There is a great manual about generic netlink on lwn - http://lwn.net/Articles/208755/. If you want working examples you can look at my code (https://github.com/dzeban/keymon)
经过一段时间,开发人员发现有太多特定的家庭。如果有人想使用那种花哨的netlink协议,他需要申报另一个家庭并使其更糟糕。所以他们添加了最后一个家族 - NETLINK_GENERIC就像多路复用器一样。关于lwn的通用netlink有一本很棒的手册 - http://lwn.net/Articles/208755/。如果你想要工作的例子,你可以查看我的代码(https://github.com/dzeban/keymon)
So, if your notifications related to any specific netlink family like NETLINK_ROUTE - then use it. But if you want to just send your very own and custom info - use generic netlink.
因此,如果您的通知与NETLINK_ROUTE等任何特定的netlink系列相关,那么请使用它。但是,如果您只想发送自己的自定义信息 - 请使用通用netlink。