问题
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?
回答1:
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);
}
来源:https://stackoverflow.com/questions/11015186/is-it-possible-to-communicate-between-two-linux-kernel-module-via-netlink