1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2019 Facebook */ 3 #include <test_progs.h> 4 #include "test_pkt_access.skel.h" 5 #include "fentry_test.skel.h" 6 7 void test_fentry_test(void) 8 { 9 struct test_pkt_access *pkt_skel = NULL; 10 struct fentry_test *fentry_skel = NULL; 11 int err, pkt_fd, i; 12 __u32 duration = 0, retval; 13 __u64 *result; 14 15 pkt_skel = test_pkt_access__open_and_load(); 16 if (CHECK(!pkt_skel, "pkt_skel_load", "pkt_access skeleton failed\n")) 17 return; 18 fentry_skel = fentry_test__open_and_load(); 19 if (CHECK(!fentry_skel, "fentry_skel_load", "fentry skeleton failed\n")) 20 goto cleanup; 21 22 err = fentry_test__attach(fentry_skel); 23 if (CHECK(err, "fentry_attach", "fentry attach failed: %d\n", err)) 24 goto cleanup; 25 26 pkt_fd = bpf_program__fd(pkt_skel->progs.test_pkt_access); 27 err = bpf_prog_test_run(pkt_fd, 1, &pkt_v6, sizeof(pkt_v6), 28 NULL, NULL, &retval, &duration); 29 CHECK(err || retval, "ipv6", 30 "err %d errno %d retval %d duration %d\n", 31 err, errno, retval, duration); 32 33 result = (__u64 *)fentry_skel->bss; 34 for (i = 0; i < 6; i++) { 35 if (CHECK(result[i] != 1, "result", 36 "fentry_test%d failed err %lld\n", i + 1, result[i])) 37 goto cleanup; 38 } 39 40 cleanup: 41 fentry_test__destroy(fentry_skel); 42 test_pkt_access__destroy(pkt_skel); 43 } 44