Skip to content

Commit

Permalink
feat(configure): add sanity check for kmod/ebpf
Browse files Browse the repository at this point in the history
Signed-off-by: Gerlando Falauto <[email protected]>
  • Loading branch information
iurly committed Feb 18, 2025
1 parent de58f57 commit 8a62188
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
23 changes: 23 additions & 0 deletions driver/bpf/configure/0__SANITY/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: GPL-2.0-only OR MIT
/*
Copyright (C) 2024 The Falco Authors.
This file is dual licensed under either the MIT or GPL 2. See MIT.txt
or GPL2.txt for full copies of the license.
*/

/*
* Check that the build system is sane.
*/

#include "../../quirks.h"
#include "../../ppm_events_public.h"
#include "../../types.h"

BPF_PROBE("sanity/", sanity, sanity_args) {
return 0;
}

char __license[] __bpf_section("license") = "Dual MIT/GPL";
9 changes: 9 additions & 0 deletions driver/bpf/configure/Makefile.inc.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ HAS_@CONFIGURE_MODULE@_OUT := $(subst @@NEWLINE@@,$(newline),$(HAS_@CONFIGURE_MO
$(info [configure-bpf] Build output for HAS_@CONFIGURE_MODULE@:)
$(info [configure-bpf] $(HAS_@CONFIGURE_MODULE@_OUT))
endif

ifeq ('@CONFIGURE_MODULE@','0__SANITY')
ifeq ($(HAS_@CONFIGURE_MODULE@),0)
$(info [configure-bpf] Build system is sane)
else
$(info [configure-bpf] Build system is broken, please see above errors)
$(error The build system is broken, please see above errors)
endif
endif
26 changes: 26 additions & 0 deletions driver/configure/0__SANITY/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright (C) 2023 The Falco Authors.
This file is dual licensed under either the MIT or GPL 2. See MIT.txt
or GPL2.txt for full copies of the license.
*/

/*
* Check that the build environment is sane
*/

#include <linux/module.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("the Falco authors");

static int empty_init(void) {
return 0;
}

static void empty_exit(void) {}

module_init(empty_init);
module_exit(empty_exit);
9 changes: 9 additions & 0 deletions driver/configure/Makefile.inc.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@ HAS_@CONFIGURE_MODULE@_OUT := $(subst @@NEWLINE@@,$(newline),$(HAS_@CONFIGURE_MO
$(info [configure-kmod] Build output for HAS_@CONFIGURE_MODULE@:)
$(info [configure-kmod] $(HAS_@CONFIGURE_MODULE@_OUT))
endif

ifeq ('@CONFIGURE_MODULE@','0__SANITY')
ifeq ($(HAS_@CONFIGURE_MODULE@),0)
$(info [configure-kmod] Build system is sane)
else
$(info [configure-kmod] Build system is broken, please see above errors)
$(error The build system is broken, please see above errors)
endif
endif

0 comments on commit 8a62188

Please sign in to comment.