Linux Audio

Check our new training course

Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0
 2#include <test_progs.h>
 3#include <network_helpers.h>
 4
 5void test_pkt_md_access(void)
 6{
 7	const char *file = "./test_pkt_md_access.bpf.o";
 8	struct bpf_object *obj;
 
 9	int err, prog_fd;
10	LIBBPF_OPTS(bpf_test_run_opts, topts,
11		.data_in = &pkt_v4,
12		.data_size_in = sizeof(pkt_v4),
13		.repeat = 10,
14	);
15
16	err = bpf_prog_test_load(file, BPF_PROG_TYPE_SCHED_CLS, &obj, &prog_fd);
17	if (CHECK_FAIL(err))
18		return;
19
20	err = bpf_prog_test_run_opts(prog_fd, &topts);
21	ASSERT_OK(err, "test_run_opts err");
22	ASSERT_OK(topts.retval, "test_run_opts retval");
 
 
23
24	bpf_object__close(obj);
25}
v5.4
 1// SPDX-License-Identifier: GPL-2.0
 2#include <test_progs.h>
 
 3
 4void test_pkt_md_access(void)
 5{
 6	const char *file = "./test_pkt_md_access.o";
 7	struct bpf_object *obj;
 8	__u32 duration, retval;
 9	int err, prog_fd;
 
 
 
 
 
10
11	err = bpf_prog_load(file, BPF_PROG_TYPE_SCHED_CLS, &obj, &prog_fd);
12	if (CHECK_FAIL(err))
13		return;
14
15	err = bpf_prog_test_run(prog_fd, 10, &pkt_v4, sizeof(pkt_v4),
16				NULL, NULL, &retval, &duration);
17	CHECK(err || retval, "",
18	      "err %d errno %d retval %d duration %d\n",
19	      err, errno, retval, duration);
20
21	bpf_object__close(obj);
22}