AlexeyPerevalov
AlexeyPerevalov

Reputation: 191

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

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?

Upvotes: 6

Views: 5537

Answers (1)

dwalter
dwalter

Reputation: 7478

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);
  }

Upvotes: 6

Related Questions