当我们从用户空间调用任何插座时,内核如何知道哪个驱动程序?
我正在使用 iwd 作为用户空间中的无线守护程序。驱动器和固件已加载。
当IWD使用NL80211
调用套接字时,它将传递到nl80211
,而不是CFG80211
在内核空间中。在内核空间,他们如何知道要致电哪个驱动程序或将请求传递给哪个驱动程序?
使用以下方式创建了插座:
fd = socket(PF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, NETLINK_GENERIC);
该FD用于将请求传递给内核空间。
[编辑]
此代码中使用类似的插座概念:如何使用NetLink套接字与内核模块进行通信?
它正在使用相同的套接字创建和调用以在用户空间和内核空间之间进行通信。
I am using IWD as a wireless daemon in userspace. Driver and firmware are loaded.
When the socket is called by IWD using nl80211
, it passes to nl80211
and than cfg80211
in kernel space. At kernel space how do they know which driver to call or pass requests to which driver?
Socket is created using this:
fd = socket(PF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, NETLINK_GENERIC);
And this fd is used to pass requests to kernel space.
[edits]
Similar concept of socket is used in this code: How to use netlink socket to communicate with a kernel module?
It is using same socket creation and calling to communicate between userspace and kernel space.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如@stark在评论中所解释的那样:
您正在使用NetLink_generic协议,因此将调用通用NetLink代码。另一个问题是使用注册协议31的用户写入模块。Wiki.linuxfoundation.org/networking/generic_netlink_howto
As explained by @stark in a comment:
You are using NETLINK_GENERIC protocol, so will call the Generic Netlink code. The other question is using a user-written module that registers protocol 31. wiki.linuxfoundation.org/networking/generic_netlink_howto