From 986a30bf9ba561b0d5acd7e39e16093639a82917 Mon Sep 17 00:00:00 2001 From: Fiona Klute Date: Fri, 1 May 2026 15:10:30 +0200 Subject: [PATCH] package/kmod: enable dlopen() for compression libraries (if any) With dlopen() enabled, kmod will load compression libraries only if actually needed (loading compressed modules into the kernel does not if the kernel can handle decompression, depending on its configuration), and only the needed one. Use compressed modules in the kmod test without enabling in-kernel decompression to verify decompression in kmod works. Signed-off-by: Fiona Klute Signed-off-by: Marcus Hoffmann --- package/kmod/kmod.mk | 4 ++++ support/testing/tests/package/test_kmod.py | 18 +++++++++++++----- .../test_kmod/compressed-modules.fragment | 3 +++ 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 support/testing/tests/package/test_kmod/compressed-modules.fragment diff --git a/package/kmod/kmod.mk b/package/kmod/kmod.mk index 0901afc872..4bd64f8456 100644 --- a/package/kmod/kmod.mk +++ b/package/kmod/kmod.mk @@ -28,6 +28,10 @@ endif KMOD_CONF_OPTS += -Dfishcompletiondir=no -Dzshcompletiondir=no +# load compression libraries (if any are enabled below) as needed +# using dlopen() +KMOD_CONF_OPTS += -Ddlopen=all + ifeq ($(BR2_PACKAGE_ZLIB),y) KMOD_DEPENDENCIES += zlib KMOD_CONF_OPTS += -Dzlib=enabled diff --git a/support/testing/tests/package/test_kmod.py b/support/testing/tests/package/test_kmod.py index e11d3b702c..3c06589b2b 100644 --- a/support/testing/tests/package/test_kmod.py +++ b/support/testing/tests/package/test_kmod.py @@ -4,10 +4,13 @@ import infra.basetest class TestKmod(infra.basetest.BRTest): - # This test uses the "virtio_net" driver compiled as a module. We - # need to recompile a Kernel for that. - kernel_fragment = \ - infra.filepath("tests/package/test_kmod/linux-virtio-net.fragment") + # This test uses the "virtio_net" driver compiled as a module, and + # compressed modules to test that kmod can handle them. We need to + # compile a kernel for that. + kernel_fragments = ( + infra.filepath("tests/package/test_kmod/compressed-modules.fragment"), + infra.filepath("tests/package/test_kmod/linux-virtio-net.fragment"), + ) config = \ f""" BR2_aarch64=y @@ -18,10 +21,13 @@ class TestKmod(infra.basetest.BRTest): BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.135" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config" - BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kernel_fragment}" + BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{" ".join(kernel_fragments)}" BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y BR2_PACKAGE_KMOD=y BR2_PACKAGE_KMOD_TOOLS=y + BR2_PACKAGE_ZSTD=y + BR2_PACKAGE_HOST_KMOD=y + BR2_PACKAGE_HOST_KMOD_ZSTD=y BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_ROOTFS_EXT2_4=y # BR2_TARGET_ROOTFS_TAR is not set @@ -48,6 +54,7 @@ class TestKmod(infra.basetest.BRTest): out, ret = self.emulator.run("modprobe --version") self.assertEqual(ret, 0) self.assertTrue(out[0].startswith("kmod version")) + self.assertIn("+ZSTD", out[1]) # List modules with "kmod list", the virtio-net module should # NOT be loaded yet. @@ -61,6 +68,7 @@ class TestKmod(infra.basetest.BRTest): lsmod_out = "\n".join(out) self.assertRegex(lsmod_out, r'name: *virtio_net') self.assertRegex(lsmod_out, r'description: *Virtio network driver') + self.assertRegex(lsmod_out, r'filename:\s+/.*/virtio_net.ko.zst') # With this test configuration, we are not supposed to have an # eth0 Ethernet interface yet. Attempting to show info on this diff --git a/support/testing/tests/package/test_kmod/compressed-modules.fragment b/support/testing/tests/package/test_kmod/compressed-modules.fragment new file mode 100644 index 0000000000..2471adebbd --- /dev/null +++ b/support/testing/tests/package/test_kmod/compressed-modules.fragment @@ -0,0 +1,3 @@ +CONFIG_MODULE_COMPRESS=y +CONFIG_MODULE_COMPRESS_ZSTD=y +CONFIG_MODULE_COMPRESS_ALL=y