/tools/testing/selftests/bpf/prog_tests/ |
D | lookup_and_delete.c | 13 static int fill_values(int map_fd) in fill_values() argument 19 err = bpf_map_update_elem(map_fd, &key, &value, BPF_NOEXIST); in fill_values() 27 static int fill_values_percpu(int map_fd) in fill_values_percpu() argument 36 err = bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST); in fill_values_percpu() 45 int *map_fd) in setup_prog() argument 66 *map_fd = bpf_map__fd(skel->maps.hash_map); in setup_prog() 67 if (!ASSERT_GE(*map_fd, 0, "bpf_map__fd")) in setup_prog() 102 int map_fd, err; in test_lookup_and_delete_hash() local 105 skel = setup_prog(BPF_MAP_TYPE_HASH, &map_fd); in test_lookup_and_delete_hash() 109 err = fill_values(map_fd); in test_lookup_and_delete_hash() [all …]
|
D | l4lb_all.c | 27 int err, i, prog_fd, map_fd; in test_l4lb() local 37 map_fd = bpf_find_map(__func__, obj, "vip_map"); in test_l4lb() 38 if (map_fd < 0) in test_l4lb() 40 bpf_map_update_elem(map_fd, &key, &value, 0); in test_l4lb() 42 map_fd = bpf_find_map(__func__, obj, "ch_rings"); in test_l4lb() 43 if (map_fd < 0) in test_l4lb() 45 bpf_map_update_elem(map_fd, &ch_key, &real_num, 0); in test_l4lb() 47 map_fd = bpf_find_map(__func__, obj, "reals"); in test_l4lb() 48 if (map_fd < 0) in test_l4lb() 50 bpf_map_update_elem(map_fd, &real_num, &real_def, 0); in test_l4lb() [all …]
|
D | global_data.c | 7 int i, err, map_fd; in test_global_data_number() local 10 map_fd = bpf_find_map(__func__, obj, "result_number"); in test_global_data_number() 11 if (CHECK_FAIL(map_fd < 0)) in test_global_data_number() 33 err = bpf_map_lookup_elem(map_fd, &tests[i].key, &num); in test_global_data_number() 42 int i, err, map_fd; in test_global_data_string() local 45 map_fd = bpf_find_map(__func__, obj, "result_string"); in test_global_data_string() 46 if (CHECK_FAIL(map_fd < 0)) in test_global_data_string() 62 err = bpf_map_lookup_elem(map_fd, &tests[i].key, str); in test_global_data_string() 77 int i, err, map_fd; in test_global_data_struct() local 80 map_fd = bpf_find_map(__func__, obj, "result_struct"); in test_global_data_struct() [all …]
|
D | map_init.c | 20 static int map_populate(int map_fd, int num) in map_populate() argument 30 err = bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST); in map_populate() 39 int *map_fd, int populate) in setup() argument 60 *map_fd = bpf_map__fd(skel->maps.hashmap1); in setup() 61 if (CHECK(*map_fd < 0, "bpf_map__fd", "failed\n")) in setup() 64 err = map_populate(*map_fd, populate); in setup() 71 close(*map_fd); in setup() 133 int map_fd, err; in test_pcpu_map_init() local 137 skel = setup(BPF_MAP_TYPE_PERCPU_HASH, 1, &map_fd, 1); in test_pcpu_map_init() 143 err = bpf_map_delete_elem(map_fd, &key); in test_pcpu_map_init() [all …]
|
D | map_lock.c | 20 int err, map_fd = *(u32 *) arg; in parallel_map_access() local 24 err = bpf_map_lookup_elem_flags(map_fd, &key, vars, BPF_F_LOCK); in parallel_map_access() 50 int prog_fd, map_fd[2], vars[17] = {}; in test_map_lock() local 61 map_fd[0] = bpf_find_map(__func__, obj, "hash_map"); in test_map_lock() 62 if (CHECK_FAIL(map_fd[0] < 0)) in test_map_lock() 64 map_fd[1] = bpf_find_map(__func__, obj, "array_map"); in test_map_lock() 65 if (CHECK_FAIL(map_fd[1] < 0)) in test_map_lock() 68 bpf_map_update_elem(map_fd[0], &key, vars, BPF_F_LOCK); in test_map_lock() 77 &map_fd[i - 4]))) in test_map_lock() 85 ret != (void *)&map_fd[i - 4])) in test_map_lock()
|
D | tailcalls.c | 11 int err, map_fd, prog_fd, main_fd, i, j; in test_tailcall_1() local 36 map_fd = bpf_map__fd(prog_array); in test_tailcall_1() 37 if (CHECK_FAIL(map_fd < 0)) in test_tailcall_1() 51 err = bpf_map_update_elem(map_fd, &i, &prog_fd, BPF_ANY); in test_tailcall_1() 62 err = bpf_map_delete_elem(map_fd, &i); in test_tailcall_1() 83 err = bpf_map_update_elem(map_fd, &i, &prog_fd, BPF_ANY); in test_tailcall_1() 105 err = bpf_map_update_elem(map_fd, &i, &prog_fd, BPF_ANY); in test_tailcall_1() 118 err = bpf_map_delete_elem(map_fd, &i); in test_tailcall_1() 129 err = bpf_map_delete_elem(map_fd, &i); in test_tailcall_1() 149 int err, map_fd, prog_fd, main_fd, i; in test_tailcall_2() local [all …]
|
D | syscall.c | 10 int map_fd; member 39 ASSERT_GT(ctx.map_fd, 0, "ctx.map_fd"); in test_syscall() 44 err = bpf_map_lookup_elem(ctx.map_fd, &key, &value); in test_syscall() 51 if (ctx.map_fd > 0) in test_syscall() 52 close(ctx.map_fd); in test_syscall()
|
D | xdp.c | 17 int err, prog_fd, map_fd; in test_xdp() local 23 map_fd = bpf_find_map(__func__, obj, "vip2tnl"); in test_xdp() 24 if (map_fd < 0) in test_xdp() 26 bpf_map_update_elem(map_fd, &key4, &value4, 0); in test_xdp() 27 bpf_map_update_elem(map_fd, &key6, &value6, 0); in test_xdp()
|
D | xdp_cpumap_attach.c | 18 int err, prog_fd, map_fd; in test_xdp_cpumap_attach() local 34 map_fd = bpf_map__fd(skel->maps.cpu_map); in test_xdp_cpumap_attach() 40 err = bpf_map_update_elem(map_fd, &idx, &val, 0); in test_xdp_cpumap_attach() 43 err = bpf_map_lookup_elem(map_fd, &idx, &val); in test_xdp_cpumap_attach() 54 err = bpf_map_update_elem(map_fd, &idx, &val, 0); in test_xdp_cpumap_attach()
|
D | cgroup_attach_multi.c | 11 static int map_fd = -1; variable 17 if (map_fd < 0) in prog_load_cnt() 18 map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, 4, 8, 1, 0); in prog_load_cnt() 19 if (map_fd < 0) { in prog_load_cnt() 44 BPF_LD_MAP_FD(BPF_REG_1, map_fd), in prog_load_cnt() 151 CHECK_FAIL(bpf_map_lookup_elem(map_fd, &key, &value)); in test_cgroup_attach_multi() 188 CHECK_FAIL(bpf_map_update_elem(map_fd, &key, &value, 0)); in test_cgroup_attach_multi() 190 CHECK_FAIL(bpf_map_lookup_elem(map_fd, &key, &value)); in test_cgroup_attach_multi() 241 CHECK_FAIL(bpf_map_update_elem(map_fd, &key, &value, 0)); in test_cgroup_attach_multi() 243 CHECK_FAIL(bpf_map_lookup_elem(map_fd, &key, &value)); in test_cgroup_attach_multi() [all …]
|
D | xdp_devmap_attach.c | 19 int err, dm_fd, map_fd; in test_xdp_with_devmap_helpers() local 36 map_fd = bpf_map__fd(skel->maps.dm_ports); in test_xdp_with_devmap_helpers() 42 err = bpf_map_update_elem(map_fd, &idx, &val, 0); in test_xdp_with_devmap_helpers() 45 err = bpf_map_lookup_elem(map_fd, &idx, &val); in test_xdp_with_devmap_helpers() 56 err = bpf_map_update_elem(map_fd, &idx, &val, 0); in test_xdp_with_devmap_helpers()
|
D | global_func_args.c | 9 int err, i, map_fd, actual_value; in test_global_func_args0() local 12 map_fd = bpf_find_map(__func__, obj, map_name); in test_global_func_args0() 13 if (CHECK(map_fd < 0, "bpf_find_map", "cannot find BPF map %s: %s\n", in test_global_func_args0() 33 err = bpf_map_lookup_elem(map_fd, &i, &actual_value); in test_global_func_args0()
|
D | load_bytes_relative.c | 12 int server_fd, cgroup_fd, prog_fd, map_fd, client_fd; in test_load_bytes_relative() local 39 map_fd = bpf_map__fd(test_result); in test_load_bytes_relative() 40 if (map_fd < 0) in test_load_bytes_relative() 57 err = bpf_map_lookup_elem(map_fd, &map_key, &map_value); in test_load_bytes_relative()
|
D | tcp_rtt.c | 46 static int verify_sk(int map_fd, int client_fd, const char *msg, __u32 invoked, in verify_sk() argument 53 if (CHECK_FAIL(bpf_map_lookup_elem(map_fd, &client_fd, &val) < 0)) { in verify_sk() 103 int map_fd; in run_test() local 113 map_fd = bpf_map__fd(map); in run_test() 127 err += verify_sk(map_fd, client_fd, "syn-ack", in run_test() 141 err += verify_sk(map_fd, client_fd, "first payload byte", in run_test()
|
D | bpf_iter.c | 597 int err, i, len, map_fd, iter_fd; in test_bpf_hash_map() local 622 linfo.map.map_fd = bpf_map__fd(skel->maps.hashmap2); in test_bpf_hash_map() 629 linfo.map.map_fd = bpf_map__fd(skel->maps.hashmap3); in test_bpf_hash_map() 635 map_fd = bpf_map__fd(skel->maps.hashmap1); in test_bpf_hash_map() 646 err = bpf_map_update_elem(map_fd, &key, &val, BPF_ANY); in test_bpf_hash_map() 651 linfo.map.map_fd = map_fd; in test_bpf_hash_map() 693 int err, i, j, len, map_fd, iter_fd; in test_bpf_percpu_hash_map() local 720 map_fd = bpf_map__fd(skel->maps.hashmap1); in test_bpf_percpu_hash_map() 734 err = bpf_map_update_elem(map_fd, &key, val, BPF_ANY); in test_bpf_percpu_hash_map() 740 linfo.map.map_fd = map_fd; in test_bpf_percpu_hash_map() [all …]
|
/tools/testing/selftests/bpf/map_tests/ |
D | sk_storage_map.c | 148 int btf_fd, map_fd; in create_sk_storage_map() local 155 map_fd = bpf_create_map_xattr(&xattr); in create_sk_storage_map() 158 CHECK(map_fd == -1, in create_sk_storage_map() 161 return map_fd; in create_sk_storage_map() 170 int i, map_fd, err, *sk_fds; in insert_close_thread() local 185 map_fd = READ_ONCE(sk_storage_map); in insert_close_thread() 193 err = bpf_map_update_elem(map_fd, &sk_fds[i], &value, in insert_close_thread() 229 int i, map_fd = -1, err = 0, nr_threads_created = 0; in do_sk_storage_map_stress_free() local 250 map_fd = create_sk_storage_map(); in do_sk_storage_map_stress_free() 251 WRITE_ONCE(sk_storage_map, map_fd); in do_sk_storage_map_stress_free() [all …]
|
D | htab_map_batch_ops.c | 13 static void map_batch_update(int map_fd, __u32 max_entries, int *keys, in map_batch_update() argument 36 err = bpf_map_update_batch(map_fd, keys, values, &max_entries, &opts); in map_batch_update() 80 int map_fd, *keys, *visited, key; in __test_map_lookup_and_delete_batch() local 99 map_fd = bpf_create_map_xattr(&xattr); in __test_map_lookup_and_delete_batch() 100 CHECK(map_fd == -1, in __test_map_lookup_and_delete_batch() 115 err = bpf_map_lookup_and_delete_batch(map_fd, NULL, &batch, keys, in __test_map_lookup_and_delete_batch() 121 map_batch_update(map_fd, max_entries, keys, values, is_pcpu); in __test_map_lookup_and_delete_batch() 125 err = bpf_map_lookup_and_delete_batch(map_fd, NULL, &batch, keys, in __test_map_lookup_and_delete_batch() 133 err = bpf_map_lookup_and_delete_batch(map_fd, NULL, &batch, keys, in __test_map_lookup_and_delete_batch() 142 err = bpf_map_get_next_key(map_fd, NULL, &key); in __test_map_lookup_and_delete_batch() [all …]
|
D | lpm_trie_map_batch_ops.c | 21 static void map_batch_update(int map_fd, __u32 max_entries, in map_batch_update() argument 39 err = bpf_map_update_batch(map_fd, keys, values, &max_entries, &opts); in map_batch_update() 75 int map_fd, *values, *visited; in test_lpm_trie_map_batch_ops() local 86 map_fd = bpf_create_map_xattr(&xattr); in test_lpm_trie_map_batch_ops() 87 CHECK(map_fd == -1, "bpf_create_map_xattr()", "error:%s\n", in test_lpm_trie_map_batch_ops() 98 map_batch_update(map_fd, max_entries, keys, values); in test_lpm_trie_map_batch_ops() 109 err = bpf_map_lookup_batch(map_fd, in test_lpm_trie_map_batch_ops() 131 err = bpf_map_delete_batch(map_fd, keys + total, &count, in test_lpm_trie_map_batch_ops() 143 err = bpf_map_get_next_key(map_fd, NULL, &key); in test_lpm_trie_map_batch_ops()
|
/tools/testing/selftests/bpf/ |
D | test_lpm_map.c | 428 int map_fd; in test_lpm_delete() local 434 map_fd = bpf_create_map(BPF_MAP_TYPE_LPM_TRIE, in test_lpm_delete() 437 assert(map_fd >= 0); in test_lpm_delete() 454 assert(bpf_map_update_elem(map_fd, key, &value, 0) == 0); in test_lpm_delete() 459 assert(bpf_map_update_elem(map_fd, key, &value, 0) == 0); in test_lpm_delete() 464 assert(bpf_map_update_elem(map_fd, key, &value, 0) == 0); in test_lpm_delete() 469 assert(bpf_map_update_elem(map_fd, key, &value, 0) == 0); in test_lpm_delete() 474 assert(bpf_map_lookup_elem(map_fd, key, &value) == -1 && in test_lpm_delete() 479 assert(bpf_map_delete_elem(map_fd, key) == -1 && in test_lpm_delete() 484 assert(bpf_map_delete_elem(map_fd, key) == -1 && in test_lpm_delete() [all …]
|
D | test_skb_cgroup_id_user.c | 86 int map_fd = -1; in get_map_fd_by_prog_id() local 107 map_fd = bpf_map_get_fd_by_id(map_ids[0]); in get_map_fd_by_prog_id() 108 if (map_fd < 0) in get_map_fd_by_prog_id() 113 return map_fd; in get_map_fd_by_prog_id() 121 int map_fd; in check_ancestor_cgroup_ids() local 128 map_fd = get_map_fd_by_prog_id(prog_id); in check_ancestor_cgroup_ids() 129 if (map_fd < 0) in check_ancestor_cgroup_ids() 133 if (bpf_map_lookup_elem(map_fd, &level, &actual_ids[level])) { in check_ancestor_cgroup_ids() 148 if (map_fd >= 0) in check_ancestor_cgroup_ids() 149 close(map_fd); in check_ancestor_cgroup_ids()
|
D | test_cgroup_storage.c | 40 int map_fd, percpu_map_fd, prog_fd, cgroup_fd; in main() local 53 map_fd = bpf_create_map(BPF_MAP_TYPE_CGROUP_STORAGE, sizeof(key), in main() 55 if (map_fd < 0) { in main() 68 prog[7].imm = map_fd; in main() 85 if (bpf_map_get_next_key(map_fd, NULL, &key)) { in main() 90 if (bpf_map_lookup_elem(map_fd, &key, &value)) { in main() 109 if (bpf_map_lookup_elem(map_fd, &key, &value)) { in main() 121 if (bpf_map_update_elem(map_fd, &key, &value, 0)) { in main() 132 if (bpf_map_lookup_elem(map_fd, &key, &value)) { in main()
|
D | xdping.c | 96 int prog_fd = -1, map_fd = -1; in main() local 192 map_fd = bpf_map__fd(map); in main() 193 if (!map || map_fd < 0) { in main() 212 close(map_fd); in main() 227 if (bpf_map_update_elem(map_fd, &raddr, &pinginfo, BPF_ANY)) { in main() 246 ret = get_stats(map_fd, count, raddr); in main() 253 if (map_fd > 0) in main() 254 close(map_fd); in main()
|
/tools/bpf/bpftool/ |
D | iter.c | 19 int err = -1, map_fd = -1; in do_pin() local 37 map_fd = map_parse_fd(&argc, &argv); in do_pin() 38 if (map_fd < 0) in do_pin() 42 linfo.map.map_fd = map_fd; in do_pin() 90 if (map_fd >= 0) in do_pin() 91 close(map_fd); in do_pin()
|
/tools/lib/bpf/ |
D | skel_internal.h | 26 int map_fd; member 65 int map_fd = -1, prog_fd = -1, key = 0, err; in bpf_load_and_run() local 68 map_fd = bpf_create_map_name(BPF_MAP_TYPE_ARRAY, "__loader.map", 4, in bpf_load_and_run() 70 if (map_fd < 0) { in bpf_load_and_run() 76 err = bpf_map_update_elem(map_fd, &key, opts->data, 0); in bpf_load_and_run() 89 attr.fd_array = (long) &map_fd; in bpf_load_and_run() 118 if (map_fd >= 0) in bpf_load_and_run() 119 close(map_fd); in bpf_load_and_run()
|
D | ringbuf.c | 31 int map_fd; member 55 int ring_buffer__add(struct ring_buffer *rb, int map_fd, in ring_buffer__add() argument 68 err = bpf_obj_get_info_by_fd(map_fd, &info, &len); in ring_buffer__add() 72 map_fd, err); in ring_buffer__add() 78 map_fd); in ring_buffer__add() 95 r->map_fd = map_fd; in ring_buffer__add() 101 tmp = mmap(NULL, rb->page_size, PROT_READ | PROT_WRITE, MAP_SHARED, map_fd, 0); in ring_buffer__add() 105 map_fd, err); in ring_buffer__add() 119 tmp = mmap(NULL, (size_t)mmap_sz, PROT_READ, MAP_SHARED, map_fd, rb->page_size); in ring_buffer__add() 124 map_fd, err); in ring_buffer__add() [all …]
|