Re: [PATCH bpf-next 3/4] selftests/bpf: restructure xsk selftests
From: Björn Töpel <hidden>
Date: 2021-02-18 10:55:51
Also in:
bpf
On Wed, 17 Feb 2021 at 17:33, Ciara Loftus [off-list ref] wrote:
Prior to this commit individual xsk tests were launched from the shell script 'test_xsk.sh'. When adding a new test type, two new test configurations had to be added to this file - one for each of the supported XDP 'modes' (skb or drv). Should zero copy support be added to the xsk selftest framework in the future, three new test configurations would need to be added for each new test type. Each new test type also typically requires new CLI arguments for the xdpxceiver program. This commit aims to reduce the overhead of adding new tests, by launching the test configurations from within the xdpxceiver program itself, using simple loops. Every test is run every time the C program is executed. Many of the CLI arguments can be removed as a result. Signed-off-by: Ciara Loftus <redacted> --- tools/testing/selftests/bpf/test_xsk.sh | 112 +----------- tools/testing/selftests/bpf/xdpxceiver.c | 199 ++++++++++++--------- tools/testing/selftests/bpf/xdpxceiver.h | 27 ++- tools/testing/selftests/bpf/xsk_prereqs.sh | 24 +-- 4 files changed, 139 insertions(+), 223 deletions(-)
I like where this is going! Nice! [...]
quoted hunk ↗ jump to hunk
diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c index 8af746c9a6b6..7cb4a13597d0 100644 --- a/tools/testing/selftests/bpf/xdpxceiver.c +++ b/tools/testing/selftests/bpf/xdpxceiver.c
[...]
+static int configure_skb(void)
+{
+
+ char cmd[80];
+
+ snprintf(cmd, sizeof(cmd), "ip link set dev %s xdpdrv off", ifdict[0]->ifname);
+ if (system(cmd)) {
+ ksft_test_result_fail("Failed to configure native mode on iface %s\n",
+ ifdict[0]->ifname);
+ return -1;
+ }
+ snprintf(cmd, sizeof(cmd), "ip netns exec %s ip link set dev %s xdpdrv off",
+ ifdict[1]->nsname, ifdict[1]->ifname);
+ if (system(cmd)) {
+ ksft_test_result_fail("Failed to configure native mode on iface/ns %s\n",
+ ifdict[1]->ifname, ifdict[1]->nsname);
+ return -1;
+ }
+
+ cur_mode = TEST_MODE_SKB;
+
+ return 0;
+
+}
+
+static int configure_drv(void)
+{
+ char cmd[80];
+
+ snprintf(cmd, sizeof(cmd), "ip link set dev %s xdpgeneric off", ifdict[0]->ifname);
+ if (system(cmd)) {
+ ksft_test_result_fail("Failed to configure native mode on iface %s\n",
+ ifdict[0]->ifname);
+ return -1;
+ }
+ snprintf(cmd, sizeof(cmd), "ip netns exec %s ip link set dev %s xdpgeneric off",
+ ifdict[1]->nsname, ifdict[1]->ifname);
+ if (system(cmd)) {
+ ksft_test_result_fail("Failed to configure native mode on iface/ns %s\n",
+ ifdict[1]->ifname, ifdict[1]->nsname);
+ return -1;
+ }
+
+ cur_mode = TEST_MODE_DRV;
+
+ return 0;
+}
+We're already using libbpf, so please use the libbpf APIs instead of calling iproute2. Björn [...]