Add nat20lib kernel module example and br environment.#98
Conversation
Add a kernel module that provides libnat20 functionality to linux kernel modules. Also add a configuration to build a minimal linux image with buildroot and run in on qemu and a workflow to test build nat20lib.ko
LCOV of commit
|
There was a problem hiding this comment.
Pull request overview
Adds a Linux kernel-module packaging of libnat20 (as an example) and a Buildroot external tree + QEMU run tooling to build/test the module in CI.
Changes:
- Introduces
examples/linux/nat20libkernel module sources/build files and exports libnat20 symbols. - Adds a Buildroot
br_externaltree (package definition, configs, bootstrap + dev helper scripts, QEMU runner) to build a minimal image/module. - Adds a GitHub Actions workflow to build and verify
nat20lib.ko, plus expands license-check patterns for the new file types.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/linux/nat20lib/mod.c | New kernel module entry/exit and symbol exports for libnat20. |
| examples/linux/nat20lib/Makefile | Wrapper Makefile for building/installing the external module. |
| examples/linux/nat20lib/Kbuild | Kbuild definition compiling nat20 sources into nat20lib.ko. |
| examples/linux/br_external/utils/envsetup.sh | Dev environment helper script for building/rebuilding Buildroot artifacts. |
| examples/linux/br_external/run-qemu.sh | Script to boot the built kernel/rootfs in QEMU. |
| examples/linux/br_external/package/nat20lib/nat20lib.mk | Buildroot package definition for the nat20lib kernel module. |
| examples/linux/br_external/package/nat20lib/Config.in | Buildroot config option for enabling nat20lib. |
| examples/linux/br_external/external.mk | Buildroot external tree package include. |
| examples/linux/br_external/external.desc | Buildroot external tree descriptor. |
| examples/linux/br_external/configs/qemu_linux_defconfig | Kernel defconfig used by the Buildroot environment. |
| examples/linux/br_external/bootstrap.sh | Bootstrap script to set up out-of-tree Buildroot build directory. |
| examples/linux/br_external/Config.in | Top-level Buildroot external Config.in sourcing nat20lib package. |
| .github/workflows/linux-kmod-build.yml | CI workflow to build and verify nat20lib.ko via Buildroot. |
| .github/license-check/license-config.json | Adds license-check patterns for new file extensions/paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
smacdude
left a comment
There was a problem hiding this comment.
I'm not an expert on all of this, but Claude found some issues that I think should at least be questioned.
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 #v4.3.0 | ||
| with: | ||
| path: ${{ runner.temp }}/buildroot.build | ||
| key: buildroot-${{ hashFiles('examples/linux/br_external/configs/qemu_br_defconfig', 'examples/linux/br_external/configs/qemu_linux_defconfig') }} |
There was a problem hiding this comment.
According to Claude:
cache key is incomplete. hashFiles(...) covers only the two defconfigs. The Buildroot version (2025.08.1) is hardcoded in bootstrap.sh, so bumping it won't invalidate the cache → stale toolchain. Include bootstrap.sh (and probably the br_external/** tree) in the key
There was a problem hiding this comment.
Added bootstra.sh. I don't think we need br_external/**. It will just add noise.
| ensure_popd make linux-rebuild nat20lib-rebuild all | ||
| ;; | ||
| *) | ||
| ensure_popd make $1-rebuild all |
There was a problem hiding this comment.
I don't think it makes much of a difference. Make targets shouldn't have spaces. Apparently, it is technically possible, but do we want to encourage this?
|
|
||
| obj-m := nat20lib.o | ||
| ccflags-y := -I $(src)/../../../include | ||
| ccflags-y += -I $(srctree) |
There was a problem hiding this comment.
Is this line and the next line changing compiler options for the Linux source, and if so, is that safe?
There was a problem hiding this comment.
This is not needed for newer kernels which use gnu11. But this code won't compile with gnu90. So we may have a problem with older kernels. I'll remove this for now.
| # <https://www.gnu.org/licenses/>. | ||
|
|
||
| name: NAT20 | ||
| desc: Provides NAT20 related packages package. |
There was a problem hiding this comment.
| desc: Provides NAT20 related packages package. | |
| desc: Provides NAT20 related packages. |
Looks like this co-pilot finding wasn't resolved.
Add a kernel module that provides libnat20 functionality to linux kernel
modules. Also add a configuration to build a minimal linux image with
buildroot and run in on qemu and a workflow to test build nat20lib.ko