blob: 1d328539442f2facf828730489708308ed150c51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
XDP_LOADER=${XDP_LOADER:-./xdp-loader}
ALL_TESTS="test_load test_section test_prog_name test_load_multi test_load_incremental test_load_clobber"
test_load()
{
check_run $XDP_LOADER load $NS $TEST_PROG_DIR/xdp_drop.o -vv
check_run $XDP_LOADER unload $NS --all -vv
}
test_section()
{
check_run $XDP_LOADER load $NS $TEST_PROG_DIR/xdp_drop.o -s xdp -vv
check_run $XDP_LOADER unload $NS --all -vv
}
test_prog_name()
{
check_run $XDP_LOADER load $NS $TEST_PROG_DIR/xdp_drop.o -n xdp_drop -vv
check_run $XDP_LOADER unload $NS --all -vv
}
check_progs_loaded()
{
local iface="$1"
local num=$2
local num_loaded
num_loaded=$($XDP_LOADER status $NS | grep -c '=>')
if [ "$num_loaded" -ne "$num" ]; then
echo "Expected $num programs loaded, found $num_loaded"
exit 1
fi
}
test_load_multi()
{
skip_if_legacy_fallback
check_run $XDP_LOADER load $NS $TEST_PROG_DIR/xdp_drop.o $TEST_PROG_DIR/xdp_pass.o -vv
check_progs_loaded $NS 2
check_run $XDP_LOADER unload $NS --all -vv
}
test_load_incremental()
{
skip_if_legacy_fallback
local output
local ret
local id
check_run $XDP_LOADER load $NS $TEST_PROG_DIR/xdp_drop.o -vv
check_progs_loaded $NS 1
output=$($XDP_LOADER load $NS $TEST_PROG_DIR/xdp_pass.o -vv 2>&1)
ret=$?
if [ "$ret" -ne "0" ] && echo $output | grep -q "Falling back to loading single prog"; then
ret=$SKIPPED_TEST
check_run $XDP_LOADER unload $NS --all -vv
else
check_progs_loaded $NS 2
id=$($XDP_LOADER status $NS | grep xdp_pass | awk '{print $4}')
check_run $XDP_LOADER unload $NS --id $id
check_progs_loaded $NS 1
id=$($XDP_LOADER status $NS | grep xdp_drop | awk '{print $4}')
check_run $XDP_LOADER unload $NS --id $id
check_progs_loaded $NS 0
fi
return $ret
}
test_load_clobber()
{
skip_if_legacy_fallback
check_run env LIBXDP_SKIP_DISPATCHER=1 $XDP_LOADER load $NS $TEST_PROG_DIR/xdp_drop.o -vv
check_progs_loaded $NS 0 # legacy prog so should show up as 0
$XDP_LOADER load $NS $TEST_PROG_DIR/xdp_pass.o -vv
ret=$?
if [ "$ret" -eq "0" ]; then
echo "Should not have been able to load prog with legacy prog loaded"
return 1
fi
check_progs_loaded $NS 0
check_run $XDP_LOADER unload $NS --all -vv
}
cleanup_tests()
{
$XDP_LOADER unload $NS --all >/dev/null 2>&1
}
|