Home
last modified time | relevance | path

Searched refs:map_fd (Results 1 – 25 of 64) sorted by relevance

123

/Linux-v5.4/tools/testing/selftests/bpf/map_tests/
Dsk_storage_map.c148 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 …]
/Linux-v5.4/samples/bpf/
Dtest_lru_dist.c102 int map_fd; member
108 lru->map_fd = bpf_create_map(BPF_MAP_TYPE_HASH, in pfect_lru_init()
112 assert(lru->map_fd != -1); in pfect_lru_init()
125 close(lru->map_fd); in pfect_lru_destroy()
136 if (!bpf_map_lookup_elem(lru->map_fd, &key, &node)) { in pfect_lru_lookup_or_insert()
153 bpf_map_update_elem(lru->map_fd, &node->key, &null_node, BPF_EXIST); in pfect_lru_lookup_or_insert()
161 assert(!bpf_map_update_elem(lru->map_fd, &key, &node, BPF_EXIST)); in pfect_lru_lookup_or_insert()
164 assert(!bpf_map_update_elem(lru->map_fd, &key, &node, BPF_NOEXIST)); in pfect_lru_lookup_or_insert()
210 int map_fd; in create_map() local
212 map_fd = bpf_create_map(map_type, sizeof(unsigned long long), in create_map()
[all …]
Dtest_cgrp2_attach.c42 static int prog_load(int map_fd, int verdict) in prog_load() argument
52 BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* load map fd to r1 */ in prog_load()
63 BPF_LD_MAP_FD(BPF_REG_1, map_fd), in prog_load()
89 int prog_fd, map_fd, ret, key; in attach_filter() local
92 map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, in attach_filter()
95 if (map_fd < 0) { in attach_filter()
100 prog_fd = prog_load(map_fd, verdict); in attach_filter()
116 assert(bpf_map_lookup_elem(map_fd, &key, &pkt_cnt) == 0); in attach_filter()
119 assert(bpf_map_lookup_elem(map_fd, &key, &byte_cnt) == 0); in attach_filter()
Dsock_example.c37 int sock = -1, map_fd, prog_fd, i, key; in test_sock() local
40 map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value), in test_sock()
42 if (map_fd < 0) { in test_sock()
53 BPF_LD_MAP_FD(BPF_REG_1, map_fd), in test_sock()
80 assert(bpf_map_lookup_elem(map_fd, &key, &tcp_cnt) == 0); in test_sock()
83 assert(bpf_map_lookup_elem(map_fd, &key, &udp_cnt) == 0); in test_sock()
86 assert(bpf_map_lookup_elem(map_fd, &key, &icmp_cnt) == 0); in test_sock()
Dxdp_fwd_user.c30 static int do_attach(int idx, int prog_fd, int map_fd, const char *name) in do_attach() argument
41 err = bpf_map_update_elem(map_fd, &idx, &idx, 0); in do_attach()
79 int prog_fd, map_fd = -1; in main() local
130 map_fd = bpf_map__fd(bpf_object__find_map_by_name(obj, in main()
132 if (map_fd < 0) { in main()
133 printf("map not found: %s\n", strerror(map_fd)); in main()
152 err = do_attach(idx, prog_fd, map_fd, argv[i]); in main()
Dlwt_len_hist_user.c38 int i, map_fd; in main() local
40 map_fd = bpf_obj_get(map_filename); in main()
41 if (map_fd < 0) { in main()
47 while (bpf_map_get_next_key(map_fd, &key, &next_key) == 0) { in main()
53 bpf_map_lookup_elem(map_fd, &next_key, values); in main()
76 close(map_fd); in main()
Dsockex1_user.c14 int map_fd, prog_fd; in main() local
25 map_fd = bpf_object__find_map_fd_by_name(obj, "my_map"); in main()
40 assert(bpf_map_lookup_elem(map_fd, &key, &tcp_cnt) == 0); in main()
43 assert(bpf_map_lookup_elem(map_fd, &key, &udp_cnt) == 0); in main()
46 assert(bpf_map_lookup_elem(map_fd, &key, &icmp_cnt) == 0); in main()
Dhbm.c129 int map_fd; in prog_load() local
142 map_fd = bpf_map__fd(map); in prog_load()
143 if (map_fd < 0) { in prog_load()
144 printf("Map not found: %s\n", strerror(map_fd)); in prog_load()
154 ret = map_fd; in prog_load()
162 int map_fd; in run_bpf_prog() local
171 map_fd = prog_load(prog); in run_bpf_prog()
172 if (map_fd == -1) in run_bpf_prog()
193 if (bpf_map_update_elem(map_fd, &key, &qstats, BPF_ANY)) { in run_bpf_prog()
216 bpf_map_lookup_elem(map_fd, &key, &qstats); in run_bpf_prog()
[all …]
Dtest_map_in_map_user.c16 #define PORT_A (map_fd[0])
17 #define PORT_H (map_fd[1])
18 #define REG_RESULT_H (map_fd[2])
19 #define INLINE_RESULT_H (map_fd[3])
20 #define A_OF_PORT_A (map_fd[4]) /* Test case #0 */
21 #define H_OF_PORT_A (map_fd[5]) /* Test case #1 */
22 #define H_OF_PORT_H (map_fd[6]) /* Test case #2 */
Dcookie_uid_helper_example.c64 static int map_fd, prog_fd; variable
70 map_fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(uint32_t), in maps_create()
72 if (map_fd < 0) in maps_create()
100 BPF_LD_MAP_FD(BPF_REG_1, map_fd), in prog_load()
135 BPF_LD_MAP_FD(BPF_REG_1, map_fd), in prog_load()
194 while (bpf_map_get_next_key(map_fd, &curN, &nextN) > -1) { in print_table()
196 res = bpf_map_lookup_elem(map_fd, &curN, &curEntry); in print_table()
236 res = bpf_map_lookup_elem(map_fd, &cookie, &dataEntry); in udp_client()
255 res = bpf_map_lookup_elem(map_fd, &cookie, &dataEntry); in udp_client()
321 close(map_fd); in main()
Dxdp1_user.c44 static void poll_stats(int map_fd, int interval) in poll_stats() argument
55 while (bpf_map_get_next_key(map_fd, &key, &key) != -1) { in poll_stats()
58 assert(bpf_map_lookup_elem(map_fd, &key, values) == 0); in poll_stats()
89 int prog_fd, map_fd, opt; in main() local
139 map_fd = bpf_map__fd(map); in main()
161 poll_stats(map_fd, 2); in main()
Dspintest_user.c36 while (bpf_map_get_next_key(map_fd[0], &key, &next_key) == 0) { in main()
37 bpf_map_lookup_elem(map_fd[0], &next_key, &value); in main()
51 while (bpf_map_get_next_key(map_fd[0], &key, &next_key) == 0) in main()
52 bpf_map_delete_elem(map_fd[0], &next_key); in main()
Dsockex2_user.c21 int map_fd, prog_fd; in main() local
33 map_fd = bpf_object__find_map_fd_by_name(obj, "hash_map"); in main()
47 while (bpf_map_get_next_key(map_fd, &key, &next_key) == 0) { in main()
48 bpf_map_lookup_elem(map_fd, &next_key, &value); in main()
Dtest_current_task_under_cgroup_user.c35 if (bpf_map_update_elem(map_fd[0], &idx, &cg2, BPF_ANY)) { in main()
49 bpf_map_lookup_elem(map_fd[1], &idx, &remote_pid); in main()
63 bpf_map_update_elem(map_fd[1], &idx, &remote_pid, BPF_ANY); in main()
66 bpf_map_lookup_elem(map_fd[1], &idx, &remote_pid); in main()
Dtracex6_user.c42 assert(bpf_map_update_elem(map_fd[0], &cpu, &pmu_fd, BPF_ANY) == 0); in check_on_cpu()
45 bpf_map_get_next_key(map_fd[1], &cpu, NULL); in check_on_cpu()
47 if (bpf_map_lookup_elem(map_fd[1], &cpu, &value)) { in check_on_cpu()
55 if (bpf_map_lookup_elem(map_fd[2], &cpu, &value2)) { in check_on_cpu()
65 assert(bpf_map_delete_elem(map_fd[0], &cpu) == 0 || error); in check_on_cpu()
68 assert(bpf_map_delete_elem(map_fd[1], &cpu) == 0 || error); in check_on_cpu()
/Linux-v5.4/tools/testing/selftests/bpf/
Dtest_lpm_map.c428 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 …]
Dtest_skb_cgroup_id_user.c86 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()
Dtest_cgroup_storage.c40 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()
100 if (bpf_map_get_next_key(map_fd, NULL, &key)) { in main()
105 if (bpf_map_lookup_elem(map_fd, &key, &value)) { in main()
124 if (bpf_map_lookup_elem(map_fd, &key, &value)) { in main()
136 if (bpf_map_update_elem(map_fd, &key, &value, 0)) { in main()
147 if (bpf_map_lookup_elem(map_fd, &key, &value)) { in main()
Dxdping.c96 int prog_fd = -1, map_fd = -1; in main() local
193 map_fd = bpf_map__fd(map); in main()
194 if (!map || map_fd < 0) { in main()
213 close(map_fd); in main()
228 if (bpf_map_update_elem(map_fd, &raddr, &pinginfo, BPF_ANY)) { in main()
247 ret = get_stats(map_fd, count, raddr); in main()
254 if (map_fd > 0) in main()
255 close(map_fd); in main()
Dtest_netcnt.c38 int map_fd, percpu_map_fd; in main() local
95 map_fd = bpf_find_map(__func__, obj, "netcnt"); in main()
96 if (map_fd < 0) { in main()
107 if (bpf_map_get_next_key(map_fd, NULL, &key)) { in main()
112 if (bpf_map_lookup_elem(map_fd, &key, &netcnt)) { in main()
/Linux-v5.4/tools/testing/selftests/bpf/prog_tests/
Dglobal_data.c6 int i, err, map_fd; in test_global_data_number() local
9 map_fd = bpf_find_map(__func__, obj, "result_number"); in test_global_data_number()
10 if (CHECK_FAIL(map_fd < 0)) in test_global_data_number()
32 err = bpf_map_lookup_elem(map_fd, &tests[i].key, &num); in test_global_data_number()
41 int i, err, map_fd; in test_global_data_string() local
44 map_fd = bpf_find_map(__func__, obj, "result_string"); in test_global_data_string()
45 if (CHECK_FAIL(map_fd < 0)) in test_global_data_string()
61 err = bpf_map_lookup_elem(map_fd, &tests[i].key, str); in test_global_data_string()
76 int i, err, map_fd; in test_global_data_struct() local
79 map_fd = bpf_find_map(__func__, obj, "result_struct"); in test_global_data_struct()
[all …]
Dl4lb_all.c26 int err, i, prog_fd, map_fd; in test_l4lb() local
36 map_fd = bpf_find_map(__func__, obj, "vip_map"); in test_l4lb()
37 if (map_fd < 0) in test_l4lb()
39 bpf_map_update_elem(map_fd, &key, &value, 0); in test_l4lb()
41 map_fd = bpf_find_map(__func__, obj, "ch_rings"); in test_l4lb()
42 if (map_fd < 0) in test_l4lb()
44 bpf_map_update_elem(map_fd, &ch_key, &real_num, 0); in test_l4lb()
46 map_fd = bpf_find_map(__func__, obj, "reals"); in test_l4lb()
47 if (map_fd < 0) in test_l4lb()
49 bpf_map_update_elem(map_fd, &real_num, &real_def, 0); in test_l4lb()
[all …]
Dxdp_noinline.c27 int err, i, prog_fd, map_fd; in test_xdp_noinline() local
37 map_fd = bpf_find_map(__func__, obj, "vip_map"); in test_xdp_noinline()
38 if (map_fd < 0) in test_xdp_noinline()
40 bpf_map_update_elem(map_fd, &key, &value, 0); in test_xdp_noinline()
42 map_fd = bpf_find_map(__func__, obj, "ch_rings"); in test_xdp_noinline()
43 if (map_fd < 0) in test_xdp_noinline()
45 bpf_map_update_elem(map_fd, &ch_key, &real_num, 0); in test_xdp_noinline()
47 map_fd = bpf_find_map(__func__, obj, "reals"); in test_xdp_noinline()
48 if (map_fd < 0) in test_xdp_noinline()
50 bpf_map_update_elem(map_fd, &real_num, &real_def, 0); in test_xdp_noinline()
[all …]
Dmap_lock.c6 int err, map_fd = *(u32 *) arg; in parallel_map_access() local
10 err = bpf_map_lookup_elem_flags(map_fd, &key, vars, BPF_F_LOCK); in parallel_map_access()
36 int prog_fd, map_fd[2], vars[17] = {}; in test_map_lock() local
47 map_fd[0] = bpf_find_map(__func__, obj, "hash_map"); in test_map_lock()
48 if (CHECK_FAIL(map_fd[0] < 0)) in test_map_lock()
50 map_fd[1] = bpf_find_map(__func__, obj, "array_map"); in test_map_lock()
51 if (CHECK_FAIL(map_fd[1] < 0)) in test_map_lock()
54 bpf_map_update_elem(map_fd[0], &key, vars, BPF_F_LOCK); in test_map_lock()
63 &map_fd[i - 4]))) in test_map_lock()
71 ret != (void *)&map_fd[i - 4])) in test_map_lock()
Dxdp.c16 int err, prog_fd, map_fd; in test_xdp() local
22 map_fd = bpf_find_map(__func__, obj, "vip2tnl"); in test_xdp()
23 if (map_fd < 0) in test_xdp()
25 bpf_map_update_elem(map_fd, &key4, &value4, 0); in test_xdp()
26 bpf_map_update_elem(map_fd, &key6, &value6, 0); in test_xdp()

123