1 // SPDX-License-Identifier: GPL-2.0 2 #include <test_progs.h> 3 #include <network_helpers.h> 4 5 void test_skb_helpers(void) 6 { 7 struct __sk_buff skb = { 8 .wire_len = 100, 9 .gso_segs = 8, 10 .gso_size = 10, 11 }; 12 LIBBPF_OPTS(bpf_test_run_opts, topts, 13 .data_in = &pkt_v4, 14 .data_size_in = sizeof(pkt_v4), 15 .ctx_in = &skb, 16 .ctx_size_in = sizeof(skb), 17 .ctx_out = &skb, 18 .ctx_size_out = sizeof(skb), 19 ); 20 struct bpf_object *obj; 21 int err, prog_fd; 22 23 err = bpf_prog_test_load("./test_skb_helpers.bpf.o", 24 BPF_PROG_TYPE_SCHED_CLS, &obj, &prog_fd); 25 if (!ASSERT_OK(err, "load")) 26 return; 27 err = bpf_prog_test_run_opts(prog_fd, &topts); 28 ASSERT_OK(err, "test_run"); 29 bpf_object__close(obj); 30 } 31