Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/xsk: Read current MAX_SKB_FRAGS from sysctl knob

Currently, xskxceiver assumes that MAX_SKB_FRAGS value is always 17
which is not true - since the introduction of BIG TCP this can now take
any value between 17 to 45 via CONFIG_MAX_SKB_FRAGS.

Adjust the TOO_MANY_FRAGS test case to read the currently configured
MAX_SKB_FRAGS value by reading it from /proc/sys/net/core/max_skb_frags.
If running system does not provide that sysctl file then let us try
running the test with a default value.

Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20240910124129.289874-1-maciej.fijalkowski@intel.com

authored by

Maciej Fijalkowski and committed by
Daniel Borkmann
d41905b3 6b083650

+38 -6
+38 -5
tools/testing/selftests/bpf/xskxceiver.c
··· 324 324 return zc_avail; 325 325 } 326 326 327 + #define MAX_SKB_FRAGS_PATH "/proc/sys/net/core/max_skb_frags" 328 + static unsigned int get_max_skb_frags(void) 329 + { 330 + unsigned int max_skb_frags = 0; 331 + FILE *file; 332 + 333 + file = fopen(MAX_SKB_FRAGS_PATH, "r"); 334 + if (!file) { 335 + ksft_print_msg("Error opening %s\n", MAX_SKB_FRAGS_PATH); 336 + return 0; 337 + } 338 + 339 + if (fscanf(file, "%u", &max_skb_frags) != 1) 340 + ksft_print_msg("Error reading %s\n", MAX_SKB_FRAGS_PATH); 341 + 342 + fclose(file); 343 + return max_skb_frags; 344 + } 345 + 327 346 static struct option long_options[] = { 328 347 {"interface", required_argument, 0, 'i'}, 329 348 {"busy-poll", no_argument, 0, 'b'}, ··· 2263 2244 2264 2245 static int testapp_too_many_frags(struct test_spec *test) 2265 2246 { 2266 - struct pkt pkts[2 * XSK_DESC__MAX_SKB_FRAGS + 2] = {}; 2247 + struct pkt *pkts; 2267 2248 u32 max_frags, i; 2249 + int ret; 2268 2250 2269 - if (test->mode == TEST_MODE_ZC) 2251 + if (test->mode == TEST_MODE_ZC) { 2270 2252 max_frags = test->ifobj_tx->xdp_zc_max_segs; 2271 - else 2272 - max_frags = XSK_DESC__MAX_SKB_FRAGS; 2253 + } else { 2254 + max_frags = get_max_skb_frags(); 2255 + if (!max_frags) { 2256 + ksft_print_msg("Couldn't retrieve MAX_SKB_FRAGS from system, using default (17) value\n"); 2257 + max_frags = 17; 2258 + } 2259 + max_frags += 1; 2260 + } 2261 + 2262 + pkts = calloc(2 * max_frags + 2, sizeof(struct pkt)); 2263 + if (!pkts) 2264 + return TEST_FAILURE; 2273 2265 2274 2266 test->mtu = MAX_ETH_JUMBO_SIZE; 2275 2267 ··· 2310 2280 pkts[2 * max_frags + 1].valid = true; 2311 2281 2312 2282 pkt_stream_generate_custom(test, pkts, 2 * max_frags + 2); 2313 - return testapp_validate_traffic(test); 2283 + ret = testapp_validate_traffic(test); 2284 + 2285 + free(pkts); 2286 + return ret; 2314 2287 } 2315 2288 2316 2289 static int xsk_load_xdp_programs(struct ifobject *ifobj)
-1
tools/testing/selftests/bpf/xskxceiver.h
··· 55 55 #define XSK_UMEM__LARGE_FRAME_SIZE (3 * 1024) 56 56 #define XSK_UMEM__MAX_FRAME_SIZE (4 * 1024) 57 57 #define XSK_DESC__INVALID_OPTION (0xffff) 58 - #define XSK_DESC__MAX_SKB_FRAGS 18 59 58 #define HUGEPAGE_SIZE (2 * 1024 * 1024) 60 59 #define PKT_DUMP_NB_TO_PRINT 16 61 60 #define RUN_ALL_TESTS UINT_MAX