Is it possible to communicate between two linux kernel module via netlink?

北慕城南 提交于 2019-12-11 03:56:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!