xref: /linux/tools/testing/selftests/bpf/prog_tests/pkt_md_access.c (revision 9f2c9170934eace462499ba0bfe042cc72900173)
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