Skip to content

Commit

Permalink
configure: Don't fail on missing bpftool
Browse files Browse the repository at this point in the history
Instead of bailing out of configure if bpftool is not found, just disable
compilation of the tools that require it (i.e., xdp-bench, xdp-monitor and
xdp-trafficgen which use BPF skeletons).

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
  • Loading branch information
tohojo committed Oct 20, 2023
1 parent 1dc1e78 commit 2b139e0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ MAKEFLAGS += --no-print-directory
endif

include version.mk
include config.mk

UTILS := xdp-filter xdp-loader xdp-dump

ifneq ($(BPFTOOL),)
UTILS += xdp-bench xdp-monitor xdp-trafficgen
endif

UTILS := xdp-filter xdp-loader xdp-dump xdp-bench xdp-monitor xdp-trafficgen
SUBDIRS := lib $(UTILS)
.PHONY: check_submodule help clobber distclean clean install test libxdp $(SUBDIRS)

Expand Down
11 changes: 6 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ check_toolchain()
CLANG=$(find_tool clang "$CLANG")
LLC=$(find_tool llc "$LLC")

for TOOL in $PKG_CONFIG $CC $LD $OBJCOPY $CLANG $LLC $M4 $BPFTOOL $READELF; do
for TOOL in $PKG_CONFIG $CC $LD $OBJCOPY $CLANG $LLC $M4 $READELF; do
if [ ! $(command -v ${TOOL} 2>/dev/null) ]; then
echo "*** ERROR: Cannot find tool ${TOOL}" ;
exit 1;
Expand Down Expand Up @@ -112,12 +112,12 @@ check_toolchain()
exit 1
fi

if $BPFTOOL gen help 2>&1 | grep 'gen skeleton.*name' > /dev/null; then
if command -v $BPFTOOL &>/dev/null && $BPFTOOL gen help 2>&1 | grep 'gen skeleton.*name' > /dev/null; then
bpftool_version=$($BPFTOOL version | head -n 1)
echo "using $bpftool_version"
else
echo "bpftool doesn't support skeleton generation"
exit 1
echo "bpftool not found or doesn't support skeleton generation; not building all tools"
BPFTOOL=
fi

if [ -z "$ARCH_INCLUDES" ] && [ -n "$ARCH_NAME" ]; then
Expand All @@ -137,8 +137,9 @@ check_toolchain()
echo "M4:=${M4}" >>$CONFIG
echo "EMACS:=${EMACS}" >>$CONFIG
echo "ARCH_INCLUDES:=$ARCH_INCLUDES" >> $CONFIG
echo "BPFTOOL:=${BPFTOOL}" >> $CONFIG
echo "READELF:=${READELF}" >> $CONFIG
echo "BPFTOOL:=${BPFTOOL}" >> $CONFIG
[ -n "$BPFTOOL" ] && echo "HAVE_FEATURES+=BPFTOOL" >>"$CONFIG"
}

check_zlib()
Expand Down
4 changes: 4 additions & 0 deletions lib/testing/test-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,14 @@ int do_probe(const void *cfg, __unused const char *pin_root_path)

switch (opt->action) {
case PROBE_CPUMAP_PROGRAM:
#ifdef HAVE_BPFTOOL
res = sample_probe_cpumap_compat();
#endif
break;
case PROBE_XDP_LOAD_BYTES:
#ifdef HAVE_BPFTOOL
res = sample_probe_xdp_load_bytes();
#endif
break;
default:
return EXIT_FAILURE;
Expand Down
13 changes: 11 additions & 2 deletions lib/util/util.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
UTIL_OBJS := params.o logging.o util.o stats.o xpcapng.o xdp_sample.o
UTIL_BPF_OBJS := xdp_sample.bpf.o xdp_load_bytes.bpf.o
LIB_DIR ?= ..
include $(LIB_DIR)/defines.mk

UTIL_OBJS := params.o logging.o util.o stats.o xpcapng.o
UTIL_BPF_OBJS :=

ifneq ($(BPFTOOL),)
UTIL_OBJS += xdp_sample.o
UTIL_BPF_OBJS += xdp_sample.bpf.o xdp_load_bytes.bpf.o
endif

0 comments on commit 2b139e0

Please sign in to comment.