Skip to content

Commit

Permalink
selftests: xsk: Add single packet test
Browse files Browse the repository at this point in the history
Add a test where a single packet is sent and received. This might
sound like a silly test, but since many of the interfaces in xsk are
batched, it is important to be able to validate that we did not break
something as fundamental as just receiving single packets, instead of
batches of packets at high speed.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210922075613.12186-12-magnus.karlsson@gmail.com
  • Loading branch information
Magnus Karlsson authored and Daniel Borkmann committed Sep 27, 2021
1 parent 1bf3649 commit 96a4067
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tools/testing/selftests/bpf/xdpxceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,15 @@ static bool testapp_unaligned(struct test_spec *test)
return true;
}

static void testapp_single_pkt(struct test_spec *test)
{
struct pkt pkts[] = {{0x1000, PKT_SIZE, 0, true}};

pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts));
testapp_validate_traffic(test);
pkt_stream_restore_default(test);
}

static void testapp_invalid_desc(struct test_spec *test)
{
struct pkt pkts[] = {
Expand Down Expand Up @@ -1298,6 +1307,10 @@ static void run_pkt_test(struct test_spec *test, enum test_mode mode, enum test_
test_spec_set_name(test, "RUN_TO_COMPLETION");
testapp_validate_traffic(test);
break;
case TEST_TYPE_RUN_TO_COMPLETION_SINGLE_PKT:
test_spec_set_name(test, "RUN_TO_COMPLETION_SINGLE_PKT");
testapp_single_pkt(test);
break;
case TEST_TYPE_RUN_TO_COMPLETION_2K_FRAME:
test_spec_set_name(test, "RUN_TO_COMPLETION_2K_FRAME_SIZE");
test->ifobj_tx->umem->frame_size = 2048;
Expand Down
1 change: 1 addition & 0 deletions tools/testing/selftests/bpf/xdpxceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum test_mode {
enum test_type {
TEST_TYPE_RUN_TO_COMPLETION,
TEST_TYPE_RUN_TO_COMPLETION_2K_FRAME,
TEST_TYPE_RUN_TO_COMPLETION_SINGLE_PKT,
TEST_TYPE_POLL,
TEST_TYPE_UNALIGNED,
TEST_TYPE_ALIGNED_INV_DESC,
Expand Down

0 comments on commit 96a4067

Please sign in to comment.