This course ebook includes all materials from the course entitled How to Build a FreeBSD Kernel Module From Scratch which was designed to help you understand how the userland communicates with the kernel through an existing example, studying the workflow; hence in the end you would be able to extend it or writing one of your own. In this course ebook, you will have a wide overview about FreeBSD kernel structure, some useful kernel options, its debugging possibilities and how to build your own in order to add new features. Indeed, FreeBSD is already shipped with a significant amount of features, but if needed it is very possible to develop new ones and to integrate them into the system like all other modules; FreeBSD is Open Source and it is a great chance for its users.
You should know…
- A minimum of C language level knowledge.
- A basic understanding of BSD Makefile system is helpful.
You will learn …
- General overview of the FreeBSD system structure via its source codes, the possible kernel options, its debugging tools. At the end of the session, some exercises will be included for the student about the kernel itself.
- Building a first basic kernel module. At the end of the session, the student will make their first kernel module, compile it and test it.
- Overview of ipfw2. At the end of the session, the student ought to be able to see the relation between the userland side and the kernel side and how they both interact.
- Building a kernel module for adding ipfw2’s new feature. At the end of the session, the student has to provide a new feature of their own to ipfw2.
Module 1: FreeBSD Kernel Module
In this module, we will give an overview of the nature of the FreeBSD’s kernel. The important configuration files will be explained in addition to learning how to compile the whole system with more options and with more debugging information enabled. This is very useful for kernel development.
Module 2: IPFW2 Userland and Kernel Workflow
In this module, we’ll have an overview of ipfw2 – both userland and kernel side – and how they both interact.
Module 3: Through The Userland to Kernel Codes
In this module, we’ll have an overview of ipfw2 – both userland and kernel side -, and how they interact. First of all, we will see how to use sysctl we saw in previous modules to set simple values. How to communicate settings to the kernel via a socket; all of it going through the userland to kernel codes.
Module 4: DUMMYNET Module Workflow Study
In this last module, we’ll not only look at ipfw’s communication with the kernel but also how the firewall configuration and rules are handled. We will go through the dummynet module, its workflow and how it operates with the kernel so you would be able to add new opcodes on your own.
David CarlierHe is an experienced developer and used to handle some languages like C/C++, Java, Python with Linux, *BSD and Win32 Operating Systems and worked inside startups and bigger companies as well. Personally a big fan of FreeBSD and OpenBSD. C/C++ are his preferred programming language most of the time.He writes and reviews articles for BSDMag http://www.bsdmag.org.He contributes modestly to OpenBSD ports and time in time to the source.He has been interviewed by BSDNow show http://www.bsdnow.tv/episodes/2017_10_18-software_is_storytelling. Also He did some small contributions for FreeBSD and DragonflyBSD operating system.