Skip to content

Latest commit

 

History

History
62 lines (51 loc) · 1.32 KB

README.md

File metadata and controls

62 lines (51 loc) · 1.32 KB

Hello via netlink

A basic communication between kernel and user via netlink

Get and build the software

Download the source code

$ cd $HOME
$ mkdir devel
$ cd devel
$ git clone https://github.com/ichergui/hello-netlink.git

Build

kernel side
$ cd $HOME/devel/hello-netlink/kernel
$ make all
User side
$ cd $HOME/devel/hello-netlink/user
$ gcc -o nl_user nl_user.c $(pkg-config --cflags --libs libnl-3.0)

Test

Insert it into the Linux kernel

$ cd $HOME/devel/hello-netlink/kernel
$ sudo insmod nl_kernel.ko
  • verification
$ lsmod | grep -i "nl_kernel"
nl_kernel              16384  0
$

Launch the application

$ cd $HOME/devel/hello-netlink/user
$ ./nl_user -m "Hello from Ilies"
User send the following message to the kernel:
Hello from Ilies
User receive a message from kernel: Hello from kernel
$

Try with the following command line to see what's happened.

$ $ tail -f /var/log/kern.log

Sep 20 22:44:48 dev-machine kernel: [13466.108923] Entering: init_module
Sep 20 22:45:42 dev-machine kernel: [13520.057427] Entering: nl_recv_msg_cb
Sep 20 22:45:42 dev-machine kernel: [13520.057430] Kernel receive a message from user:Hello from Ilies

Remove it from Linux kernel

$ sudo rmmod nl_kernel