As all know, netlink it's user/kernel space communication mechanism.
I want to communicate from my kernel module to an another. Another kernel module already has the netlink interface.
Is it possible to make connection from kernel module to netlink, as we do it in user space?
Netlink is used to transfer information between the kernel and user-space processes. It consists of a standard sockets-based interface for user space processes and an internal kernel API for kernel modules.
In user space, we call socket() to create a netlink socket, but in kernel space, we call the following API: struct sock * netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len)); The parameter unit is, in fact, the netlink protocol type, such as NETLINK_TEST.
Generic netlink was designed to allow kernel modules to easily communicate with userspace applications using netlink. Instead of creating a new top level netlink family for each module, generic netlink provides a simplified interface to enable modules to plug into the generic netlink bus.
Short answer: No.
If you want to communicate between two kernel modules you should use symbols (global variables or functions) which are exported by the other kernel module.
netlink
Sockets are used to communicate between kernel and userland. AFAIR there is no way to use netlink (at least it is not the preferred way) to communicate within the kernel.
example for exporting a symbol:
module1.c:
int foo(int a)
{
/* do some stuff here */
}
EXPORT_SYMBOL(foo);
module2.c
extern int foo(int);
int bla(int b)
{
/* call foo(a) */
int ret = foo(b);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With