Projectname large_stringclasses 15
values | Filepath large_stringlengths 4 106 ⌀ | Function large_stringlengths 11 3.45k | Label list |
|---|---|---|---|
Linux Kernel | tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c | static void btf_add_dup_struct_in_cu(struct btf *btf, int start_id) {
#define ID(n) (start_id + n)
btf__set_pointer_size(btf, 8);
btf__add_int(btf, "int", 4, BTF_INT_SIGNED); /* [1] int */
btf__add_struct(btf, "s", 8); /* [2] struct s { */
btf__add_field(btf, "a", ID(3), 0, 0); /* struct anon a;... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c |
void test_btf_dedup_split() {
if (test__start_subtest("split_simple"))
test_split_simple();
if (test__start_subtest("split_struct_duped"))
test_split_struct_duped();
if (test__start_subtest("split_fwd_resolve"))
test_split_fwd_resolve();
if (test__start_subtest("split_dup_struct_in_cu"))
test_s... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/btf_dump.c |
static void btf_dump_snprintf(void *ctx, const char *fmt, va_list args) {
char *s = ctx, new[STRSIZE];
vsnprintf(new, STRSIZE, fmt, args);
if (strlen(s) < STRSIZE)
strncat(s, new, STRSIZE - strlen(s) - 1);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/btf_dump.c |
static void test_btf_dump_datasec_data(char *str) {
struct btf *btf;
char license[4] = "GPL";
struct btf_dump *d;
btf = btf__parse("xdping_kern.bpf.o", NULL);
if (!ASSERT_OK_PTR(btf, "xdping_kern.bpf.o BTF not found"))
return;
d = btf_dump__new(btf, btf_dump_snprintf, str, NULL);
if (!ASSERT_OK_PTR... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/btf_tag.c |
static void test_btf_decl_tag(void) {
struct test_btf_decl_tag *skel;
skel = test_btf_decl_tag__open_and_load();
if (!ASSERT_OK_PTR(skel, "btf_decl_tag"))
return;
if (skel->rodata->skip_tests) {
printf("%s:SKIP: btf_decl_tag attribute not supported", __func__);
test__skip();
}
test_btf_decl_... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/btf_write.c |
void test_btf_write() {
if (test__start_subtest("btf_add"))
test_btf_add();
if (test__start_subtest("btf_add_btf"))
test_btf_add_btf();
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cb_refs.c |
void test_cb_refs(void) {
LIBBPF_OPTS(bpf_object_open_opts, opts, .kernel_log_buf = log_buf,
.kernel_log_size = sizeof(log_buf), .kernel_log_level = 1);
struct bpf_program *prog;
struct cb_refs *skel;
int i;
for (i = 0; i < ARRAY_SIZE(cb_refs_tests); i++) {
LIBBPF_OPTS(bpf_test_run_opts, r... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cgroup_attach_override.c | static int prog_load(int verdict) {
struct bpf_insn prog[] = {
BPF_MOV64_IMM(BPF_REG_0, verdict),
BPF_EXIT_INSN(),
};
size_t insns_cnt = ARRAY_SIZE(prog);
return bpf_test_load_program(BPF_PROG_TYPE_CGROUP_SKB, prog, insns_cnt, "GPL",
0, bpf_log_buf, BPF_LOG_BUF_SIZE);... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cgroup_getset_retval.c | static void test_setsockopt_legacy_eperm(int cgroup_fd, int sock_fd) {
struct cgroup_getset_retval_setsockopt *obj;
struct bpf_link *link_legacy_eperm = NULL, *link_get_retval = NULL;
obj = cgroup_getset_retval_setsockopt__open_and_load();
if (!ASSERT_OK_PTR(obj, "skel-load"))
return;
link_legacy_eperm ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cgroup_getset_retval.c | static void test_setsockopt_legacy_no_override(int cgroup_fd, int sock_fd) {
struct cgroup_getset_retval_setsockopt *obj;
struct bpf_link *link_set_eunatch = NULL, *link_legacy_eperm = NULL;
struct bpf_link *link_get_retval = NULL;
obj = cgroup_getset_retval_setsockopt__open_and_load();
if (!ASSERT_OK_PTR(ob... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cgroup_getset_retval.c | static void test_getsockopt_override(int cgroup_fd, int sock_fd) {
struct cgroup_getset_retval_getsockopt *obj;
struct bpf_link *link_set_eisconn = NULL;
int buf;
socklen_t optlen = sizeof(buf);
obj = cgroup_getset_retval_getsockopt__open_and_load();
if (!ASSERT_OK_PTR(obj, "skel-load"))
return;
lin... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c | static int setup_cgroups(void) {
int i, fd, err;
err = setup_cgroup_environment();
if (!ASSERT_OK(err, "setup_cgroup_environment"))
return err;
root_cgroup_fd = get_root_cgroup();
if (!ASSERT_GE(root_cgroup_fd, 0, "get_root_cgroup"))
return root_cgroup_fd;
for (i = 0; i < N_CGROUPS; i++) {
fd... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c |
static void cleanup_cgroups(void) {
close(root_cgroup_fd);
for (int i = 0; i < N_CGROUPS; i++)
close(cgroups[i].fd);
cleanup_cgroup_environment();
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c | static int setup_hierarchy(void) { return setup_bpffs() || setup_cgroups(); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c | static int setup_cgroup_iter(struct cgroup_hierarchical_stats *obj,
int cgroup_fd, const char *file_name) {
DECLARE_LIBBPF_OPTS(bpf_iter_attach_opts, opts);
union bpf_iter_link_info linfo = {};
struct bpf_link *link;
static char path[128];
int err;
linfo.cgroup.cgroup_fd = cgro... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cgroup_skb_sk_lookup.c | void test_cgroup_skb_sk_lookup(void) {
const char *cg_path = "/foo";
int out_sk;
out_sk = socket(AF_INET6, SOCK_STREAM, 0);
if (CHECK_FAIL(out_sk < 0))
return;
run_cgroup_bpf_test(cg_path, out_sk);
close(out_sk);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cgrp_kfunc.c |
static struct cgrp_kfunc_success *open_load_cgrp_kfunc_skel(void) {
struct cgrp_kfunc_success *skel;
int err;
skel = cgrp_kfunc_success__open();
if (!ASSERT_OK_PTR(skel, "skel_open"))
return NULL;
skel->bss->pid = getpid();
err = cgrp_kfunc_success__load(skel);
if (!ASSERT_OK(err, "skel_load"))
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cls_redirect.c | static bool set_up_conn(const struct sockaddr *addr, socklen_t len, int type,
int *server, int *conn, struct tuple *tuple) {
struct sockaddr_storage ss;
socklen_t slen = sizeof(ss);
struct sockaddr *sa = (struct sockaddr *)&ss;
*server = start_server(addr, len, type);
if (*server < 0)... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cls_redirect.c |
static int test_str(void *buf, size_t len, const struct test_cfg *test,
int family) {
const char *family_str, *type, *conn, *hops, *result, *flags;
family_str = "IPv4";
if (family == AF_INET6)
family_str = "IPv6";
type = "TCP";
if (test->type == UDP)
type = "UDP";
conn = "kno... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cls_redirect.c |
static void test_cls_redirect_subprogs(void) {
struct test_cls_redirect_subprogs *skel;
int err;
skel = test_cls_redirect_subprogs__open();
if (CHECK(!skel, "skel_open", "failed\n"))
return;
skel->rodata->ENCAPSULATION_IP = htonl(ENCAP_IP);
skel->rodata->ENCAPSULATION_PORT = htons(ENCAP_PORT);
err... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cls_redirect.c |
void test_cls_redirect(void) {
if (test__start_subtest("cls_redirect_inlined"))
test_cls_redirect_inlined();
if (test__start_subtest("cls_redirect_subprogs"))
test_cls_redirect_subprogs();
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/core_extern.c |
void test_core_extern(void) {
const uint32_t kern_ver = get_kernel_version();
int err, i, j;
struct test_core_extern *skel = NULL;
uint64_t *got, *exp;
int n = sizeof(*skel->data) / sizeof(uint64_t);
for (i = 0; i < ARRAY_SIZE(test_cases); i++) {
struct test_case *t = &test_cases[i];
DECLARE_LIBBP... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/core_reloc.c |
static size_t roundup_page(size_t sz) {
long page_size = sysconf(_SC_PAGE_SIZE);
return (sz + page_size - 1) / page_size * page_size;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/core_reloc.c |
void test_core_reloc(void) { run_core_reloc_tests(false); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/core_retro.c | void test_core_retro(void) {
int err, zero = 0, res, my_pid = getpid();
struct test_core_retro *skel;
skel = test_core_retro__open_and_load();
if (!ASSERT_OK_PTR(skel, "skel_load"))
goto out_close;
err = bpf_map__update_elem(skel->maps.exp_tgid_map, &zero, sizeof(zero),
&my_... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/cpu_mask.c |
void test_cpu_mask() {
int i, err, n;
bool *mask;
for (i = 0; i < ARRAY_SIZE(test_cases); i++) {
mask = NULL;
err = parse_cpu_mask_str(test_cases[i].cpu_mask, &mask, &n);
if (test_cases[i].fails) {
CHECK(!err, "should_fail", "case #%d: parsing should fail!\n", i + 1);
} else {
if (CH... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/custom_sec_handlers.c | static int custom_attach_prog(const struct bpf_program *prog, long cookie,
struct bpf_link **link) {
switch (cookie) {
case COOKIE_ABC2:
*link = bpf_program__attach_raw_tracepoint(prog, "sys_enter");
return libbpf_get_error(*link);
case COOKIE_CUSTOM:
*link =
bpf_... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/deny_namespace.c |
static int wait_for_pid(pid_t pid) {
int status, ret;
again:
ret = waitpid(pid, &status, 0);
if (ret == -1) {
if (errno == EINTR)
goto again;
return -1;
}
if (!WIFEXITED(status))
return -1;
return WEXITSTATUS(status);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/deny_namespace.c | static int create_user_ns(void) {
pid_t pid;
pid = fork();
if (pid < 0)
return -1;
if (pid == 0) {
if (unshare(CLONE_NEWUSER))
_exit(EXIT_FAILURE);
_exit(EXIT_SUCCESS);
}
return wait_for_pid(pid);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/dummy_st_ops.c |
static void test_dummy_st_ops_attach(void) {
struct dummy_st_ops *skel;
struct bpf_link *link;
skel = dummy_st_ops__open_and_load();
if (!ASSERT_OK_PTR(skel, "dummy_st_ops_load"))
return;
link = bpf_map__attach_struct_ops(skel->maps.dummy_1);
ASSERT_EQ(libbpf_get_error(link), -EOPNOTSUPP, "dummy_st_o... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/d_path.c | static void test_d_path_basic(void) {
struct test_d_path__bss *bss;
struct test_d_path *skel;
int err;
skel = test_d_path__open_and_load();
if (CHECK(!skel, "setup", "d_path skeleton failed\n"))
goto cleanup;
err = test_d_path__attach(skel);
if (CHECK(err, "setup", "attach failed: %d\n", err))
g... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/d_path.c |
static void test_d_path_check_types(void) {
struct test_d_path_check_types *skel;
skel = test_d_path_check_types__open_and_load();
ASSERT_ERR_PTR(skel, "unexpected_load_passing_wrong_type");
test_d_path_check_types__destroy(skel);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/enable_stats.c |
void test_enable_stats(void) {
struct test_enable_stats *skel;
int stats_fd, err, prog_fd;
struct bpf_prog_info info;
__u32 info_len = sizeof(info);
int duration = 0;
skel = test_enable_stats__open_and_load();
if (CHECK(!skel, "skel_open_and_load", "skeleton open/load failed\n"))
return;
stats_fd... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/exhandler.c |
void test_exhandler(void) {
int err = 0, duration = 0, status;
struct exhandler_kern *skel;
pid_t cpid;
skel = exhandler_kern__open_and_load();
if (CHECK(!skel, "skel_load", "skeleton failed: %d\n", err))
goto cleanup;
skel->bss->test_pid = getpid();
err = exhandler_kern__attach(skel);
if (!ASSE... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/fentry_test.c | static int fentry_test(struct fentry_test_lskel *fentry_skel) {
int err, prog_fd, i;
int link_fd;
__u64 *result;
LIBBPF_OPTS(bpf_test_run_opts, topts);
err = fentry_test_lskel__attach(fentry_skel);
if (!ASSERT_OK(err, "fentry_attach"))
return err;
link_fd = fentry_test_lskel__test1__attach(fentry_sk... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/fentry_test.c |
void test_fentry_test(void) {
struct fentry_test_lskel *fentry_skel = NULL;
int err;
fentry_skel = fentry_test_lskel__open_and_load();
if (!ASSERT_OK_PTR(fentry_skel, "fentry_skel_load"))
goto cleanup;
err = fentry_test(fentry_skel);
if (!ASSERT_OK(err, "fentry_first_attach"))
goto cleanup;
er... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c |
static void test_target_yes_callees(void) {
const char *prog_name[] = {
"fexit/test_pkt_access",
"fexit/test_pkt_access_subprog1",
"fexit/test_pkt_access_subprog2",
"fexit/test_pkt_access_subprog3",
};
test_fexit_bpf2bpf_common("./fexit_bpf2bpf.bpf.o", "./test_pkt_access.bpf.o",
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c |
static void test_func_sockmap_update(void) {
const char *prog_name[] = {
"freplace/cls_redirect",
};
test_fexit_bpf2bpf_common("./freplace_cls_redirect.bpf.o",
"./test_cls_redirect.bpf.o", ARRAY_SIZE(prog_name),
prog_name, false, NULL);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c |
static int find_prog_btf_id(const char *name, __u32 attach_prog_fd) {
struct bpf_prog_info info = {};
__u32 info_len = sizeof(info);
struct btf *btf;
int ret;
ret = bpf_obj_get_info_by_fd(attach_prog_fd, &info, &info_len);
if (ret)
return ret;
if (!info.btf_id)
return -EINVAL;
btf = btf__loa... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c | static void test_fentry_to_cgroup_bpf(void) {
struct bind4_prog *skel = NULL;
struct bpf_prog_info info = {};
__u32 info_len = sizeof(info);
int cgroup_fd = -1;
int fentry_fd = -1;
int btf_id;
cgroup_fd = test__join_cgroup("/fentry_to_cgroup_bpf");
if (!ASSERT_GE(cgroup_fd, 0, "cgroup_fd"))
return;... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/fexit_test.c | static int fexit_test(struct fexit_test_lskel *fexit_skel) {
int err, prog_fd, i;
int link_fd;
__u64 *result;
LIBBPF_OPTS(bpf_test_run_opts, topts);
err = fexit_test_lskel__attach(fexit_skel);
if (!ASSERT_OK(err, "fexit_attach"))
return err;
link_fd = fexit_test_lskel__test1__attach(fexit_skel);
i... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/fexit_test.c |
void test_fexit_test(void) {
struct fexit_test_lskel *fexit_skel = NULL;
int err;
fexit_skel = fexit_test_lskel__open_and_load();
if (!ASSERT_OK_PTR(fexit_skel, "fexit_skel_load"))
goto cleanup;
err = fexit_test(fexit_skel);
if (!ASSERT_OK(err, "fexit_first_attach"))
goto cleanup;
err = fexit_... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/find_vma.c |
static void test_and_reset_skel(struct find_vma *skel,
int expected_find_zero_ret, bool need_test) {
if (need_test) {
ASSERT_EQ(skel->bss->found_vm_exec, 1, "found_vm_exec");
ASSERT_EQ(skel->data->find_addr_ret, 0, "find_addr_ret");
ASSERT_EQ(skel->data->find_zero_ret, exp... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/find_vma.c | static void test_find_vma_pe(struct find_vma *skel) {
struct bpf_link *link = NULL;
volatile int j = 0;
int pfd, i;
const int one_bn = 1000000000;
pfd = open_pe();
if (pfd < 0) {
if (pfd == -ENOENT || pfd == -EOPNOTSUPP) {
printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n", __func__);
test__ski... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/find_vma.c | static void test_find_vma_kprobe(struct find_vma *skel) {
int err;
err = find_vma__attach(skel);
if (!ASSERT_OK(err, "get_branch_snapshot__attach"))
return;
getpgid(skel->bss->target_pid);
test_and_reset_skel(skel, -ENOENT, true);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/find_vma.c |
static void test_illegal_write_task(void) {
struct find_vma_fail2 *skel;
skel = find_vma_fail2__open_and_load();
if (!ASSERT_ERR_PTR(skel, "find_vma_fail2__open_and_load"))
find_vma_fail2__destroy(skel);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/flow_dissector.c |
static int tx_tap(int fd, void *pkt, size_t len) {
struct iovec iov[] = {
{
.iov_len = len,
.iov_base = pkt,
},
};
return writev(fd, iov, ARRAY_SIZE(iov));
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/flow_dissector.c | static void run_tests_skb_less(int tap_fd, struct bpf_map *keys) {
int i, err, keys_fd;
keys_fd = bpf_map__fd(keys);
if (CHECK(keys_fd < 0, "bpf_map__fd", "err %d\n", keys_fd))
return;
for (i = 0; i < ARRAY_SIZE(tests); i++) {
__u32 eth_get_headlen_flags = BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG;
LIB... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/flow_dissector.c |
static void test_skb_less_link_create(struct bpf_flow *skel, int tap_fd) {
struct bpf_link *link;
int err, net_fd;
net_fd = open("/proc/self/ns/net", O_RDONLY);
if (CHECK(net_fd < 0, "open(/proc/self/ns/net)", "err %d\n", errno))
return;
link = bpf_program__attach_netns(skel->progs._dissect, net_fd);
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/flow_dissector_reattach.c | static void test_prog_attach_prog_attach(int netns, int prog1, int prog2) {
int err;
err = bpf_prog_attach(prog1, 0, BPF_FLOW_DISSECTOR, 0);
if (CHECK_FAIL(err)) {
perror("bpf_prog_attach(prog1)");
return;
}
CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1));
err = bpf_prog_attach(p... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/flow_dissector_reattach.c | static void test_link_create_link_create(int netns, int prog1, int prog2) {
DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts);
int link1, link2;
link1 = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &opts);
if (CHECK_FAIL(link < 0)) {
perror("bpf_link_create(prog1)");
return;
}
CHECK_FAIL(query_a... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/flow_dissector_reattach.c | static void test_link_create_prog_attach(int netns, int prog1, int prog2) {
DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts);
int err, link;
link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &opts);
if (CHECK_FAIL(link < 0)) {
perror("bpf_link_create(prog1)");
return;
}
CHECK_FAIL(query_attac... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/flow_dissector_reattach.c | static void test_link_update_same_prog(int netns, int prog1, int prog2) {
DECLARE_LIBBPF_OPTS(bpf_link_create_opts, create_opts);
DECLARE_LIBBPF_OPTS(bpf_link_update_opts, update_opts);
int err, link;
link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &create_opts);
if (CHECK_FAIL(link < 0)) {
perr... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/flow_dissector_reattach.c | static void test_link_update_netns_gone(int netns, int prog1, int prog2) {
DECLARE_LIBBPF_OPTS(bpf_link_create_opts, create_opts);
DECLARE_LIBBPF_OPTS(bpf_link_update_opts, update_opts);
int err, link, old_net;
old_net = netns;
netns = unshare_net(old_net);
if (netns < 0)
return;
link = bpf_link_cre... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/for_each.c |
void test_for_each(void) {
if (test__start_subtest("hash_map"))
test_hash_map();
if (test__start_subtest("array_map"))
test_array_map();
if (test__start_subtest("write_map_key"))
test_write_map_key();
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c | static void test_function_entry(void) {
struct get_func_ip_test *skel = NULL;
int err, prog_fd;
LIBBPF_OPTS(bpf_test_run_opts, topts);
skel = get_func_ip_test__open();
if (!ASSERT_OK_PTR(skel, "get_func_ip_test__open"))
return;
err = get_func_ip_test__load(skel);
if (!ASSERT_OK(err, "get_func_ip_tes... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/global_data.c |
static void test_global_data_struct(struct bpf_object *obj, __u32 duration) {
int i, err, map_fd;
struct foo val;
map_fd = bpf_find_map(__func__, obj, "result_struct");
if (CHECK_FAIL(map_fd < 0))
return;
struct {
char *name;
uint32_t key;
struct foo val;
} tests[] = {
{"relocate .r... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/global_data.c |
void test_global_data(void) {
const char *file = "./test_global_data.bpf.o";
struct bpf_object *obj;
int err, prog_fd;
LIBBPF_OPTS(bpf_test_run_opts, topts, .data_in = &pkt_v4,
.data_size_in = sizeof(pkt_v4), .repeat = 1, );
err = bpf_prog_test_load(file, BPF_PROG_TYPE_SCHED_CLS, &obj, &prog_f... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/global_data_init.c | void test_global_data_init(void) {
const char *file = "./test_global_data.bpf.o";
int err = -ENOMEM, map_fd, zero = 0;
__u8 *buff = NULL, *newval = NULL;
struct bpf_object *obj;
struct bpf_map *map;
__u32 duration = 0;
size_t sz;
obj = bpf_object__open_file(file, NULL);
err = libbpf_get_error(obj);
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/global_func_args.c |
static void test_global_func_args0(struct bpf_object *obj) {
int err, i, map_fd, actual_value;
const char *map_name = "values";
map_fd = bpf_find_map(__func__, obj, map_name);
if (CHECK(map_fd < 0, "bpf_find_map", "cannot find BPF map %s: %s\n",
map_name, strerror(errno)))
return;
struct {
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/global_func_args.c |
void test_global_func_args(void) {
const char *file = "./test_global_func_args.bpf.o";
struct bpf_object *obj;
int err, prog_fd;
LIBBPF_OPTS(bpf_test_run_opts, topts, .data_in = &pkt_v4,
.data_size_in = sizeof(pkt_v4), .repeat = 1, );
err = bpf_prog_test_load(file, BPF_PROG_TYPE_CGROUP_SKB, &o... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/hashmap.c |
static size_t hash_fn(long k, void *ctx) { return k; } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/hashmap.c |
static size_t str_hash_fn(long a, void *ctx) { return str_hash((char *)a); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/hashmap.c |
void test_hashmap() {
if (test__start_subtest("generic"))
test_hashmap_generic();
if (test__start_subtest("multimap"))
test_hashmap_multimap();
if (test__start_subtest("empty"))
test_hashmap_empty();
if (test__start_subtest("ptr_iface"))
test_hashmap_ptr_iface();
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/hash_large_key.c |
void test_hash_large_key(void) {
int err, value = 21, duration = 0, hash_map_fd;
struct test_hash_large_key *skel;
struct bigelement {
int a;
char b[4096];
long long c;
} key;
bzero(&key, sizeof(key));
skel = test_hash_large_key__open_and_load();
if (CHECK(!skel, "skel_open_and_load", "skel... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/kfunc_call.c | static void verify_success(struct kfunc_test_params *param) {
struct kfunc_call_test_lskel *lskel = NULL;
LIBBPF_OPTS(bpf_test_run_opts, topts);
struct bpf_prog_desc *lskel_prog;
struct kfunc_call_test *skel;
struct bpf_program *prog;
int prog_fd, err;
struct syscall_test_args args = {
.size = 10,
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/kfunc_call.c |
static void test_main(void) {
int i;
for (i = 0; i < ARRAY_SIZE(kfunc_tests); i++) {
if (!test__start_subtest(kfunc_tests[i].prog_name))
continue;
if (!kfunc_tests[i].expected_err_msg)
verify_success(&kfunc_tests[i]);
else
verify_fail(&kfunc_tests[i]);
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/kfunc_call.c |
void test_kfunc_call(void) {
test_main();
if (test__start_subtest("subprog"))
test_subprog();
if (test__start_subtest("subprog_lskel"))
test_subprog_lskel();
if (test__start_subtest("destructive"))
test_destructive();
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/kfunc_dynptr_param.c |
static void verify_success(const char *prog_name, int expected_runtime_err) {
struct test_kfunc_dynptr_param *skel;
libbpf_print_fn_t old_print_cb;
struct bpf_program *prog;
struct bpf_link *link;
__u32 next_id;
int err;
skel = test_kfunc_dynptr_param__open();
if (!ASSERT_OK_PTR(skel, "test_kfunc_dynp... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c |
static void test_skel_api(void) {
struct kprobe_multi *skel = NULL;
int err;
skel = kprobe_multi__open_and_load();
if (!ASSERT_OK_PTR(skel, "kprobe_multi__open_and_load"))
goto cleanup;
skel->bss->pid = getpid();
err = kprobe_multi__attach(skel);
if (!ASSERT_OK(err, "kprobe_multi__attach"))
got... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c |
static void test_attach_api(const char *pattern,
struct bpf_kprobe_multi_opts *opts) {
struct bpf_link *link1 = NULL, *link2 = NULL;
struct kprobe_multi *skel = NULL;
skel = kprobe_multi__open_and_load();
if (!ASSERT_OK_PTR(skel, "fentry_raw_skel_load"))
goto cleanup;
skel->... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c |
static void test_attach_api_pattern(void) {
LIBBPF_OPTS(bpf_kprobe_multi_opts, opts);
test_attach_api("bpf_fentry_test*", &opts);
test_attach_api("bpf_fentry_test?", NULL);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/ksyms_btf.c |
static void test_null_check(void) {
struct test_ksyms_btf_null_check *skel;
skel = test_ksyms_btf_null_check__open_and_load();
CHECK(skel, "skel_open", "unexpected load of a prog missing null check\n");
test_ksyms_btf_null_check__destroy(skel);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/ksyms_btf.c |
void test_ksyms_btf(void) {
int percpu_datasec;
struct btf *btf;
btf = libbpf_find_kernel_btf();
if (!ASSERT_OK_PTR(btf, "btf_exists"))
return;
percpu_datasec =
btf__find_by_name_kind(btf, ".data..percpu", BTF_KIND_DATASEC);
btf__free(btf);
if (percpu_datasec < 0) {
printf("%s:SKIP:no PER... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/legacy_printk.c | static int execute_one_variant(bool legacy) {
struct test_legacy_printk *skel;
int err, zero = 0, my_pid = getpid(), res, map_fd;
skel = test_legacy_printk__open();
if (!ASSERT_OK_PTR(skel, "skel_open"))
return -errno;
bpf_program__set_autoload(skel->progs.handle_legacy, legacy);
bpf_program__set_auto... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/libbpf_probes.c | void test_libbpf_probe_map_types(void) {
struct btf *btf;
const struct btf_type *t;
const struct btf_enum *e;
int i, n, id;
btf = btf__parse("/sys/kernel/btf/vmlinux", NULL);
if (!ASSERT_OK_PTR(btf, "btf_parse"))
return;
id = btf__find_by_name_kind(btf, "bpf_map_type", BTF_KIND_ENUM);
if (!ASSERT_... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/libbpf_str.c | static void test_libbpf_bpf_link_type_str(void) {
struct btf *btf;
const struct btf_type *t;
const struct btf_enum *e;
int i, n, id;
btf = btf__parse("/sys/kernel/btf/vmlinux", NULL);
if (!ASSERT_OK_PTR(btf, "btf_parse"))
return;
id = btf__find_by_name_kind(btf, "bpf_link_type", BTF_KIND_ENUM);
if... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/libbpf_str.c | static void test_libbpf_bpf_map_type_str(void) {
struct btf *btf;
const struct btf_type *t;
const struct btf_enum *e;
int i, n, id;
btf = btf__parse("/sys/kernel/btf/vmlinux", NULL);
if (!ASSERT_OK_PTR(btf, "btf_parse"))
return;
id = btf__find_by_name_kind(btf, "bpf_map_type", BTF_KIND_ENUM);
if (... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/libbpf_str.c | void test_libbpf_str(void) {
if (test__start_subtest("bpf_attach_type_str"))
test_libbpf_bpf_attach_type_str();
if (test__start_subtest("bpf_link_type_str"))
test_libbpf_bpf_link_type_str();
if (test__start_subtest("bpf_map_type_str"))
test_libbpf_bpf_map_type_str();
if (test__start_subtest("bpf_... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/linked_funcs.c | void test_linked_funcs(void) {
int err;
struct linked_funcs *skel;
skel = linked_funcs__open();
if (!ASSERT_OK_PTR(skel, "skel_open"))
return;
bpf_program__set_autoload(skel->progs.handler1, true);
bpf_program__set_autoload(skel->progs.handler2, true);
skel->rodata->my_tid = syscall(SYS_gettid);
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/log_fixup.c |
static void bad_core_relo_subprog(void) {
char log_buf[8 * 1024];
struct test_log_fixup *skel;
int err;
skel = test_log_fixup__open();
if (!ASSERT_OK_PTR(skel, "skel_open"))
return;
bpf_program__set_autoload(skel->progs.bad_relo_subprog, true);
bpf_program__set_log_buf(skel->progs.bad_relo_subprog,... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/log_fixup.c | void test_log_fixup(void) {
if (test__start_subtest("bad_core_relo_trunc_none"))
bad_core_relo(0, TRUNC_NONE);
if (test__start_subtest("bad_core_relo_trunc_partial"))
bad_core_relo(300, TRUNC_PARTIAL /* truncate original log a bit */);
if (test__start_subtest("bad_core_relo_trunc_full"))
bad_core_relo... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c |
void test_lsm_cgroup(void) {
if (test__start_subtest("functional"))
test_lsm_cgroup_functional();
if (test__start_subtest("nonvoid"))
test_lsm_cgroup_nonvoid();
btf__free(btf);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/map_kptr.c | void test_map_kptr(void) {
if (test__start_subtest("success")) {
test_map_kptr_success(false);
test_map_kptr_success(true);
}
RUN_TESTS(map_kptr_fail);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/map_lock.c |
void test_map_lock(void) {
const char *file = "./test_map_lock.bpf.o";
int prog_fd, map_fd[2], vars[17] = {};
pthread_t thread_id[6];
struct bpf_object *obj = NULL;
int err = 0, key = 0, i;
void *ret;
err = bpf_prog_test_load(file, BPF_PROG_TYPE_CGROUP_SKB, &obj, &prog_fd);
if (CHECK_FAIL(err)) {
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/map_ptr.c |
void test_map_ptr(void) {
struct map_ptr_kern_lskel *skel;
char buf[128];
int err;
int page_size = getpagesize();
LIBBPF_OPTS(bpf_test_run_opts, topts, .data_in = &pkt_v4,
.data_size_in = sizeof(pkt_v4), .data_out = buf,
.data_size_out = sizeof(buf), .repeat = 1, );
skel = map_... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c | static int setup_fastopen(char *buf, int size, int *saved_len, bool restore) {
int err = 0, fd, len;
fd = open("/proc/sys/net/ipv4/tcp_fastopen", O_RDWR);
if (!ASSERT_NEQ(fd, -1, "open"))
return -1;
if (restore) {
len = write(fd, buf, *saved_len);
if (!ASSERT_EQ(len, *saved_len, "write - restore")... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c |
static int drop_ack(struct migrate_reuseport_test_case *test_case,
struct test_migrate_reuseport *skel) {
if (test_case->family == AF_INET)
skel->bss->server_port = ((struct sockaddr_in *)&test_case->addr)->sin_port;
else
skel->bss->server_port =
((struct sockaddr_in6 *)&test_ca... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/module_attach.c |
static int delete_module(const char *name, int flags) {
return syscall(__NR_delete_module, name, flags);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/mptcp.c |
void test_mptcp(void) {
if (test__start_subtest("base"))
test_base();
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c | static void test_ns_current_pid_tgid_new_ns(void) {
int wstatus, duration = 0;
pid_t cpid;
cpid = clone(test_current_pid_tgid, child_stack + STACK_SIZE,
CLONE_NEWPID | SIGCHLD, NULL);
if (CHECK(cpid == -1, "clone", "%s\n", strerror(errno)))
return;
if (CHECK(waitpid(cpid, &wstatus, 0) ==... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c | void serial_test_ns_current_pid_tgid(void) {
if (test__start_subtest("ns_current_pid_tgid_root_ns"))
test_current_pid_tgid(NULL);
if (test__start_subtest("ns_current_pid_tgid_new_ns"))
test_ns_current_pid_tgid_new_ns();
} | [
0,
1
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/perf_branches.c | static void check_good_sample(struct test_perf_branches *skel) {
int written_global = skel->bss->written_global_out;
int required_size = skel->bss->required_size_out;
int written_stack = skel->bss->written_stack_out;
int pbe_size = sizeof(struct perf_branch_entry);
int duration = 0;
if (CHECK(!skel->bss->v... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/perf_event_stackmap.c |
noinline int func_2(void) { return func_1(); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/pe_preserve_elems.c | static void test_one_map(struct bpf_map *map, struct bpf_program *prog,
bool has_share_pe) {
int err, key = 0, pfd = -1, mfd = bpf_map__fd(map);
DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts);
struct perf_event_attr attr = {
.size = sizeof(struct perf_event_attr),
.type = PERF_T... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/pe_preserve_elems.c |
void test_pe_preserve_elems(void) {
struct test_pe_preserve_elems *skel;
skel = test_pe_preserve_elems__open_and_load();
if (CHECK(!skel, "skel_open", "failed to open skeleton\n"))
return;
test_one_map(skel->maps.array_1, skel->progs.read_array_1, false);
test_one_map(skel->maps.array_2, skel->progs.re... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/pkt_md_access.c |
void test_pkt_md_access(void) {
const char *file = "./test_pkt_md_access.bpf.o";
struct bpf_object *obj;
int err, prog_fd;
LIBBPF_OPTS(bpf_test_run_opts, topts, .data_in = &pkt_v4,
.data_size_in = sizeof(pkt_v4), .repeat = 10, );
err = bpf_prog_test_load(file, BPF_PROG_TYPE_SCHED_CLS, &obj, &p... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/probe_read_user_str.c | void test_probe_read_user_str(void) {
struct test_probe_read_user_str *skel;
int err, duration = 0;
skel = test_probe_read_user_str__open_and_load();
if (CHECK(!skel, "test_probe_read_user_str__open_and_load",
"skeleton open and load failed\n"))
return;
skel->bss->pid = getpid();
err = te... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/prog_array_init.c |
void test_prog_array_init(void) {
struct test_prog_array_init *skel;
int err;
skel = test_prog_array_init__open();
if (!ASSERT_OK_PTR(skel, "could not open BPF object"))
return;
skel->rodata->my_pid = getpid();
err = test_prog_array_init__load(skel);
if (!ASSERT_OK(err, "could not load BPF object"... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/bpf/prog_tests/queue_stack_map.c |
void test_queue_stack_map(void) {
test_queue_stack_map_by_type(QUEUE);
test_queue_stack_map_by_type(STACK);
} | [
0,
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.