xref: /linux/tools/testing/selftests/bpf/prog_tests/pkt_md_access.c (revision ae22a94997b8a03dcb3c922857c203246711f9d4)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <test_progs.h>
3 #include <network_helpers.h>
4 
5 void 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 }
26