1 // SPDX-License-Identifier: GPL-2.0 2 #include <test_progs.h> 3 4 void test_xdp_adjust_tail(void) 5 { 6 const char *file = "./test_adjust_tail.o"; 7 struct bpf_object *obj; 8 char buf[128]; 9 __u32 duration, retval, size; 10 int err, prog_fd; 11 12 err = bpf_prog_load(file, BPF_PROG_TYPE_XDP, &obj, &prog_fd); 13 if (err) { 14 error_cnt++; 15 return; 16 } 17 18 err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4), 19 buf, &size, &retval, &duration); 20 21 CHECK(err || retval != XDP_DROP, 22 "ipv4", "err %d errno %d retval %d size %d\n", 23 err, errno, retval, size); 24 25 err = bpf_prog_test_run(prog_fd, 1, &pkt_v6, sizeof(pkt_v6), 26 buf, &size, &retval, &duration); 27 CHECK(err || retval != XDP_TX || size != 54, 28 "ipv6", "err %d errno %d retval %d size %d\n", 29 err, errno, retval, size); 30 bpf_object__close(obj); 31 } 32