2019-03-02 03:42:14 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <test_progs.h>
|
2020-05-08 17:46:09 +00:00
|
|
|
#include <network_helpers.h>
|
2019-03-02 03:42:14 +00:00
|
|
|
|
|
|
|
void test_pkt_access(void)
|
|
|
|
{
|
|
|
|
const char *file = "./test_pkt_access.o";
|
|
|
|
struct bpf_object *obj;
|
|
|
|
__u32 duration, retval;
|
|
|
|
int err, prog_fd;
|
|
|
|
|
|
|
|
err = bpf_prog_load(file, BPF_PROG_TYPE_SCHED_CLS, &obj, &prog_fd);
|
2019-08-21 23:44:25 +00:00
|
|
|
if (CHECK_FAIL(err))
|
2019-03-02 03:42:14 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
err = bpf_prog_test_run(prog_fd, 100000, &pkt_v4, sizeof(pkt_v4),
|
|
|
|
NULL, NULL, &retval, &duration);
|
|
|
|
CHECK(err || retval, "ipv4",
|
|
|
|
"err %d errno %d retval %d duration %d\n",
|
|
|
|
err, errno, retval, duration);
|
|
|
|
|
|
|
|
err = bpf_prog_test_run(prog_fd, 100000, &pkt_v6, sizeof(pkt_v6),
|
|
|
|
NULL, NULL, &retval, &duration);
|
|
|
|
CHECK(err || retval, "ipv6",
|
|
|
|
"err %d errno %d retval %d duration %d\n",
|
|
|
|
err, errno, retval, duration);
|
|
|
|
bpf_object__close(obj);
|
|
|
|
}
|