Skip to content

Commit 8a62188

Browse files
committed
feat(configure): add sanity check for kmod/ebpf
Signed-off-by: Gerlando Falauto <[email protected]>
1 parent de58f57 commit 8a62188

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

driver/bpf/configure/0__SANITY/test.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: GPL-2.0-only OR MIT
2+
/*
3+
4+
Copyright (C) 2024 The Falco Authors.
5+
6+
This file is dual licensed under either the MIT or GPL 2. See MIT.txt
7+
or GPL2.txt for full copies of the license.
8+
9+
*/
10+
11+
/*
12+
* Check that the build system is sane.
13+
*/
14+
15+
#include "../../quirks.h"
16+
#include "../../ppm_events_public.h"
17+
#include "../../types.h"
18+
19+
BPF_PROBE("sanity/", sanity, sanity_args) {
20+
return 0;
21+
}
22+
23+
char __license[] __bpf_section("license") = "Dual MIT/GPL";

driver/bpf/configure/Makefile.inc.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,12 @@ HAS_@CONFIGURE_MODULE@_OUT := $(subst @@NEWLINE@@,$(newline),$(HAS_@CONFIGURE_MO
1212
$(info [configure-bpf] Build output for HAS_@CONFIGURE_MODULE@:)
1313
$(info [configure-bpf] $(HAS_@CONFIGURE_MODULE@_OUT))
1414
endif
15+
16+
ifeq ('@CONFIGURE_MODULE@','0__SANITY')
17+
ifeq ($(HAS_@CONFIGURE_MODULE@),0)
18+
$(info [configure-bpf] Build system is sane)
19+
else
20+
$(info [configure-bpf] Build system is broken, please see above errors)
21+
$(error The build system is broken, please see above errors)
22+
endif
23+
endif

driver/configure/0__SANITY/test.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
3+
Copyright (C) 2023 The Falco Authors.
4+
5+
This file is dual licensed under either the MIT or GPL 2. See MIT.txt
6+
or GPL2.txt for full copies of the license.
7+
8+
*/
9+
10+
/*
11+
* Check that the build environment is sane
12+
*/
13+
14+
#include <linux/module.h>
15+
16+
MODULE_LICENSE("GPL");
17+
MODULE_AUTHOR("the Falco authors");
18+
19+
static int empty_init(void) {
20+
return 0;
21+
}
22+
23+
static void empty_exit(void) {}
24+
25+
module_init(empty_init);
26+
module_exit(empty_exit);

driver/configure/Makefile.inc.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,12 @@ HAS_@CONFIGURE_MODULE@_OUT := $(subst @@NEWLINE@@,$(newline),$(HAS_@CONFIGURE_MO
1414
$(info [configure-kmod] Build output for HAS_@CONFIGURE_MODULE@:)
1515
$(info [configure-kmod] $(HAS_@CONFIGURE_MODULE@_OUT))
1616
endif
17+
18+
ifeq ('@CONFIGURE_MODULE@','0__SANITY')
19+
ifeq ($(HAS_@CONFIGURE_MODULE@),0)
20+
$(info [configure-kmod] Build system is sane)
21+
else
22+
$(info [configure-kmod] Build system is broken, please see above errors)
23+
$(error The build system is broken, please see above errors)
24+
endif
25+
endif

0 commit comments

Comments
 (0)