summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2018-09-04 08:25:07 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2018-09-18 15:32:36 +0200
commit691c71a7f2a1d2816a11165480e45355dcf032cb (patch)
treeb646fc278de877c42d31dd71b921944741867b54
parentd9a4b59c18e36f2b577744b7fe6710d71161ca12 (diff)
downloadNetworkManager-bg/n-acd-update.tar.gz
build: allow disabling eBPF support in n-acdbg/n-acd-update
Add a configure option to disable eBPF support in n-acd. Note that, even if eBPF is not supported, n-acd requires a kernel > 3.19, which means that the setsockopt(..., SO_ATTACH_BPF) option must be defined. To allow building on older kernels without modifying the n-acd code, we inject the SO_ATTACH_BPF value as a preprocessor define in the compiler the command line.
-rw-r--r--.travis.yml4
-rw-r--r--Makefile.am8
-rw-r--r--configure.ac10
-rw-r--r--meson_options.txt1
-rw-r--r--shared/meson.build12
5 files changed, 31 insertions, 4 deletions
diff --git a/.travis.yml b/.travis.yml
index de6ff770a0..1149c8b830 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
+ build_command_prepend: sh autogen.sh --with-systemd-logind=no --enable-more-warnings=no --disable-ovs --without-ebpf
build_command: make -j4
branch_pattern: .*coverity.*
@@ -114,6 +114,7 @@ script:
-D ifcfg_rh=false \
-D ibft=true \
-D ifupdown=true \
+ -D ebpf=false \
&&
ninja -C build &&
ninja -C build test
@@ -136,6 +137,7 @@ script:
--enable-more-warnings=no \
--enable-tests=yes \
--with-crypto=$CRYPTO \
+ --without-ebpf \
\
--with-libnm-glib=yes \
--with-iwd=yes \
diff --git a/Makefile.am b/Makefile.am
index 70a1f05dd4..afa6cfc852 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1370,6 +1370,7 @@ shared_libnacd_la_LIBADD = shared/libcrbtree.la
shared_libnacd_la_CPPFLAGS = \
-D_GNU_SOURCE \
+ -DSO_ATTACH_BPF=50 \
$(CODE_COVERAGE_CFLAGS) \
$(SANITIZER_LIB_CFLAGS) \
-I$(srcdir)/shared/c-list/src \
@@ -1380,12 +1381,17 @@ shared_libnacd_la_CPPFLAGS = \
shared_libnacd_la_SOURCES = \
shared/n-acd/src/n-acd.c \
shared/n-acd/src/n-acd.h \
- shared/n-acd/src/n-acd-bpf.c \
shared/n-acd/src/n-acd-private.h \
shared/n-acd/src/n-acd-probe.c \
shared/n-acd/src/util/timer.c \
shared/n-acd/src/util/timer.h
+if WITH_EBPF
+shared_libnacd_la_SOURCES += shared/n-acd/src/n-acd-bpf.c
+else
+shared_libnacd_la_SOURCES += shared/n-acd/src/n-acd-bpf-fallback.c
+endif
+
EXTRA_DIST += shared/c-list/src/c-list.h
###############################################################################
diff --git a/configure.ac b/configure.ac
index e080d359cc..a8b0083e5f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -518,6 +518,15 @@ case $with_suspend_resume in
;;
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])
+fi
+AM_CONDITIONAL(WITH_EBPF, test "${with_ebpf}" = "yes")
+
# SELinux support
AC_ARG_WITH(selinux,
AS_HELP_STRING([--with-selinux=yes|no|auto], [Build with SELinux (default: auto)]),
@@ -1353,4 +1362,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
diff --git a/meson_options.txt b/meson_options.txt
index 7f06d53a71..ee205601c3 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -41,6 +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')
# 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 bb743cbd70..780c31fefe 100644
--- a/shared/meson.build
+++ b/shared/meson.build
@@ -23,17 +23,25 @@ shared_c_rbtree_dep = declare_dependency(
link_with: shared_c_rbtree,
)
+
+if get_option('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')
+endif
+
shared_n_acd = static_library(
'n-acd',
sources: files('n-acd/src/n-acd.c',
'n-acd/src/n-acd.h',
- 'n-acd/src/n-acd-bpf.c',
'n-acd/src/n-acd-private.h',
'n-acd/src/n-acd-probe.c',
'n-acd/src/util/timer.c',
- 'n-acd/src/util/timer.h'),
+ 'n-acd/src/util/timer.h')
+ + shared_n_acd_bpf_files,
c_args: [
'-D_GNU_SOURCE',
+ '-DSO_ATTACH_BPF=50',
'-std=c11',
'-Wno-pointer-arith',
'-Wno-vla',