简体   繁体   English

当我们从用户空间调用任何套接字时,内核如何知道要调用哪个驱动程序?

[英]How kernel know which driver to be called when we are calling any socket from user-space?

I am using IWD as a wireless daemon in userspace.我将IWD用作用户空间中的无线守护程序。 Driver and firmware are loaded.驱动程序和固件已加载。

When the socket is called by IWD using nl80211 , it passes to nl80211 and than cfg80211 in kernel space.当 IWD 使用nl80211调用套接字时,它会传递给nl80211 ,然后传递给内核空间中的cfg80211 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.而这个 fd 用于将请求传递给内核空间。

[edits] [编辑]

Similar concept of socket is used in this code: How to use netlink socket to communicate with a kernel module?这段代码中使用了类似的套接字概念: How to use netlink socket to communication with a kernel module?

It is using same socket creation and calling to communicate between userspace and kernel space.它使用相同的套接字创建和调用在用户空间和内核空间之间进行通信。

As explained by @stark in a comment:正如@stark 在评论中解释的那样:

You are using NETLINK_GENERIC protocol, so will call the Generic Netlink code.您正在使用 NETLINK_GENERIC 协议,因此将调用 Generic Netlink 代码。 The other question is using a user-written module that registers protocol 31. wiki.linuxfoundation.org/networking/generic_netlink_howto另一个问题是使用注册协议 31 的用户编写的模块。wiki.linuxfoundation.org/networking/generic_netlink_howto

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从内核模块扫描用户空间内存 - How to scan user-space memory from a kernel module 从内核分配用户空间内存 - allocate user-space memory from kernel 从内核空间执行用户空间功能 - Executing a user-space function from the kernel space 如何从 Linux kernel 空间模块执行/调用用户空间定义的 function? - How can I Execute/Call a user-space defined function from Linux kernel space module? 从用户空间进程启用内核模块调试 - Enable debugging of kernel module from user-space process 在用户空间使用netlink从内核检索数据时出错 - Error in receving data from kernel using netlink at user-space UDP数据包从内核到Linux中用户空间的路径 - Path of the UDP packet from kernel to user-space in Linux 在Windows 10驱动程序中将内核空间虚拟地址映射到用户空间虚拟地址 - Mapping Kernel-Space Virtual Address to User-Space Virtual Address in Windows 10 Driver 麻烦从用户空间C调用ioctl - Trouble Calling ioctl from user-space C 在不依赖输入调用的情况下,自动将消息从内核模块发送到用户空间应用程序。 来自用户空间 - Autonomically sending a message from kernel-module to user-space application without relying on the invoke of input. from user-space
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM