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 struct bpf_prog_test_run_attr tattr = { 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; 22 23 err = bpf_prog_test_load("./test_skb_helpers.o", BPF_PROG_TYPE_SCHED_CLS, &obj, 24 &tattr.prog_fd); 25 if (CHECK_ATTR(err, "load", "err %d errno %d\n", err, errno)) 26 return; 27 err = bpf_prog_test_run_xattr(&tattr); 28 CHECK_ATTR(err, "len", "err %d errno %d\n", err, errno); 29 bpf_object__close(obj); 30 } 31