简体   繁体   中英

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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM