Skip to content

Commit cc76140

Browse files
tvyavahaKernel Patches Daemon
authored and
Kernel Patches Daemon
committed
selftests/xsk: Add packet resizing tests with bpf_xdp_adjust_tail for AF_XDP
Add packet resizing tests using the bpf_xdp_adjust_tail()function within the AF_XDP framework. Implement testapp_adjust_tail_common() to handle common logic for packet resizing tests, streamlining the testing process. Allow setting MTU to MAX_ETH_JUMBO_SIZE for specific tests. Implement testapp_adjust_tail_shrink() and testapp_adjust_tail_shrink_mb() to test shrinking packets, including multi-buffer scenarios, under AF_XDP. Implement testapp_adjust_tail_grow() and testapp_adjust_tail_grow_mb() to test growing packets within the AF_XDP context, utilizing the common logic function for consistency and efficiency. Signed-off-by: Tushar Vyavahare <[email protected]>
1 parent 7ec924e commit cc76140

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tools/testing/selftests/bpf/xskxceiver.c

+32
Original file line numberDiff line numberDiff line change
@@ -2600,6 +2600,34 @@ static int testapp_adjust_tail(struct test_spec *test, u32 value, u32 pkt_len)
26002600
return 0;
26012601
}
26022602

2603+
static int testapp_adjust_tail_common(struct test_spec *test, int adjust_value, u32 len,
2604+
bool set_mtu)
2605+
{
2606+
if (set_mtu)
2607+
test->mtu = MAX_ETH_JUMBO_SIZE;
2608+
return testapp_adjust_tail(test, adjust_value, len);
2609+
}
2610+
2611+
static int testapp_adjust_tail_shrink(struct test_spec *test)
2612+
{
2613+
return testapp_adjust_tail_common(test, -4, MIN_PKT_SIZE, false);
2614+
}
2615+
2616+
static int testapp_adjust_tail_shrink_mb(struct test_spec *test)
2617+
{
2618+
return testapp_adjust_tail_common(test, -4, XSK_RING_PROD__DEFAULT_NUM_DESCS * 3, true);
2619+
}
2620+
2621+
static int testapp_adjust_tail_grow(struct test_spec *test)
2622+
{
2623+
return testapp_adjust_tail_common(test, 4, MIN_PKT_SIZE, false);
2624+
}
2625+
2626+
static int testapp_adjust_tail_grow_mb(struct test_spec *test)
2627+
{
2628+
return testapp_adjust_tail_common(test, 4, XSK_RING_PROD__DEFAULT_NUM_DESCS * 3, true);
2629+
}
2630+
26032631
static void run_pkt_test(struct test_spec *test)
26042632
{
26052633
int ret;
@@ -2706,6 +2734,10 @@ static const struct test_spec tests[] = {
27062734
{.name = "TOO_MANY_FRAGS", .test_func = testapp_too_many_frags},
27072735
{.name = "HW_SW_MIN_RING_SIZE", .test_func = testapp_hw_sw_min_ring_size},
27082736
{.name = "HW_SW_MAX_RING_SIZE", .test_func = testapp_hw_sw_max_ring_size},
2737+
{.name = "XDP_ADJUST_TAIL_SHRINK", .test_func = testapp_adjust_tail_shrink},
2738+
{.name = "XDP_ADJUST_TAIL_SHRINK_MULTI_BUFF", .test_func = testapp_adjust_tail_shrink_mb},
2739+
{.name = "XDP_ADJUST_TAIL_GROW", .test_func = testapp_adjust_tail_grow},
2740+
{.name = "XDP_ADJUST_TAIL_GROW_MULTI_BUFF", .test_func = testapp_adjust_tail_grow_mb},
27092741
};
27102742

27112743
static void print_tests(void)

0 commit comments

Comments
 (0)