Merge branch 'bpf-sockmap-selftests'
John Fastabend says: ==================== This series moves ./samples/sockmap into BPF selftests. There are a few good reasons to do this. First, by pushing this into selftests the tests will be run automatically. Second, sockmap was not really a sample of anything anymore, but rather a large set of tests. Note: There are three recent fixes outstanding against bpf branch that can be detected occasionally by the automated tests here. https://patchwork.ozlabs.org/patch/903138/ https://patchwork.ozlabs.org/patch/903139/ https://patchwork.ozlabs.org/patch/903140/ ==================== Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
Коммит
bf91a76b8f
|
@ -1,75 +0,0 @@
|
|||
# List of programs to build
|
||||
hostprogs-y := sockmap
|
||||
|
||||
# Libbpf dependencies
|
||||
LIBBPF := ../../tools/lib/bpf/bpf.o ../../tools/lib/bpf/nlattr.o
|
||||
|
||||
HOSTCFLAGS += -I$(objtree)/usr/include
|
||||
HOSTCFLAGS += -I$(srctree)/tools/lib/
|
||||
HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
|
||||
HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
|
||||
HOSTCFLAGS += -I$(srctree)/tools/perf
|
||||
|
||||
sockmap-objs := ../bpf/bpf_load.o $(LIBBPF) sockmap_user.o
|
||||
|
||||
# Tell kbuild to always build the programs
|
||||
always := $(hostprogs-y)
|
||||
always += sockmap_kern.o
|
||||
|
||||
HOSTLOADLIBES_sockmap += -lelf -lpthread
|
||||
|
||||
# Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
|
||||
# make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
|
||||
LLC ?= llc
|
||||
CLANG ?= clang
|
||||
|
||||
# Trick to allow make to be run from this directory
|
||||
all:
|
||||
$(MAKE) -C ../../ $(CURDIR)/
|
||||
|
||||
clean:
|
||||
$(MAKE) -C ../../ M=$(CURDIR) clean
|
||||
@rm -f *~
|
||||
|
||||
$(obj)/syscall_nrs.s: $(src)/syscall_nrs.c
|
||||
$(call if_changed_dep,cc_s_c)
|
||||
|
||||
$(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE
|
||||
$(call filechk,offsets,__SYSCALL_NRS_H__)
|
||||
|
||||
clean-files += syscall_nrs.h
|
||||
|
||||
FORCE:
|
||||
|
||||
|
||||
# Verify LLVM compiler tools are available and bpf target is supported by llc
|
||||
.PHONY: verify_cmds verify_target_bpf $(CLANG) $(LLC)
|
||||
|
||||
verify_cmds: $(CLANG) $(LLC)
|
||||
@for TOOL in $^ ; do \
|
||||
if ! (which -- "$${TOOL}" > /dev/null 2>&1); then \
|
||||
echo "*** ERROR: Cannot find LLVM tool $${TOOL}" ;\
|
||||
exit 1; \
|
||||
else true; fi; \
|
||||
done
|
||||
|
||||
verify_target_bpf: verify_cmds
|
||||
@if ! (${LLC} -march=bpf -mattr=help > /dev/null 2>&1); then \
|
||||
echo "*** ERROR: LLVM (${LLC}) does not support 'bpf' target" ;\
|
||||
echo " NOTICE: LLVM version >= 3.7.1 required" ;\
|
||||
exit 2; \
|
||||
else true; fi
|
||||
|
||||
$(src)/*.c: verify_target_bpf
|
||||
|
||||
# asm/sysreg.h - inline assembly used by it is incompatible with llvm.
|
||||
# But, there is no easy way to fix it, so just exclude it since it is
|
||||
# useless for BPF samples.
|
||||
$(obj)/%.o: $(src)/%.c
|
||||
$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \
|
||||
-D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
|
||||
-Wno-compare-distinct-pointer-types \
|
||||
-Wno-gnu-variable-sized-type-not-at-end \
|
||||
-Wno-address-of-packed-member -Wno-tautological-compare \
|
||||
-Wno-unknown-warning-option \
|
||||
-O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
|
|
@ -1,488 +0,0 @@
|
|||
#Test a bunch of positive cases to verify basic functionality
|
||||
for prog in "--txmsg_redir --txmsg_skb" "--txmsg_redir --txmsg_ingress" "--txmsg" "--txmsg_redir" "--txmsg_redir --txmsg_ingress" "--txmsg_drop"; do
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
for r in 1 10 100; do
|
||||
for i in 1 10 100; do
|
||||
for l in 1 10 100; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
#Test max iov
|
||||
t="sendmsg"
|
||||
r=1
|
||||
i=1024
|
||||
l=1
|
||||
prog="--txmsg"
|
||||
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
prog="--txmsg_redir"
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
|
||||
# Test max iov with 1k send
|
||||
|
||||
t="sendmsg"
|
||||
r=1
|
||||
i=1024
|
||||
l=1024
|
||||
prog="--txmsg"
|
||||
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
prog="--txmsg_redir"
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
|
||||
# Test apply with 1B
|
||||
r=1
|
||||
i=1024
|
||||
l=1024
|
||||
prog="--txmsg_apply 1"
|
||||
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test apply with larger value than send
|
||||
r=1
|
||||
i=8
|
||||
l=1024
|
||||
prog="--txmsg_apply 2048"
|
||||
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test apply with apply that never reaches limit
|
||||
r=1024
|
||||
i=1
|
||||
l=1
|
||||
prog="--txmsg_apply 2048"
|
||||
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test apply and redirect with 1B
|
||||
r=1
|
||||
i=1024
|
||||
l=1024
|
||||
prog="--txmsg_redir --txmsg_apply 1"
|
||||
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
prog="--txmsg_redir --txmsg_apply 1 --txmsg_ingress"
|
||||
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
prog="--txmsg_redir --txmsg_apply 1 --txmsg_skb"
|
||||
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
|
||||
# Test apply and redirect with larger value than send
|
||||
r=1
|
||||
i=8
|
||||
l=1024
|
||||
prog="--txmsg_redir --txmsg_apply 2048"
|
||||
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
prog="--txmsg_redir --txmsg_apply 2048 --txmsg_ingress"
|
||||
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
prog="--txmsg_redir --txmsg_apply 2048 --txmsg_skb"
|
||||
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
|
||||
# Test apply and redirect with apply that never reaches limit
|
||||
r=1024
|
||||
i=1
|
||||
l=1
|
||||
prog="--txmsg_apply 2048"
|
||||
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test cork with 1B not really useful but test it anyways
|
||||
r=1
|
||||
i=1024
|
||||
l=1024
|
||||
prog="--txmsg_cork 1"
|
||||
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test cork with a more reasonable 100B
|
||||
r=1
|
||||
i=1000
|
||||
l=1000
|
||||
prog="--txmsg_cork 100"
|
||||
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test cork with larger value than send
|
||||
r=1
|
||||
i=8
|
||||
l=1024
|
||||
prog="--txmsg_cork 2048"
|
||||
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test cork with cork that never reaches limit
|
||||
r=1024
|
||||
i=1
|
||||
l=1
|
||||
prog="--txmsg_cork 2048"
|
||||
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
r=1
|
||||
i=1024
|
||||
l=1024
|
||||
prog="--txmsg_redir --txmsg_cork 1"
|
||||
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test cork with a more reasonable 100B
|
||||
r=1
|
||||
i=1000
|
||||
l=1000
|
||||
prog="--txmsg_redir --txmsg_cork 100"
|
||||
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test cork with larger value than send
|
||||
r=1
|
||||
i=8
|
||||
l=1024
|
||||
prog="--txmsg_redir --txmsg_cork 2048"
|
||||
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test cork with cork that never reaches limit
|
||||
r=1024
|
||||
i=1
|
||||
l=1
|
||||
prog="--txmsg_cork 2048"
|
||||
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
|
||||
# mix and match cork and apply not really useful but valid programs
|
||||
|
||||
# Test apply < cork
|
||||
r=100
|
||||
i=1
|
||||
l=5
|
||||
prog="--txmsg_apply 10 --txmsg_cork 100"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Try again with larger sizes so we hit overflow case
|
||||
r=100
|
||||
i=1000
|
||||
l=2048
|
||||
prog="--txmsg_apply 4096 --txmsg_cork 8096"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test apply > cork
|
||||
r=100
|
||||
i=1
|
||||
l=5
|
||||
prog="--txmsg_apply 100 --txmsg_cork 10"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Again with larger sizes so we hit overflow cases
|
||||
r=100
|
||||
i=1000
|
||||
l=2048
|
||||
prog="--txmsg_apply 8096 --txmsg_cork 4096"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
|
||||
# Test apply = cork
|
||||
r=100
|
||||
i=1
|
||||
l=5
|
||||
prog="--txmsg_apply 10 --txmsg_cork 10"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
r=100
|
||||
i=1000
|
||||
l=2048
|
||||
prog="--txmsg_apply 4096 --txmsg_cork 4096"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test apply < cork
|
||||
r=100
|
||||
i=1
|
||||
l=5
|
||||
prog="--txmsg_redir --txmsg_apply 10 --txmsg_cork 100"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Try again with larger sizes so we hit overflow case
|
||||
r=100
|
||||
i=1000
|
||||
l=2048
|
||||
prog="--txmsg_redir --txmsg_apply 4096 --txmsg_cork 8096"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Test apply > cork
|
||||
r=100
|
||||
i=1
|
||||
l=5
|
||||
prog="--txmsg_redir --txmsg_apply 100 --txmsg_cork 10"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Again with larger sizes so we hit overflow cases
|
||||
r=100
|
||||
i=1000
|
||||
l=2048
|
||||
prog="--txmsg_redir --txmsg_apply 8096 --txmsg_cork 4096"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
|
||||
# Test apply = cork
|
||||
r=100
|
||||
i=1
|
||||
l=5
|
||||
prog="--txmsg_redir --txmsg_apply 10 --txmsg_cork 10"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
r=100
|
||||
i=1000
|
||||
l=2048
|
||||
prog="--txmsg_redir --txmsg_apply 4096 --txmsg_cork 4096"
|
||||
for t in "sendpage" "sendmsg"; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Tests for bpf_msg_pull_data()
|
||||
for i in `seq 99 100 1600`; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t sendpage -r 16 -i 1 -l 100 \
|
||||
--txmsg --txmsg_start 0 --txmsg_end $i --txmsg_cork 1600"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
for i in `seq 199 100 1600`; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t sendpage -r 16 -i 1 -l 100 \
|
||||
--txmsg --txmsg_start 100 --txmsg_end $i --txmsg_cork 1600"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t sendpage -r 16 -i 1 -l 100 \
|
||||
--txmsg --txmsg_start 1500 --txmsg_end 1600 --txmsg_cork 1600"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t sendpage -r 16 -i 1 -l 100 \
|
||||
--txmsg --txmsg_start 1111 --txmsg_end 1112 --txmsg_cork 1600"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t sendpage -r 16 -i 1 -l 100 \
|
||||
--txmsg --txmsg_start 1111 --txmsg_end 0 --txmsg_cork 1600"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t sendpage -r 16 -i 1 -l 100 \
|
||||
--txmsg --txmsg_start 0 --txmsg_end 1601 --txmsg_cork 1600"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t sendpage -r 16 -i 1 -l 100 \
|
||||
--txmsg --txmsg_start 0 --txmsg_end 1601 --txmsg_cork 1602"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
|
||||
# Run through gamut again with start and end
|
||||
for prog in "--txmsg" "--txmsg_redir" "--txmsg_drop"; do
|
||||
for t in "sendmsg" "sendpage"; do
|
||||
for r in 1 10 100; do
|
||||
for i in 1 10 100; do
|
||||
for l in 1 10 100; do
|
||||
TEST="./sockmap --cgroup /mnt/cgroup2/ -t $t -r $r -i $i -l $l $prog --txmsg_start 1 --txmsg_end 2"
|
||||
echo $TEST
|
||||
$TEST
|
||||
sleep 2
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
# Some specific tests to cover specific code paths
|
||||
./sockmap --cgroup /mnt/cgroup2/ -t sendpage \
|
||||
-r 5 -i 1 -l 1 --txmsg_redir --txmsg_cork 5 --txmsg_apply 3
|
||||
./sockmap --cgroup /mnt/cgroup2/ -t sendmsg \
|
||||
-r 5 -i 1 -l 1 --txmsg_redir --txmsg_cork 5 --txmsg_apply 3
|
||||
./sockmap --cgroup /mnt/cgroup2/ -t sendpage \
|
||||
-r 5 -i 1 -l 1 --txmsg_redir --txmsg_cork 5 --txmsg_apply 5
|
||||
./sockmap --cgroup /mnt/cgroup2/ -t sendmsg \
|
||||
-r 5 -i 1 -l 1 --txmsg_redir --txmsg_cork 5 --txmsg_apply 5
|
|
@ -894,6 +894,7 @@ enum bpf_func_id {
|
|||
/* BPF_FUNC_skb_set_tunnel_key flags. */
|
||||
#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
|
||||
#define BPF_F_DONT_FRAGMENT (1ULL << 2)
|
||||
#define BPF_F_SEQ_NUMBER (1ULL << 3)
|
||||
|
||||
/* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and
|
||||
* BPF_FUNC_perf_event_read_value flags.
|
||||
|
|
|
@ -941,4 +941,43 @@ enum {
|
|||
IFLA_EVENT_BONDING_OPTIONS, /* change in bonding options */
|
||||
};
|
||||
|
||||
/* tun section */
|
||||
|
||||
enum {
|
||||
IFLA_TUN_UNSPEC,
|
||||
IFLA_TUN_OWNER,
|
||||
IFLA_TUN_GROUP,
|
||||
IFLA_TUN_TYPE,
|
||||
IFLA_TUN_PI,
|
||||
IFLA_TUN_VNET_HDR,
|
||||
IFLA_TUN_PERSIST,
|
||||
IFLA_TUN_MULTI_QUEUE,
|
||||
IFLA_TUN_NUM_QUEUES,
|
||||
IFLA_TUN_NUM_DISABLED_QUEUES,
|
||||
__IFLA_TUN_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_TUN_MAX (__IFLA_TUN_MAX - 1)
|
||||
|
||||
/* rmnet section */
|
||||
|
||||
#define RMNET_FLAGS_INGRESS_DEAGGREGATION (1U << 0)
|
||||
#define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1)
|
||||
#define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2)
|
||||
#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3)
|
||||
|
||||
enum {
|
||||
IFLA_RMNET_UNSPEC,
|
||||
IFLA_RMNET_MUX_ID,
|
||||
IFLA_RMNET_FLAGS,
|
||||
__IFLA_RMNET_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_RMNET_MAX (__IFLA_RMNET_MAX - 1)
|
||||
|
||||
struct ifla_rmnet_flags {
|
||||
__u32 flags;
|
||||
__u32 mask;
|
||||
};
|
||||
|
||||
#endif /* _UAPI_LINUX_IF_LINK_H */
|
||||
|
|
|
@ -1961,8 +1961,8 @@ BPF_PROG_TYPE_FNS(raw_tracepoint, BPF_PROG_TYPE_RAW_TRACEPOINT);
|
|||
BPF_PROG_TYPE_FNS(xdp, BPF_PROG_TYPE_XDP);
|
||||
BPF_PROG_TYPE_FNS(perf_event, BPF_PROG_TYPE_PERF_EVENT);
|
||||
|
||||
static void bpf_program__set_expected_attach_type(struct bpf_program *prog,
|
||||
enum bpf_attach_type type)
|
||||
void bpf_program__set_expected_attach_type(struct bpf_program *prog,
|
||||
enum bpf_attach_type type)
|
||||
{
|
||||
prog->expected_attach_type = type;
|
||||
}
|
||||
|
|
|
@ -193,6 +193,8 @@ int bpf_program__set_sched_act(struct bpf_program *prog);
|
|||
int bpf_program__set_xdp(struct bpf_program *prog);
|
||||
int bpf_program__set_perf_event(struct bpf_program *prog);
|
||||
void bpf_program__set_type(struct bpf_program *prog, enum bpf_prog_type type);
|
||||
void bpf_program__set_expected_attach_type(struct bpf_program *prog,
|
||||
enum bpf_attach_type type);
|
||||
|
||||
bool bpf_program__is_socket_filter(struct bpf_program *prog);
|
||||
bool bpf_program__is_tracepoint(struct bpf_program *prog);
|
||||
|
|
|
@ -24,7 +24,7 @@ urandom_read: urandom_read.c
|
|||
# Order correspond to 'make run_tests' order
|
||||
TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
|
||||
test_align test_verifier_log test_dev_cgroup test_tcpbpf_user \
|
||||
test_sock test_btf
|
||||
test_sock test_btf test_sockmap
|
||||
|
||||
TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o test_obj_id.o \
|
||||
test_pkt_md_access.o test_xdp_redirect.o test_xdp_meta.o sockmap_parse_prog.o \
|
||||
|
@ -32,7 +32,7 @@ TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o test
|
|||
test_l4lb_noinline.o test_xdp_noinline.o test_stacktrace_map.o \
|
||||
sample_map_ret0.o test_tcpbpf_kern.o test_stacktrace_build_id.o \
|
||||
sockmap_tcp_msg_prog.o connect4_prog.o connect6_prog.o test_adjust_tail.o \
|
||||
test_btf_haskv.o test_btf_nokv.o
|
||||
test_btf_haskv.o test_btf_nokv.o test_sockmap_kern.o
|
||||
|
||||
# Order correspond to 'make run_tests' order
|
||||
TEST_PROGS := test_kmod.sh \
|
||||
|
@ -56,6 +56,7 @@ $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/libbpf.a
|
|||
$(OUTPUT)/test_dev_cgroup: cgroup_helpers.c
|
||||
$(OUTPUT)/test_sock: cgroup_helpers.c
|
||||
$(OUTPUT)/test_sock_addr: cgroup_helpers.c
|
||||
$(OUTPUT)/test_sockmap: cgroup_helpers.c
|
||||
|
||||
.PHONY: force
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,20 +1,19 @@
|
|||
/* Copyright (c) 2017 Covalent IO, Inc. http://covalent.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of version 2 of the GNU General Public
|
||||
* License as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*/
|
||||
#include <uapi/linux/bpf.h>
|
||||
#include <uapi/linux/if_ether.h>
|
||||
#include <uapi/linux/if_packet.h>
|
||||
#include <uapi/linux/ip.h>
|
||||
#include "../../tools/testing/selftests/bpf/bpf_helpers.h"
|
||||
#include "../../tools/testing/selftests/bpf/bpf_endian.h"
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2017-2018 Covalent IO, Inc. http://covalent.io
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <linux/bpf.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/if_packet.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/in.h>
|
||||
#include <linux/udp.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/pkt_cls.h>
|
||||
#include <sys/socket.h>
|
||||
#include "bpf_helpers.h"
|
||||
#include "bpf_endian.h"
|
||||
|
||||
/* Sockmap sample program connects a client and a backend together
|
||||
* using cgroups.
|
||||
|
@ -337,5 +336,5 @@ int bpf_prog10(struct sk_msg_md *msg)
|
|||
return SK_DROP;
|
||||
}
|
||||
|
||||
|
||||
int _version SEC("version") = 1;
|
||||
char _license[] SEC("license") = "GPL";
|
Загрузка…
Ссылка в новой задаче