'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.
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ritik garg |