mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 16:38:12 +00:00
488a23b89d
1. Move pkt_v4 and pkt_v6 into network_helpers and adjust the users. 2. Copy-paste spin_lock_thread into two tests that use it. Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Martin KaFai Lau <kafai@fb.com> Acked-by: Andrey Ignatov <rdna@fb.com> Link: https://lore.kernel.org/bpf/20200508174611.228805-3-sdf@google.com
28 lines
806 B
C
28 lines
806 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <test_progs.h>
|
|
#include <network_helpers.h>
|
|
|
|
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);
|
|
if (CHECK_FAIL(err))
|
|
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);
|
|
}
|