Example for Implementing a Custom Netlink Family in Userland (C & Rust) + Linux Kernel Module for IPC Using Generic Netlink

Netlink is one of the nicer interfaces to communicate between userland and Linux kernel (IPC), but it’s still quite hard/complex, tho. For an uni project I had to figure it out how to communicate between userland and a self written Linux kernel module using the generic part of the netlink protocol. Because it was quite tough, I want to share my findings with the open source world.

I chosed Rust as the language for the userland and „neli“ as library. All my code can be found on Github. I recommend directly visiting Github for all the latest comments and code. The repo also includes two C components for comparision. One C component uses libnl whereas the other uses raw sockets without any library. All the code is well and intensively documented, also a few examples for changes you could make are given. My tutorial includes Netlink validation (Kernel), error responses (from Kernel), and regular IPC (Kernel, userland [Rust], userland [Pure C], userland [C with libnl]).

This repository on Github: https://github.com/phip1611/generic-netlink-user-kernel-rust/

Netlink code snippet (kernel code)

Netlink code snippet (kernel code)

Philipp Schuster

Ich bin Philipp, studiere Informatik an der TU Dresden und neben meinem Studio arbeite ich beruflich als Werkstudent und Privat an zahlreichen Projekten. Dabei nutze ich unter anderem Rust, Java, Angular, Typescript, C/C++, uvm.

Das könnte dich auch interessieren …

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.