1 // SPDX-License-Identifier: GPL-2.0 2 #include <test_progs.h> 3 4 void test_pkt_access(void) 5 { 6 const char *file = "./test_pkt_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 (err) { 13 error_cnt++; 14 return; 15 } 16 17 err = bpf_prog_test_run(prog_fd, 100000, &pkt_v4, sizeof(pkt_v4), 18 NULL, NULL, &retval, &duration); 19 CHECK(err || retval, "ipv4", 20 "err %d errno %d retval %d duration %d\n", 21 err, errno, retval, duration); 22 23 err = bpf_prog_test_run(prog_fd, 100000, &pkt_v6, sizeof(pkt_v6), 24 NULL, NULL, &retval, &duration); 25 CHECK(err || retval, "ipv6", 26 "err %d errno %d retval %d duration %d\n", 27 err, errno, retval, duration); 28 bpf_object__close(obj); 29 } 30