# Linux Kernel Module Cheat

#### 17.8.7. netlink sockets

Netlink sockets offer a socket API for kernel / userland communication:

    ./netlink.sh
    echo $?

Outcome: the test passes:

    0

Sources:

- kernel_modules/netlink.c

- lkmc/netlink.h

- userland/kernel_modules/netlink.c

- rootfs_overlay/lkmc/netlink.sh

Launch multiple user requests in parallel to stress our socket:

    insmod netlink.ko sleep=1
    for i in `seq 16`; do ./netlink.out & done

TODO: what is the advantage over `read`, `write` and `poll`? https://stackoverflow.com/questions/16727212/how-netlink-socket-in-linux-kernel-is-different-from-normal-polling-done-by-appl

Bibliography:

- https://stackoverflow.com/questions/3299386/how-to-use-netlink-socket-to-communicate-with-a-kernel-module

- https://en.wikipedia.org/wiki/Netlink