/* topts.data_size_in as a special signal to bpf prog */ if (is_64k_pagesize)
topts.data_size_in = sizeof(pkt_v4) - 1; else
topts.data_size_in = sizeof(pkt_v4);
err = bpf_prog_test_load(file, BPF_PROG_TYPE_XDP, &obj, &prog_fd); if (!ASSERT_OK(err, "test_xdp_adjust_tail_grow")) return;
staticvoid test_xdp_adjust_tail_grow2(void)
{ constchar *file = "./test_xdp_adjust_tail_grow.bpf.o"; char buf[4096]; /* avoid segfault: large buf to hold grow results */ struct bpf_object *obj; int err, cnt, i; int max_grow, prog_fd; /* SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) */ #ifdefined(__s390x__) int tailroom = 512; #elifdefined(__powerpc__) int tailroom = 384; #else int tailroom = 320; #endif
LIBBPF_OPTS(bpf_test_run_opts, tattr,
.repeat = 1,
.data_in = &buf,
.data_out = &buf,
.data_size_in = 0, /* Per test */
.data_size_out = 0, /* Per test */
);
err = bpf_prog_test_load(file, BPF_PROG_TYPE_XDP, &obj, &prog_fd); if (!ASSERT_OK(err, "test_xdp_adjust_tail_grow")) return;
/* Test case-64 */
memset(buf, 1, sizeof(buf));
tattr.data_size_in = 64; /* Determine test case via pkt size */
tattr.data_size_out = 128; /* Limit copy_size */ /* Kernel side alloc packet memory area that is zero init */
err = bpf_prog_test_run_opts(prog_fd, &tattr);
/* For the individual test cases, the first byte in the packet * indicates which test will be run.
*/
obj = bpf_object__open(file); if (libbpf_get_error(obj)) return;
prog = bpf_object__next_program(obj, NULL); if (bpf_object__load(obj)) return;
prog_fd = bpf_program__fd(prog);
buf = malloc(9000); if (!ASSERT_OK_PTR(buf, "alloc buf 9Kb")) goto out;
memset(buf, 0, 9000);
/* Test case removing 10 bytes from last frag, NOT freeing it */
exp_size = 8990; /* 9000 - 10 */
topts.data_in = buf;
topts.data_out = buf;
topts.data_size_in = 9000;
topts.data_size_out = 9000;
err = bpf_prog_test_run_opts(prog_fd, &topts);
void test_xdp_adjust_tail(void)
{ int page_size = getpagesize();
if (test__start_subtest("xdp_adjust_tail_shrink"))
test_xdp_adjust_tail_shrink(); if (test__start_subtest("xdp_adjust_tail_grow"))
test_xdp_adjust_tail_grow(page_size == 65536); if (test__start_subtest("xdp_adjust_tail_grow2"))
test_xdp_adjust_tail_grow2(); if (test__start_subtest("xdp_adjust_frags_tail_shrink"))
test_xdp_adjust_frags_tail_shrink(); if (test__start_subtest("xdp_adjust_frags_tail_grow")) { if (page_size == 65536)
test_xdp_adjust_frags_tail_grow_64k(); else
test_xdp_adjust_frags_tail_grow_4k();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.