diff --git a/src/basic/build.c b/src/basic/build.c index f8baaabb9f..e34d23adeb 100644 --- a/src/basic/build.c +++ b/src/basic/build.c @@ -194,6 +194,12 @@ const char* const systemd_features = /* other stuff that doesn't fit above */ +#if BPF_FRAMEWORK + " +BPF_FRAMEWORK" +#else + " -BPF_FRAMEWORK" +#endif + #if HAVE_XKBCOMMON " +XKBCOMMON" #else diff --git a/src/core/bpf/meson.build b/src/core/bpf/meson.build index ab1a7167a6..cd0cd3230b 100644 --- a/src/core/bpf/meson.build +++ b/src/core/bpf/meson.build @@ -1,61 +1,63 @@ # SPDX-License-Identifier: LGPL-2.1+ -if conf.get('BPF_FRAMEWORK') == 1 - clang_flags = [ - '-Wno-compare-distinct-pointer-types', - '-O2', - '-target', - 'bpf', - '-g', - '-c', - ] - - clang_arch_flag = '-D__@0@__'.format(host_machine.cpu_family()) - - if meson.version().version_compare('>= 0.58') - libbpf_include_dir = libbpf.get_variable('includedir') - else - libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir') - endif - - bpf_o_unstripped_cmd = [ - clang, - clang_flags, - clang_arch_flag, - '-I.' - ] - - if not meson.is_cross_build() - target_triplet_cmd = run_command('gcc', '-dumpmachine', check: false) - if target_triplet_cmd.returncode() == 0 - target_triplet = target_triplet_cmd.stdout().strip() - bpf_o_unstripped_cmd += [ - '-isystem', - '/usr/include/@0@'.format(target_triplet) - ] - endif - endif - - bpf_o_unstripped_cmd += [ - '-idirafter', - libbpf_include_dir, - '@INPUT@', - '-o', - '@OUTPUT@' - ] - - bpf_o_cmd = [ - llvm_strip, - '-g', - '@INPUT@', - '-o', - '@OUTPUT@' - ] - - skel_h_cmd = [ - bpftool, - 'g', - 's', - '@INPUT@' - ] +if conf.get('BPF_FRAMEWORK') != 1 + subdir_done() endif + +clang_flags = [ + '-Wno-compare-distinct-pointer-types', + '-O2', + '-target', + 'bpf', + '-g', + '-c', +] + +clang_arch_flag = '-D__@0@__'.format(host_machine.cpu_family()) + +if meson.version().version_compare('>= 0.58') + libbpf_include_dir = libbpf.get_variable('includedir') +else + libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir') +endif + +bpf_o_unstripped_cmd = [ + clang, + clang_flags, + clang_arch_flag, + '-I.' +] + +if not meson.is_cross_build() + target_triplet_cmd = run_command('gcc', '-dumpmachine', check: false) + if target_triplet_cmd.returncode() == 0 + target_triplet = target_triplet_cmd.stdout().strip() + bpf_o_unstripped_cmd += [ + '-isystem', + '/usr/include/@0@'.format(target_triplet) + ] + endif +endif + +bpf_o_unstripped_cmd += [ + '-idirafter', + libbpf_include_dir, + '@INPUT@', + '-o', + '@OUTPUT@' +] + +bpf_o_cmd = [ + llvm_strip, + '-g', + '@INPUT@', + '-o', + '@OUTPUT@' +] + +skel_h_cmd = [ + bpftool, + 'g', + 's', + '@INPUT@' +] diff --git a/src/core/bpf/restrict_fs/meson.build b/src/core/bpf/restrict_fs/meson.build index dfe3f12033..69cde02a7b 100644 --- a/src/core/bpf/restrict_fs/meson.build +++ b/src/core/bpf/restrict_fs/meson.build @@ -1,22 +1,24 @@ # SPDX-License-Identifier: LGPL-2.1-or-later -if conf.get('BPF_FRAMEWORK') == 1 - restrict_fs_bpf_o_unstripped = custom_target( - 'restrict-fs.bpf.unstripped.o', - input : 'restrict-fs.bpf.c', - output : 'restrict-fs.bpf.unstripped.o', - command : bpf_o_unstripped_cmd) - - restrict_fs_bpf_o = custom_target( - 'restrict-fs.bpf.o', - input : restrict_fs_bpf_o_unstripped, - output : 'restrict-fs.bpf.o', - command : bpf_o_cmd) - - restrict_fs_skel_h = custom_target( - 'restrict-fs.skel.h', - input : restrict_fs_bpf_o, - output : 'restrict-fs.skel.h', - command : skel_h_cmd, - capture : true) +if conf.get('BPF_FRAMEWORK') != 1 + subdir_done() endif + +restrict_fs_bpf_o_unstripped = custom_target( + 'restrict-fs.bpf.unstripped.o', + input : 'restrict-fs.bpf.c', + output : 'restrict-fs.bpf.unstripped.o', + command : bpf_o_unstripped_cmd) + +restrict_fs_bpf_o = custom_target( + 'restrict-fs.bpf.o', + input : restrict_fs_bpf_o_unstripped, + output : 'restrict-fs.bpf.o', + command : bpf_o_cmd) + +restrict_fs_skel_h = custom_target( + 'restrict-fs.skel.h', + input : restrict_fs_bpf_o, + output : 'restrict-fs.skel.h', + command : skel_h_cmd, + capture : true) diff --git a/src/core/bpf/restrict_ifaces/meson.build b/src/core/bpf/restrict_ifaces/meson.build index b7e2bc1519..5f36178228 100644 --- a/src/core/bpf/restrict_ifaces/meson.build +++ b/src/core/bpf/restrict_ifaces/meson.build @@ -1,22 +1,24 @@ # SPDX-License-Identifier: LGPL-2.1-or-later -if conf.get('BPF_FRAMEWORK') == 1 - restrict_ifaces_bpf_o_unstripped = custom_target( - 'restrict-ifaces.bpf.unstripped.o', - input : 'restrict-ifaces.bpf.c', - output : 'restrict-ifaces.bpf.unstripped.o', - command : bpf_o_unstripped_cmd) - - restrict_ifaces_bpf_o = custom_target( - 'restrict-ifaces.bpf.o', - input : restrict_ifaces_bpf_o_unstripped, - output : 'restrict-ifaces.bpf.o', - command : bpf_o_cmd) - - restrict_ifaces_skel_h = custom_target( - 'restrict-ifaces.skel.h', - input : restrict_ifaces_bpf_o, - output : 'restrict-ifaces.skel.h', - command : skel_h_cmd, - capture : true) +if conf.get('BPF_FRAMEWORK') != 1 + subdir_done() endif + +restrict_ifaces_bpf_o_unstripped = custom_target( + 'restrict-ifaces.bpf.unstripped.o', + input : 'restrict-ifaces.bpf.c', + output : 'restrict-ifaces.bpf.unstripped.o', + command : bpf_o_unstripped_cmd) + +restrict_ifaces_bpf_o = custom_target( + 'restrict-ifaces.bpf.o', + input : restrict_ifaces_bpf_o_unstripped, + output : 'restrict-ifaces.bpf.o', + command : bpf_o_cmd) + +restrict_ifaces_skel_h = custom_target( + 'restrict-ifaces.skel.h', + input : restrict_ifaces_bpf_o, + output : 'restrict-ifaces.skel.h', + command : skel_h_cmd, + capture : true) diff --git a/src/core/bpf/socket_bind/meson.build b/src/core/bpf/socket_bind/meson.build index 8211a7a5c9..05a2b9daf8 100644 --- a/src/core/bpf/socket_bind/meson.build +++ b/src/core/bpf/socket_bind/meson.build @@ -1,22 +1,24 @@ # SPDX-License-Identifier: LGPL-2.1-or-later -if conf.get('BPF_FRAMEWORK') == 1 - socket_bind_bpf_o_unstripped = custom_target( - 'socket-bind.bpf.unstripped.o', - input : 'socket-bind.bpf.c', - output : 'socket-bind.bpf.unstripped.o', - command : bpf_o_unstripped_cmd) - - socket_bind_bpf_o = custom_target( - 'socket-bind.bpf.o', - input : socket_bind_bpf_o_unstripped, - output : 'socket-bind.bpf.o', - command : bpf_o_cmd) - - socket_bind_skel_h = custom_target( - 'socket-bind.skel.h', - input : socket_bind_bpf_o, - output : 'socket-bind.skel.h', - command : skel_h_cmd, - capture : true) +if conf.get('BPF_FRAMEWORK') != 1 + subdir_done() endif + +socket_bind_bpf_o_unstripped = custom_target( + 'socket-bind.bpf.unstripped.o', + input : 'socket-bind.bpf.c', + output : 'socket-bind.bpf.unstripped.o', + command : bpf_o_unstripped_cmd) + +socket_bind_bpf_o = custom_target( + 'socket-bind.bpf.o', + input : socket_bind_bpf_o_unstripped, + output : 'socket-bind.bpf.o', + command : bpf_o_cmd) + +socket_bind_skel_h = custom_target( + 'socket-bind.skel.h', + input : socket_bind_bpf_o, + output : 'socket-bind.skel.h', + command : skel_h_cmd, + capture : true) diff --git a/test/units/testsuite-62.sh b/test/units/testsuite-62.sh index ee67c94ab1..2f3b18bec3 100755 --- a/test/units/testsuite-62.sh +++ b/test/units/testsuite-62.sh @@ -36,7 +36,7 @@ teardown() { KERNEL_VERSION="$(uname -r)" KERNEL_MAJOR="${KERNEL_VERSION%%.*}" -KERNEL_MINOR="${KERNEL_VERSION#$KERNEL_MAJOR.}" +KERNEL_MINOR="${KERNEL_VERSION#"$KERNEL_MAJOR".}" KERNEL_MINOR="${KERNEL_MINOR%%.*}" MAJOR_REQUIRED=5 @@ -47,6 +47,11 @@ if [[ "$KERNEL_MAJOR" -lt $MAJOR_REQUIRED || ("$KERNEL_MAJOR" -eq $MAJOR_REQUIRE exit 0 fi +if systemctl --version | grep -q -F "-BPF_FRAMEWORK"; then + echo "bpf-framework is disabled" >>/skipped + exit 0 +fi + trap teardown EXIT setup