diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2018-09-19 16:38:38 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2018-09-19 17:23:11 +0200 |
commit | 81a565ebe5ded63c1da77500808d44dfd73d9df8 (patch) | |
tree | ae8c83d905cd5a0456bc274a9734d1358646631f | |
parent | c7c3acf28029aef8a839ec7629a62e53e963ea81 (diff) | |
download | NetworkManager-81a565ebe5ded63c1da77500808d44dfd73d9df8.tar.gz |
build: autodetect ebpf support
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | configure.ac | 17 | ||||
-rw-r--r-- | meson.build | 13 | ||||
-rw-r--r-- | meson_options.txt | 2 | ||||
-rw-r--r-- | shared/meson.build | 2 |
5 files changed, 27 insertions, 11 deletions
diff --git a/.travis.yml b/.travis.yml index 6a0a3d89cd..c96bb9496a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ addons: coverity_scan: project: name: NetworkManager/NetworkManager - build_command_prepend: sh autogen.sh --with-systemd-logind=no --enable-more-warnings=no --disable-ovs --without-ebpf + build_command_prepend: sh autogen.sh --with-systemd-logind=no --enable-more-warnings=no --disable-ovs build_command: make -j4 branch_pattern: .*coverity.* @@ -114,7 +114,6 @@ script: -D ifcfg_rh=false \ -D ibft=true \ -D ifupdown=true \ - -D ebpf=false \ && ninja -C build && ninja -C build test @@ -137,7 +136,6 @@ script: --enable-more-warnings=no \ --enable-tests=yes \ --with-crypto=$CRYPTO \ - --without-ebpf \ \ --with-libnm-glib=yes \ --with-iwd=yes \ diff --git a/configure.ac b/configure.ac index 49d2e5a02f..946f6b35e5 100644 --- a/configure.ac +++ b/configure.ac @@ -520,12 +520,17 @@ esac # eBPF support AC_ARG_WITH(ebpf, - AS_HELP_STRING([--with-ebpf=yes|no], [Build with eBPF support (default: yes)]), - [], [with_ebpf=yes]) -if test "$with_ebpf" != "yes" -a "$with_ebpf" != "no"; then - AC_MSG_ERROR(--with-ebpf must be one of [yes, no]) + AS_HELP_STRING([--with-ebpf=yes|no|auto], [Build with eBPF support (default: auto)]), + [], [with_ebpf=auto]) +if test "$with_ebpf" = "yes" -o "$with_ebpf" = "auto"; then + AC_CHECK_HEADER(linux/bpf.h, [have_ebpf=yes], [have_ebpf=no]) +else + have_ebpf=no +fi +if test "$with_ebpf" = "yes" -a "$have_ebpf" = "no"; then + AC_MSG_ERROR([--with-ebpf=yes requires eBPF kernel header]) fi -AM_CONDITIONAL(WITH_EBPF, test "${with_ebpf}" = "yes") +AM_CONDITIONAL(WITH_EBPF, test "${have_ebpf}" = "yes") # SELinux support AC_ARG_WITH(selinux, @@ -1362,5 +1367,5 @@ echo " JSON validation for libnm: $enable_json_validation" echo " crypto: $with_crypto (have-gnutls: $have_crypto_gnutls, have-nss: $have_crypto_nss)" echo " sanitizers: $sanitizers" echo " Mozilla Public Suffix List: $with_libpsl" -echo " eBPF: $with_ebpf" +echo " eBPF: $have_ebpf" echo diff --git a/meson.build b/meson.build index 8d6fa031f0..32e9522171 100644 --- a/meson.build +++ b/meson.build @@ -423,6 +423,18 @@ if enable_selinux endif config_h.set10('HAVE_SELINUX', enable_selinux) +# eBPF support +ebpf_opt = get_option('ebpf') +if ebpf_opt == 'false' + enable_ebpf = false +else + enable_ebpf = true + if not cc.has_header('linux/bpf.h') + assert(ebpf_opt != 'true', 'eBPF requires kernel support') + enable_ebpf = false + endif +endif + # libaudit support libaudit = get_option('libaudit') enable_libaudit = libaudit.contains('yes') @@ -994,4 +1006,5 @@ output += ' crypto: ' + crypto + ' (have-gnutls: ' + crypto_gnutls_dep.found(). output += ' sanitizers: ' + get_option('b_sanitize') + '\n' output += ' Mozilla Public Suffix List: ' + enable_libpsl.to_string() + '\n' output += ' vapi: ' + enable_vapi.to_string() + '\n' +output += ' ebpf: ' + enable_ebpf.to_string() + '\n' message(output) diff --git a/meson_options.txt b/meson_options.txt index 1e7f886d27..bd8e8b641a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -41,7 +41,7 @@ option('libnm_glib', type: 'boolean', value: false, description: 'build legacy l option('nmcli', type: 'boolean', value: true, description: 'Build nmcli') option('nmtui', type: 'boolean', value: true, description: 'Build nmtui') option('bluez5_dun', type: 'boolean', value: false, description: 'enable Bluez5 DUN support') -option('ebpf', type: 'boolean', value: true, description: 'Enable or disable eBPF support') +option('ebpf', type: 'combo', choices : ['auto', 'true', 'false'], description: 'Enable eBPF support') # configuration plugins option('config_plugins_default', type: 'string', value: '', description: 'Default configuration option for main.plugins setting, used as fallback if the configuration option is unset') diff --git a/shared/meson.build b/shared/meson.build index 780c31fefe..9fb665bcbb 100644 --- a/shared/meson.build +++ b/shared/meson.build @@ -24,7 +24,7 @@ shared_c_rbtree_dep = declare_dependency( ) -if get_option('ebpf') +if enable_ebpf shared_n_acd_bpf_files = files('n-acd/src/n-acd-bpf.c') else shared_n_acd_bpf_files = files('n-acd/src/n-acd-bpf-fallback.c') |