Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ check_toolchain()
: ${BPFTOOL=bpftool}
: ${READELF=readelf}
: ${ARCH_INCLUDES=}
: ${BPF_SKIP_STD_INCLUDE:=0}
: ${ARCH_NAME=}

CLANG=$(find_tool clang "$CLANG")
Expand Down Expand Up @@ -136,6 +137,7 @@ check_toolchain()
echo "M4:=${M4}" >>$CONFIG
echo "EMACS:=${EMACS}" >>$CONFIG
echo "ARCH_INCLUDES:=$ARCH_INCLUDES" >> $CONFIG
echo "BPF_SKIP_STD_INCLUDE:=$BPF_SKIP_STD_INCLUDE" >> $CONFIG
echo "READELF:=${READELF}" >> $CONFIG
echo "BPFTOOL:=${BPFTOOL}" >> $CONFIG
[ -n "$BPFTOOL" ] && echo "HAVE_FEATURES+=BPFTOOL" >>"$CONFIG"
Expand Down
13 changes: 13 additions & 0 deletions headers/asm/bitsperlong.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* Arch-neutral bitsperlong for the BPF targets (bpfel/bpfeb), shadowing
* the arch-specific asm/bitsperlong.h copies which select their value
* with compiler backend macros a -target bpf compile never defines
* (_MIPS_SZLONG, __x86_64__, ...).
*/
#ifndef __ASM_BITSPERLONG_H
#define __ASM_BITSPERLONG_H

#include <asm-generic/bitsperlong.h>

#endif /* __ASM_BITSPERLONG_H */
16 changes: 16 additions & 0 deletions headers/asm/byteorder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* Arch-neutral byteorder for the BPF targets (bpfel/bpfeb), shadowing
* the arch-specific asm/byteorder.h copies which select their flavour
* with compiler backend macros a -target bpf compile never defines.
*/
#ifndef _ASM_BYTEORDER_H
#define _ASM_BYTEORDER_H

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#include <linux/byteorder/little_endian.h>
#else
#include <linux/byteorder/big_endian.h>
#endif

#endif /* _ASM_BYTEORDER_H */
8 changes: 7 additions & 1 deletion lib/defines.mk
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ endif
DEFINES += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64

CFLAGS += -std=gnu2x -Wextra -Werror $(DEFINES) $(ARCH_INCLUDES)
BPF_CFLAGS += -std=gnu2x $(DEFINES) $(filter -ffile-prefix-map=%,$(CFLAGS)) $(filter -I%,$(CFLAGS)) $(ARCH_INCLUDES)

BPF_CFLAGS += -std=gnu2x $(DEFINES) $(filter -ffile-prefix-map=%,$(CFLAGS)) \
-I$(HEADER_DIR) \
$(subst -I,-isystem ,$(filter-out -I$(HEADER_DIR) -I$(LIB_DIR)/util,$(filter -I%,$(CFLAGS))))
Comment thread
tohojo marked this conversation as resolved.
Resolved
ifeq ($(BPF_SKIP_STD_INCLUDE),1)
BPF_CFLAGS += -nostdlibinc
endif

CONFIGMK := $(LIB_DIR)/../config.mk
LIBMK := Makefile $(CONFIGMK) $(LIB_DIR)/defines.mk $(LIB_DIR)/common.mk $(LIB_DIR)/../version.mk
4 changes: 2 additions & 2 deletions lib/libxdp/tests/test-libxdp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_link_so()
{
[ -n "${CC:-}" ] || return $SKIPPED_TEST

TMPDIR=$(mktemp --tmpdir -d libxdp-test.XXXXXX)
TMPDIR=$(mktemp -d -t libxdp-test.XXXXXX)
cat >$TMPDIR/libxdptest.c <<EOF
#include <xdp/libxdp.h>
int main(int argc, char **argv) {
Expand All @@ -34,7 +34,7 @@ test_link_a()
{
[ -n "${CC:-}" ] || return $SKIPPED_TEST

TMPDIR=$(mktemp --tmpdir -d libxdp-test.XXXXXX)
TMPDIR=$(mktemp -d -t libxdp-test.XXXXXX)
cat >$TMPDIR/libxdptest.c <<EOF
#include <xdp/libxdp.h>
int main(int argc, char **argv) {
Expand Down
4 changes: 2 additions & 2 deletions lib/testing/test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ kill_process_group()

kill -SIGINT -$PID
for i in $(seq 10); do
ps --ppid $PID -p $PID > /dev/null || return 0
kill -0 -$PID 2>/dev/null || return 0
sleep 0.1
done
kill -TERM -$PID
Expand Down Expand Up @@ -293,7 +293,7 @@ check_prereq()
die "This script needs root permissions to run."
fi

STATEDIR="$(mktemp -d --tmpdir=${TMPDIR:-/tmp} --suffix=.xdptest)"
STATEDIR="$(mktemp -d -t xdptest.XXXXXX)"
if [ $? -ne 0 ]; then
die "Unable to create state dir in $TMPDIR"
fi
Expand Down
15 changes: 8 additions & 7 deletions xdp-dump/tests/test-xdpdump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ test_capt_pcap()
skip_if_missing_kernel_symbol bpf_xdp_output_proto
skip_if_missing_trace_attach

local PASS_PKT="IP6 $INSIDE_IP6 > $OUTSIDE_IP6: ICMP6, echo reply(, id [0-9]+)?, seq 1, length 64"
local PASS_PKT="IP6 $INSIDE_IP6 > $OUTSIDE_IP6: ICMP6, echo reply(, id [0-9]+)?, seq [0-9]+, length 64"

$PING6 -W 2 -c 1 "$INSIDE_IP6" || return 1
$XDP_LOADER load "$NS" "$TEST_PROG_DIR/test_long_func_name.o" || return 1
Expand All @@ -125,7 +125,7 @@ test_capt_pcap()

version_greater_or_equal()
{
printf '%s\n%s\n' "$2" "$1" | sort -V -C
printf '%s\n%s\n' "$2" "$1" | sort -V -c 2>/dev/null
}

test_capt_pcapng()
Expand All @@ -134,7 +134,7 @@ test_capt_pcapng()
skip_if_missing_trace_attach

local PCAP_FILE="/tmp/${NS}_PID_$$_$RANDOM.pcap"
local PASS_PKT="IP6 $INSIDE_IP6 > $OUTSIDE_IP6: ICMP6, echo reply(, id [0-9]+)?, seq 1, length 64"
local PASS_PKT="IP6 $INSIDE_IP6 > $OUTSIDE_IP6: ICMP6, echo reply(, id [0-9]+)?, seq [0-9]+, length 64"
local HW=$(uname -m | sed -e 's/[]\/$*+.^|[]/\\&/g')
local OS=$(uname -snrv | sed -e 's/[]\/$+*.^()|[]/\\&/g')
local INFOS_REGEX=""
Expand Down Expand Up @@ -281,15 +281,15 @@ test_exitentry()
$XDP_LOADER load "$NS" "$TEST_PROG_DIR/xdp_drop.o" || return 1

PID=$(start_tcpdump "$XDPDUMP -i $NS --rx-capture=exit")
$PING6 -W 0.1 -c 1 "$INSIDE_IP6" # Note that this ping will fail!!
timeout 0.3 $PING6 -c 1 "$INSIDE_IP6" # Note that this ping will fail!!
RESULT=$(stop_background "$PID")
if ! [[ $RESULT =~ $PASS_EXIT_D_REGEX ]]; then
print_result "IPv6 drop exit packet not received"
return 1
fi

PID=$(start_tcpdump "$XDPDUMP -i $NS --rx-capture=exit,entry")
$PING6 -W 0.1 -c 1 "$INSIDE_IP6" # Note that this ping will fail!!
timeout 0.3 $PING6 -c 1 "$INSIDE_IP6" # Note that this ping will fail!!
RESULT=$(stop_background "$PID")
if ! [[ $RESULT =~ $PASS_EXIT_D_REGEX && $RESULT =~ $PASS_ENTRY_D_REGEX ]]; then
print_result "IPv6 drop entry/exit packet not received"
Expand Down Expand Up @@ -353,7 +353,8 @@ test_multi_pkt()
for PKT_SIZE in "${PKT_SIZES[@]}" ; do

PID=$(start_tcpdump "$XDPDUMP -i $NS -p xdp_test_prog_with_a_long_name --rx-capture=entry,exit")
timeout 40 $PING6 -q -W 0.1 -s "$PKT_SIZE" -c 20000 -f "$INSIDE_IP6" || return 1
timeout 0.3 $PING6 -q -s "$PKT_SIZE" -c 1 "$INSIDE_IP6" || return 1
timeout 40 $PING6 -q -W 1 -s "$PKT_SIZE" -c 20000 -A "$INSIDE_IP6" || return 1
RESULT=$(stop_background "$PID")
if ! [[ $RESULT =~ $PASS_ENTRY_REGEX ]]; then
print_result "IPv6 entry packet not received, $PKT_SIZE"
Expand Down Expand Up @@ -400,7 +401,7 @@ test_perf_wakeup()

# We sent 10k packets and see if the all arrive
PID=$(start_tcpdump "$XDPDUMP -i $NS -p xdp_test_prog_with_a_long_name --perf-wakeup=$WAKEUP")
timeout 20 "$PING6" -q -W 2 -c 10000 -f "$INSIDE_IP6" || return 1
timeout 20 "$PING6" -q -W 2 -c 10000 -A "$INSIDE_IP6" || return 1
RESULT=$(stop_background "$PID")
if ! [[ $RESULT =~ $PASS_10K_REGEX ]]; then
print_result "IPv6 10k packet not received for wakeup $WAKEUP"
Expand Down
4 changes: 2 additions & 2 deletions xdp-filter/tests/test-xdp-filter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ test_ports_deny()

check_ping6()
{
check_packet "dst $OUTSIDE_IP6" "$PING6 -W 0.1 -c 1 $OUTSIDE_IP6" $1
check_packet "dst $OUTSIDE_IP6" "timeout 0.3 $PING6 -c 1 $OUTSIDE_IP6" $1
}

check_ndisc6()
Expand Down Expand Up @@ -175,7 +175,7 @@ test_ipv6_deny()

check_ping4()
{
check_packet "dst $OUTSIDE_IP4" "ping -W 0.1 -c 1 $OUTSIDE_IP4" $1
check_packet "dst $OUTSIDE_IP4" "timeout 0.3 ping -c 1 $OUTSIDE_IP4" $1
}

check_arp()
Expand Down
Loading