Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
67ca3fc
Add nat20lib kernel module example and br environment.
werwurm Feb 11, 2026
4070f76
Fixup lint and add Makefiles to license checker.
werwurm Apr 29, 2026
de1ea2a
Make bootstrap executable
werwurm Apr 29, 2026
36bc192
Use prebuild toolchain and stop building qemu from scratch.
werwurm Apr 29, 2026
44c8f8f
address comments and also resolve circular dependency when using OVER…
werwurm Apr 29, 2026
6627ce3
Do not use relative paths
werwurm Apr 29, 2026
edbd436
Add module nat20device to linux examples.
werwurm Apr 28, 2026
2fd948f
Add nat20device to linux-kmod-build github action.
werwurm Apr 29, 2026
b9669af
nat20device fixups
werwurm Apr 30, 2026
d40b5bf
Add nat20crypto module to linux examples
werwurm Apr 28, 2026
49d4901
Set override SRCDIR for dependencies.
werwurm May 5, 2026
4b64988
Address comments.
werwurm May 5, 2026
b1899da
Merge branch 'refs/heads/werwurm/linux_example_nat20lib' into werwurm…
werwurm May 5, 2026
fee93e2
address comments
werwurm May 5, 2026
e5a7001
Serialize read and write access and document concurrency contracts.
werwurm May 5, 2026
b491dbb
Add macro for max instances
werwurm May 5, 2026
6062a0b
Merge branch 'refs/heads/werwurm/linux_example_nat20device' into werw…
werwurm May 5, 2026
1afed43
Update license in package config.
werwurm May 5, 2026
0eae0d8
tidy
werwurm May 5, 2026
47f9055
Add SECURITY.md and fix some issues.
werwurm May 5, 2026
6a47870
fix error handling contract.
werwurm May 6, 2026
54014fd
address comments
werwurm May 6, 2026
f645788
fixup KBuild
werwurm May 6, 2026
b621371
fixups
werwurm May 6, 2026
b7b57a6
fix error path
werwurm May 6, 2026
502f49c
fix non standard deterministic DSA construction
werwurm May 7, 2026
f5e6efd
Change shash initialization order
werwurm May 7, 2026
3ded408
typo
werwurm May 7, 2026
1957cd9
Merge branch 'werwurm/linux_example_nat20lib' into werwurm/linux_exam…
werwurm May 7, 2026
7fd4b5b
Merge branch 'main' into werwurm/linux_example_nat20device
werwurm May 7, 2026
424d872
Merge branch 'refs/heads/werwurm/linux_example_nat20device' into werw…
werwurm May 7, 2026
94a513c
address comments
werwurm May 7, 2026
49f3f1a
Merge branch 'main' into werwurm/linux_example_nat20crypto
werwurm May 7, 2026
f7b2bd3
Fix result size estimation.
werwurm May 8, 2026
c10d616
Fix underestimating size when overflowing after signing.
werwurm May 9, 2026
bf7e663
add test for underestimate after signing
werwurm May 9, 2026
13a4a4c
Merge branch 'werwurm/linux_example_nat20crypto' into werwurm/fix_cer…
werwurm May 9, 2026
f89cb70
Add nat20sw kernel module to linux examples.
werwurm Apr 28, 2026
f5285c6
address comments
werwurm May 11, 2026
8f306bb
Address comments.
werwurm May 11, 2026
080638f
Add libnat20 as buildroot package to the linux example.
werwurm Apr 28, 2026
fb0a11a
Merge branch 'werwurm/linux_example_nat20crypto' into werwurm/fix_cer…
werwurm May 12, 2026
0180dd9
Merge branch 'main' into werwurm/fix_certificate_size_estimates
werwurm May 12, 2026
d7d13bb
Merge branch 'werwurm/fix_certificate_size_estimates' into werwurm/li…
werwurm May 12, 2026
8808749
Merge branch 'main' into werwurm/linux_example_nat20sw
werwurm May 12, 2026
600e630
address comments
werwurm May 12, 2026
8b52e5f
Merge branch 'werwurm/linux_example_nat20sw' into werwurm/linux_examp…
werwurm May 12, 2026
1492110
address comments
werwurm May 12, 2026
dfc343c
Merge branch 'refs/heads/werwurm/linux_example_nat20sw' into werwurm/…
werwurm May 12, 2026
4be3210
Address comments
werwurm May 12, 2026
f3f0549
Make nat20sw.mk consistent
werwurm May 12, 2026
6bbee61
Merge branch 'refs/heads/werwurm/linux_example_nat20sw' into werwurm/…
werwurm May 12, 2026
7ffea18
address comments
werwurm May 13, 2026
42b2c9e
Merge branch 'werwurm/linux_example_nat20sw' into werwurm/linux_examp…
werwurm May 14, 2026
0612f25
Add nat20cli command line tool for nat20device.
werwurm Apr 29, 2026
b7a2f03
Address comments
werwurm May 14, 2026
47500a2
Add nat20 integration test suite for linux examples
werwurm May 14, 2026
8e3063f
Apply suggestions from code review
werwurm May 14, 2026
bb95742
address comments
werwurm May 14, 2026
2eac3fb
fix comma swallowing portability issue
werwurm May 15, 2026
b159fbb
Revert "Add nat20cli command line tool for nat20device."
werwurm May 15, 2026
839b180
Merge branch 'werwurm/linux_example_nat20sw' into werwurm/linux_examp…
werwurm May 15, 2026
3cfbb32
Merge branch 'main' into werwurm/linux_example_libnat20
werwurm May 15, 2026
8739753
Merge branch 'werwurm/linux_example_libnat20' into werwurm/linux_exam…
werwurm May 16, 2026
89d1814
Tidy test runner
werwurm May 16, 2026
a194dff
Merge branch 'main' into werwurm/linux_example_integration_test
werwurm May 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion .github/workflows/linux-kmod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b #v4.1.5

- name: Install Buildroot dependencies
- name: Install build and test dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
Expand All @@ -60,6 +60,7 @@ jobs:
git \
libncurses-dev \
python3 \
qemu-system-x86 \
rsync \
unzip \
wget
Expand Down Expand Up @@ -152,3 +153,38 @@ jobs:
find ${{ runner.temp }}/buildroot.build -name 'libnat20.a' | grep -q libnat20.a
echo "libnat20.a built successfully:"
find ${{ runner.temp }}/buildroot.build -name 'libnat20.a' -exec ls -la {} \;

- name: Build rootfs image
env:
NAT20LIB_OVERRIDE_SRCDIR: ${{ github.workspace }}
NAT20DEVICE_OVERRIDE_SRCDIR: ${{ github.workspace }}
NAT20CRYPTO_OVERRIDE_SRCDIR: ${{ github.workspace }}
NAT20SW_OVERRIDE_SRCDIR: ${{ github.workspace }}
LIBNAT20_OVERRIDE_SRCDIR: ${{ github.workspace }}
NAT20TEST_OVERRIDE_SRCDIR: ${{ github.workspace }}
run: make -C ${{ runner.temp }}/buildroot.build/buildroot -j $(( $(nproc) + 1 ))

- name: Run integration tests in QEMU
timeout-minutes: 5
run: |
BUILDROOT_DIR="${{ runner.temp }}/buildroot.build/buildroot"
KERNEL="${BUILDROOT_DIR}/output/images/bzImage"
ROOTFS="${BUILDROOT_DIR}/output/images/rootfs.ext2"

qemu-system-x86_64 \
-M pc \
-kernel "${KERNEL}" \
-drive file="${ROOTFS}",if=virtio,format=raw \
-append "rootwait root=/dev/vda console=ttyS0 init=/usr/bin/nat20test_qemu_init.sh" \
-nographic \
-no-reboot \
-net none \
2>&1 | tee qemu_output.log

if grep -q "INTEGRATION_TESTS_PASSED" qemu_output.log; then
echo "Integration tests passed."
else
echo "Integration tests failed. QEMU output:"
cat qemu_output.log
exit 1
fi
Comment on lines +157 to +190
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are also present in #104. Based on the PR title, I think they should be here.. can you please separate them out so it's more clear?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, however, this PR is correct, so you should have approved this one and not #104.

Ultimately, both are correct in this respect, I just forgot to change the base on #104 which is supposed to land after this one. I corrected this now.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ build/
cmake_install.cmake
compile_commands.json
html/
nat20test
1 change: 1 addition & 0 deletions examples/linux/br_external/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ source "$BR2_EXTERNAL_NAT20_PATH/package/nat20device/Config.in"
source "$BR2_EXTERNAL_NAT20_PATH/package/nat20sw/Config.in"
source "$BR2_EXTERNAL_NAT20_PATH/package/nat20lib/Config.in"
source "$BR2_EXTERNAL_NAT20_PATH/package/libnat20/Config.in"
source "$BR2_EXTERNAL_NAT20_PATH/package/nat20test/Config.in"
2 changes: 1 addition & 1 deletion examples/linux/br_external/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pushd ${LIBNAT20_BR_BUILD_DIR}

echo "LIBNAT20_BR_BUILD_DIR=${LIBNAT20_BR_BUILD_DIR}" | tee .env
echo "LIBNAT20_ROOT=${LIBNAT20_ROOT}" | tee -a .env
echo "LIBNAT20_PROJECT=${PROJECT}" | tee -a .env

cp ${LIBNAT20_ROOT}/examples/linux/br_external/utils/envsetup.sh ./

Expand All @@ -109,7 +110,6 @@ git clone --depth 1 --branch "2025.08.1" https://gitlab.com/buildroot.org/buildr
case "$PROJECT" in
qemu)
cp ${LIBNAT20_ROOT}/examples/linux/br_external/configs/qemu_br_defconfig buildroot/.config
cp ${LIBNAT20_ROOT}/examples/linux/br_external/run-qemu.sh ./
;;
esac

Expand Down
1 change: 1 addition & 0 deletions examples/linux/br_external/configs/qemu_br_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3981,3 +3981,4 @@ BR2_PACKAGE_NAT20DEVICE=y
BR2_PACKAGE_NAT20SW=y
BR2_PACKAGE_NAT20LIB=y
BR2_PACKAGE_LIBNAT20=y
BR2_PACKAGE_NAT20TEST=y
42 changes: 42 additions & 0 deletions examples/linux/br_external/package/nat20test/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2026 Aurora Operations, Inc.
#
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0
#
# This work is dual licensed.
# You may use it under Apache-2.0 or GPL-2.0 at your option.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# OR
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see
# <https://www.gnu.org/licenses/>.

config BR2_PACKAGE_NAT20TEST
bool "nat20test"
depends on BR2_PACKAGE_LIBNAT20
depends on BR2_PACKAGE_OPENSSL
Comment thread
werwurm marked this conversation as resolved.
select BR2_PACKAGE_NAT20SW
help
Enable building the nat20test, an integration test for nat20device with nat20sw.
51 changes: 51 additions & 0 deletions examples/linux/br_external/package/nat20test/nat20test.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2026 Aurora Operations, Inc.
#
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0
#
# This work is dual licensed.
# You may use it under Apache-2.0 or GPL-2.0 at your option.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# OR
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see
# <https://www.gnu.org/licenses/>.

# In CI NAT20TEST_OVERRIDE_SRCDIR is set to the root of the repository,
# so that the source under test is always the current branch.
# Integrators who use this configuration should pin the version
# to a specific commit or branch to avoid breakages when the main branch changes.
NAT20TEST_VERSION = origin/main
NAT20TEST_SITE = https://github.com/aurora-opensource/libnat20.git
NAT20TEST_SITE_METHOD = git
NAT20TEST_LICENSE = Apache-2.0 OR GPL-2.0
NAT20TEST_LICENSE_FILES = LICENSE-Apache-2.0.txt LICENSE-GPL-2.0.txt

NAT20TEST_SUBDIR = examples/linux/nat20test

NAT20TEST_INSTALL_TARGET = YES
NAT20TEST_DEPENDENCIES += libnat20 openssl
Comment thread
werwurm marked this conversation as resolved.

$(eval $(cmake-package))
27 changes: 26 additions & 1 deletion examples/linux/br_external/utils/envsetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export NAT20CRYPTO_OVERRIDE_SRCDIR="$LIBNAT20_ROOT"
export NAT20SW_OVERRIDE_SRCDIR="$LIBNAT20_ROOT"
export NAT20DEVICE_OVERRIDE_SRCDIR="$LIBNAT20_ROOT"
export NAT20LIB_OVERRIDE_SRCDIR="$LIBNAT20_ROOT"
export NAT20TEST_OVERRIDE_SRCDIR="$LIBNAT20_ROOT"
export LIBNAT20_OVERRIDE_SRCDIR="$LIBNAT20_ROOT"

function ensure_popd() {
Expand Down Expand Up @@ -77,16 +78,40 @@ function brrebuild() {
echo " nat20device - Rebuild the nat20device module"
echo " nat20sw - Rebuild the nat20sw module"
echo " nat20lib - Rebuild the nat20lib library"
echo " nat20test - Rebuild the nat20device integration test"
popd
return 1
fi

case "$1" in
all)
ensure_popd make linux-rebuild nat20lib-rebuild nat20crypto-rebuild nat20device-rebuild nat20sw-rebuild libnat20-rebuild all
ensure_popd make linux-rebuild nat20lib-rebuild nat20crypto-rebuild nat20device-rebuild nat20sw-rebuild libnat20-rebuild nat20test-rebuild all
;;
*)
ensure_popd make $1-rebuild all
;;
esac
}

function run-qemu() {
if [ $LIBNAT20_PROJECT != "qemu" ]; then
echo "Error: run-qemu is only supported for the qemu project."
return 1
fi

QEMU_BIN=qemu-system-x86_64

BUILDROOT_DIR="${LIBNAT20_BR_BUILD_DIR}/buildroot"
KERNEL_IMAGE="${BUILDROOT_DIR}/output/images/bzImage"
FS_IMAGE="${BUILDROOT_DIR}/output/images/rootfs.ext2"

if [ -n "$1" ]; then
"${QEMU_BIN}" -M pc -kernel "${KERNEL_IMAGE}" -nographic -drive file="${FS_IMAGE}",if=virtio,format=raw -append "rootwait root=/dev/vda console=ttyS0 init=$1" -serial mon:stdio -net nic,model=virtio -net user
else
"${QEMU_BIN}" -M pc -kernel "${KERNEL_IMAGE}" -nographic -drive file="${FS_IMAGE}",if=virtio,format=raw -append "rootwait root=/dev/vda console=ttyS0" -serial mon:stdio -net nic,model=virtio -net user
fi
}

function run-nat20test-test() {
run-qemu "/usr/bin/nat20test_qemu_init.sh"
}
82 changes: 82 additions & 0 deletions examples/linux/nat20test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Copyright 2026 Aurora Operations, Inc.
#
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0
#
# This work is dual licensed.
# You may use it under Apache-2.0 or GPL-2.0 at your option.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# OR
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see
# <https://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.22)

project(NAT20TEST VERSION 0.0.1 LANGUAGES C)

# The C standard shall be C11.
set(CMAKE_C_STANDARD 11)

# CMake shall generate a compile_commands.json file for
# the benefit of clangd based IDE support.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


###################################################################################################
# Integration test binary — exercises the nat20 DICE service via /dev/nat200.
add_executable(nat20_integration_test)

find_package(LibNat20 REQUIRED)
find_package(OpenSSL REQUIRED)

target_sources(nat20_integration_test
PRIVATE test/nat20_integration_test.c
PRIVATE test/test_helpers.c
)

target_include_directories(nat20_integration_test
PRIVATE test
)

target_link_libraries(nat20_integration_test
PRIVATE LibNat20::nat20
PRIVATE LibNat20::nat20_service
PRIVATE LibNat20::nat20_crypto_nat20
PRIVATE OpenSSL::Crypto
)

target_compile_options(nat20_integration_test
PRIVATE -pedantic
PRIVATE -Wall
PRIVATE -Wextra
PRIVATE -Werror
)

install(TARGETS nat20_integration_test RUNTIME DESTINATION bin)
install(PROGRAMS nat20test.sh DESTINATION bin)
install(PROGRAMS nat20test_qemu_init.sh DESTINATION bin)

###################################################################################################
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Copyright 2026 Aurora Operations, Inc.
#
Expand Down Expand Up @@ -35,18 +35,12 @@
# along with this program; if not, see
# <https://www.gnu.org/licenses/>.

QEMU_BIN=qemu-system-x86_64
set -e

if [ ! -f ".env" ]; then
echo ".env file not found. Please run bootstrap.sh first."
exit 1
fi
SCRIPT_DIR="$(dirname "$0")"

source .env
modprobe nat20sw
mount -t securityfs none /sys/kernel/security

BUILDROOT_DIR="${LIBNAT20_BR_BUILD_DIR}/buildroot"
KERNEL_IMAGE="${BUILDROOT_DIR}/output/images/bzImage"
FS_IMAGE="${BUILDROOT_DIR}/output/images/rootfs.ext2"


"${QEMU_BIN}" -M pc -kernel "${KERNEL_IMAGE}" -nographic -drive file="${FS_IMAGE}",if=virtio,format=raw -append "rootwait root=/dev/vda console=ttyS0" -serial mon:stdio -net nic,model=virtio -net user
echo "Running integration test suite..."
"${SCRIPT_DIR}/nat20_integration_test"
Loading
Loading