Skip to content

Commit 43c5026

Browse files
author
Alexei Starovoitov
committed
Merge branch 'selftests/bpf: xsk improvements and new stats'
Ciara Loftus says: ==================== This series attempts to improve the xsk selftest framework by: 1. making the default output less verbose 2. adding an optional verbose flag to both the test_xsk.sh script and xdpxceiver app. 3. renaming the debug option in the app to to 'dump-pkts' and add a flag to the test_xsk.sh script which enables the flag in the app. 4. changing how tests are launched - now they are launched from the xdpxceiver app instead of the script. Once the improvements are made, a new set of tests are added which test the xsk statistics. The output of the test script now looks like: ./test_xsk.sh PREREQUISITES: [ PASS ] 1..10 ok 1 PASS: SKB NOPOLL ok 2 PASS: SKB POLL ok 3 PASS: SKB NOPOLL Socket Teardown ok 4 PASS: SKB NOPOLL Bi-directional Sockets ok 5 PASS: SKB NOPOLL Stats ok 6 PASS: DRV NOPOLL ok 7 PASS: DRV POLL ok 8 PASS: DRV NOPOLL Socket Teardown ok 9 PASS: DRV NOPOLL Bi-directional Sockets ok 10 PASS: DRV NOPOLL Stats # Totals: pass:10 fail:0 xfail:0 xpass:0 skip:0 error:0 XSK KSELFTESTS: [ PASS ] v2->v3: * Rename dump-pkts to dump_pkts in test_xsk.sh * Add examples of flag usage to test_xsk.sh v1->v2: * Changed '-d' flag in the shell script to '-D' to be consistent with the xdpxceiver app. * Renamed debug mode to 'dump-pkts' which better reflects the behaviour. * Use libpf APIs instead of calls to ss for configuring xdp on the links * Remove mutex init & destroy for each stats test * Added a description for each of the new statistics tests * Distinguish between exiting due to initialisation failure vs test failure This series applies on commit d310ec0 Ciara Loftus (3): selftests/bpf: expose and rename debug argument selftests/bpf: restructure xsk selftests selftests/bpf: introduce xsk statistics tests ==================== Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2 parents e6ac593 + b267e5a commit 43c5026

4 files changed

Lines changed: 342 additions & 260 deletions

File tree

‎tools/testing/selftests/bpf/test_xsk.sh‎

Lines changed: 25 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,21 @@
7171
#
7272
# Run (full output without color-coding):
7373
# sudo ./test_xsk.sh
74+
#
75+
# Run with verbose output:
76+
# sudo ./test_xsk.sh -v
77+
#
78+
# Run and dump packet contents:
79+
# sudo ./test_xsk.sh -D
7480

7581
. xsk_prereqs.sh
7682

77-
while getopts c flag
83+
while getopts "cvD" flag
7884
do
7985
case "${flag}" in
8086
c) colorconsole=1;;
87+
v) verbose=1;;
88+
D) dump_pkts=1;;
8189
esac
8290
done
8391

@@ -95,13 +103,17 @@ NS1=af_xdp${VETH1_POSTFIX}
95103
MTU=1500
96104

97105
setup_vethPairs() {
98-
echo "setting up ${VETH0}: namespace: ${NS0}"
106+
if [[ $verbose -eq 1 ]]; then
107+
echo "setting up ${VETH0}: namespace: ${NS0}"
108+
fi
99109
ip netns add ${NS1}
100110
ip link add ${VETH0} type veth peer name ${VETH1}
101111
if [ -f /proc/net/if_inet6 ]; then
102112
echo 1 > /proc/sys/net/ipv6/conf/${VETH0}/disable_ipv6
103113
fi
104-
echo "setting up ${VETH1}: namespace: ${NS1}"
114+
if [[ $verbose -eq 1 ]]; then
115+
echo "setting up ${VETH1}: namespace: ${NS1}"
116+
fi
105117
ip link set ${VETH1} netns ${NS1}
106118
ip netns exec ${NS1} ip link set ${VETH1} mtu ${MTU}
107119
ip link set ${VETH0} mtu ${MTU}
@@ -125,121 +137,24 @@ echo "${VETH0}:${VETH1},${NS1}" > ${SPECFILE}
125137

126138
validate_veth_spec_file
127139

128-
echo "Spec file created: ${SPECFILE}"
129-
130-
test_status $retval "${TEST_NAME}"
131-
132-
## START TESTS
133-
134-
statusList=()
135-
136-
### TEST 1
137-
TEST_NAME="XSK KSELFTEST FRAMEWORK"
138-
139-
echo "Switching interfaces [${VETH0}, ${VETH1}] to XDP Generic mode"
140-
vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
141-
142-
retval=$?
143-
if [ $retval -eq 0 ]; then
144-
echo "Switching interfaces [${VETH0}, ${VETH1}] to XDP Native mode"
145-
vethXDPnative ${VETH0} ${VETH1} ${NS1}
140+
if [[ $verbose -eq 1 ]]; then
141+
echo "Spec file created: ${SPECFILE}"
142+
VERBOSE_ARG="-v"
146143
fi
147144

148-
retval=$?
149-
test_status $retval "${TEST_NAME}"
150-
statusList+=($retval)
151-
152-
### TEST 2
153-
TEST_NAME="SKB NOPOLL"
154-
155-
vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
156-
157-
params=("-S")
158-
execxdpxceiver params
159-
160-
retval=$?
161-
test_status $retval "${TEST_NAME}"
162-
statusList+=($retval)
163-
164-
### TEST 3
165-
TEST_NAME="SKB POLL"
166-
167-
vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
168-
169-
params=("-S" "-p")
170-
execxdpxceiver params
171-
172-
retval=$?
173-
test_status $retval "${TEST_NAME}"
174-
statusList+=($retval)
175-
176-
### TEST 4
177-
TEST_NAME="DRV NOPOLL"
178-
179-
vethXDPnative ${VETH0} ${VETH1} ${NS1}
180-
181-
params=("-N")
182-
execxdpxceiver params
183-
184-
retval=$?
185-
test_status $retval "${TEST_NAME}"
186-
statusList+=($retval)
187-
188-
### TEST 5
189-
TEST_NAME="DRV POLL"
190-
191-
vethXDPnative ${VETH0} ${VETH1} ${NS1}
192-
193-
params=("-N" "-p")
194-
execxdpxceiver params
195-
196-
retval=$?
197-
test_status $retval "${TEST_NAME}"
198-
statusList+=($retval)
199-
200-
### TEST 6
201-
TEST_NAME="SKB SOCKET TEARDOWN"
202-
203-
vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
204-
205-
params=("-S" "-T")
206-
execxdpxceiver params
207-
208-
retval=$?
209-
test_status $retval "${TEST_NAME}"
210-
statusList+=($retval)
211-
212-
### TEST 7
213-
TEST_NAME="DRV SOCKET TEARDOWN"
214-
215-
vethXDPnative ${VETH0} ${VETH1} ${NS1}
216-
217-
params=("-N" "-T")
218-
execxdpxceiver params
145+
if [[ $dump_pkts -eq 1 ]]; then
146+
DUMP_PKTS_ARG="-D"
147+
fi
219148

220-
retval=$?
221149
test_status $retval "${TEST_NAME}"
222-
statusList+=($retval)
223150

224-
### TEST 8
225-
TEST_NAME="SKB BIDIRECTIONAL SOCKETS"
226-
227-
vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
228-
229-
params=("-S" "-B")
230-
execxdpxceiver params
231-
232-
retval=$?
233-
test_status $retval "${TEST_NAME}"
234-
statusList+=($retval)
151+
## START TESTS
235152

236-
### TEST 9
237-
TEST_NAME="DRV BIDIRECTIONAL SOCKETS"
153+
statusList=()
238154

239-
vethXDPnative ${VETH0} ${VETH1} ${NS1}
155+
TEST_NAME="XSK KSELFTESTS"
240156

241-
params=("-N" "-B")
242-
execxdpxceiver params
157+
execxdpxceiver
243158

244159
retval=$?
245160
test_status $retval "${TEST_NAME}"

0 commit comments

Comments
 (0)