Home
last modified time | relevance | path

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

123

/Linux-v4.19/samples/bpf/
Dtest_lru_dist.c105 int map_fd; member
111 lru->map_fd = bpf_create_map(BPF_MAP_TYPE_HASH, in pfect_lru_init()
115 assert(lru->map_fd != -1); in pfect_lru_init()
128 close(lru->map_fd); in pfect_lru_destroy()
139 if (!bpf_map_lookup_elem(lru->map_fd, &key, &node)) { in pfect_lru_lookup_or_insert()
156 bpf_map_update_elem(lru->map_fd, &node->key, &null_node, BPF_EXIST); in pfect_lru_lookup_or_insert()
164 assert(!bpf_map_update_elem(lru->map_fd, &key, &node, BPF_EXIST)); in pfect_lru_lookup_or_insert()
167 assert(!bpf_map_update_elem(lru->map_fd, &key, &node, BPF_NOEXIST)); in pfect_lru_lookup_or_insert()
213 int map_fd; in create_map() local
215 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()
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()
Dtest_map_in_map_user.c19 #define PORT_A (map_fd[0])
20 #define PORT_H (map_fd[1])
21 #define REG_RESULT_H (map_fd[2])
22 #define INLINE_RESULT_H (map_fd[3])
23 #define A_OF_PORT_A (map_fd[4]) /* Test case #0 */
24 #define H_OF_PORT_A (map_fd[5]) /* Test case #1 */
25 #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()
Dtest_cgrp2_attach2.c208 static int map_fd = -1; variable
214 if (map_fd < 0) in prog_load_cnt()
215 map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, 4, 8, 1, 0); in prog_load_cnt()
216 if (map_fd < 0) { in prog_load_cnt()
233 BPF_LD_MAP_FD(BPF_REG_1, map_fd), in prog_load_cnt()
337 assert(bpf_map_lookup_elem(map_fd, &key, &value) == 0); in test_multiprog()
372 assert(bpf_map_update_elem(map_fd, &key, &value, 0) == 0); in test_multiprog()
374 assert(bpf_map_lookup_elem(map_fd, &key, &value) == 0); in test_multiprog()
388 assert(bpf_map_update_elem(map_fd, &key, &value, 0) == 0); in test_multiprog()
390 assert(bpf_map_lookup_elem(map_fd, &key, &value) == 0); in test_multiprog()
[all …]
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()
46 while (bpf_map_get_next_key(map_fd[0], &key, &next_key) == 0) in main()
47 bpf_map_delete_elem(map_fd[0], &next_key); in main()
Dtest_current_task_under_cgroup_user.c39 if (bpf_map_update_elem(map_fd[0], &idx, &cg2, BPF_ANY)) { in main()
53 bpf_map_lookup_elem(map_fd[1], &idx, &remote_pid); in main()
67 bpf_map_update_elem(map_fd[1], &idx, &remote_pid, BPF_ANY); in main()
70 bpf_map_lookup_elem(map_fd[1], &idx, &remote_pid); in main()
Dxdp1_user.c34 static void poll_stats(int map_fd, int interval) in poll_stats() argument
50 assert(bpf_map_lookup_elem(map_fd, &key, values) == 0); in poll_stats()
78 int prog_fd, map_fd, opt; in main() local
120 map_fd = bpf_map__fd(map); in main()
135 poll_stats(map_fd, 2); in main()
Dxdp_fwd_user.c73 int prog_fd, map_fd; in main() local
115 map_fd = bpf_map__fd(bpf_object__find_map_by_name(obj, in main()
117 if (map_fd < 0) { in main()
118 printf("map not found: %s\n", strerror(map_fd)); in main()
124 bpf_map_update_elem(map_fd, &i, &i, 0); in main()
Dxdp_redirect_map_user.c56 assert(bpf_map_lookup_elem(map_fd[1], &key, values) == 0); in poll_stats()
139 map_fd[0], map_fd[1], map_fd[2]); in main()
142 ret = bpf_map_update_elem(map_fd[0], &key, &ifindex_out, 0); in main()
Dxdp_adjust_tail_user.c38 static void poll_stats(unsigned int map_fd, unsigned int kill_after_s) in poll_stats() argument
48 assert(bpf_map_lookup_elem(map_fd, &key, &value) == 0); in poll_stats()
75 int i, prog_fd, map_fd, opt; in main() local
130 map_fd = bpf_map__fd(map); in main()
145 poll_stats(map_fd, kill_after_s); 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()
Dsyscall_tp_user.c62 printf("prog #%d: map ids %d %d\n", i, map_fd[0], map_fd[1]); in test()
63 map0_fds[i] = map_fd[0]; in test()
64 map1_fds[i] = map_fd[1]; in test()
Dxdp_sample_pkts_user.c71 static void test_bpf_perf_event(int map_fd, int num) in test_bpf_perf_event() argument
88 assert(bpf_map_update_elem(map_fd, &key, in test_bpf_perf_event()
107 int prog_fd, map_fd; in main() local
137 map_fd = bpf_map__fd(map); in main()
159 test_bpf_perf_event(map_fd, numcpus); in main()
Doffwaketime_user.c53 if (bpf_map_lookup_elem(map_fd[3], &key->tret, ip) != 0) { in print_stack()
60 if (bpf_map_lookup_elem(map_fd[3], &key->wret, ip) != 0) { in print_stack()
90 print_stacks(map_fd[0]); in int_exit()
119 print_stacks(map_fd[0]); in main()
/Linux-v4.19/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()
480 assert(bpf_map_lookup_elem(map_fd, key, &value) == 0); in test_lpm_delete()
486 assert(bpf_map_delete_elem(map_fd, key) == 0); in test_lpm_delete()
[all …]
Dtest_cgroup_storage.c31 int map_fd, prog_fd, cgroup_fd; in main() local
35 map_fd = bpf_create_map(BPF_MAP_TYPE_CGROUP_STORAGE, sizeof(key), in main()
37 if (map_fd < 0) { in main()
42 prog[0].imm = map_fd; in main()
74 if (bpf_map_get_next_key(map_fd, NULL, &key)) { in main()
79 if (bpf_map_lookup_elem(map_fd, &key, &value)) { in main()
90 if (bpf_map_lookup_elem(map_fd, &key, &value)) { in main()
102 if (bpf_map_update_elem(map_fd, &key, &value, 0)) { in main()
113 if (bpf_map_lookup_elem(map_fd, &key, &value)) { in main()
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_lru_map.c32 int map_fd; in create_map() local
34 map_fd = bpf_create_map(map_type, sizeof(unsigned long long), in create_map()
37 if (map_fd == -1) in create_map()
40 return map_fd; in create_map()
492 static void do_test_lru_sanity5(unsigned long long last_key, int map_fd) in do_test_lru_sanity5() argument
497 assert(!bpf_map_lookup_elem(map_fd, &last_key, value)); in do_test_lru_sanity5()
502 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST)); in do_test_lru_sanity5()
503 assert(!bpf_map_lookup_elem(map_fd, &key, value)); in do_test_lru_sanity5()
506 assert(bpf_map_lookup_elem(map_fd, &last_key, value)); in do_test_lru_sanity5()
514 int map_fd; in test_lru_sanity5() local
[all …]
Dtest_maps.c1171 static void prepare_reuseport_grp(int type, int map_fd, in prepare_reuseport_grp() argument
1202 err = bpf_map_update_elem(map_fd, &index0, &fd64, in prepare_reuseport_grp()
1231 err = bpf_map_update_elem(map_fd, &index0, &fd64, in prepare_reuseport_grp()
1257 int map_fd, err, t, f; in test_reuseport_array() local
1261 map_fd = bpf_create_map(BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, in test_reuseport_array()
1263 CHECK(map_fd == -1, "reuseport array create", in test_reuseport_array()
1264 "map_fd:%d, errno:%d\n", map_fd, errno); in test_reuseport_array()
1267 err = bpf_map_delete_elem(map_fd, &bad_index); in test_reuseport_array()
1271 err = bpf_map_update_elem(map_fd, &bad_index, &fd64, BPF_ANY); in test_reuseport_array()
1276 err = bpf_map_lookup_elem(map_fd, &bad_index, &map_cookie); in test_reuseport_array()
[all …]
Dtest_progs.c139 int err, prog_fd, map_fd; in test_xdp() local
147 map_fd = bpf_find_map(__func__, obj, "vip2tnl"); in test_xdp()
148 if (map_fd < 0) in test_xdp()
150 bpf_map_update_elem(map_fd, &key4, &value4, 0); in test_xdp()
151 bpf_map_update_elem(map_fd, &key6, &value6, 0); in test_xdp()
228 int err, i, prog_fd, map_fd; in test_l4lb() local
240 map_fd = bpf_find_map(__func__, obj, "vip_map"); in test_l4lb()
241 if (map_fd < 0) in test_l4lb()
243 bpf_map_update_elem(map_fd, &key, &value, 0); in test_l4lb()
245 map_fd = bpf_find_map(__func__, obj, "ch_rings"); in test_l4lb()
[all …]
Dtest_sockmap.c59 int map_fd[8]; variable
629 err = bpf_prog_attach(prog_fd[0], map_fd[0], in run_options()
634 prog_fd[0], map_fd[0], err, strerror(errno)); in run_options()
638 err = bpf_prog_attach(prog_fd[1], map_fd[0], in run_options()
684 map_fd[1], BPF_SK_MSG_VERDICT, 0); in run_options()
692 err = bpf_map_update_elem(map_fd[1], &i, &c1, BPF_ANY); in run_options()
705 err = bpf_map_update_elem(map_fd[2], &i, &redir_fd, BPF_ANY); in run_options()
714 err = bpf_map_update_elem(map_fd[3], in run_options()
725 err = bpf_map_update_elem(map_fd[4], in run_options()
736 err = bpf_map_update_elem(map_fd[5], in run_options()
[all …]
/Linux-v4.19/tools/bpf/bpftool/
Dmap_perf_ring.c144 static int bpf_perf_event_open(int map_fd, int key, int cpu) in bpf_perf_event_open() argument
159 if (bpf_map_update_elem(map_fd, &key, &pmu_fd, BPF_ANY)) { in bpf_perf_event_open()
177 int i, nfds, map_fd, index = -1, cpu = -1; in do_event_pipe() local
187 map_fd = map_parse_fd_and_info(&argc, &argv, &map_info, &map_info_len); in do_event_pipe()
188 if (map_fd < 0) in do_event_pipe()
257 rings[i].fd = bpf_perf_event_open(map_fd, rings[i].key, in do_event_pipe()
293 close(map_fd); in do_event_pipe()
307 close(map_fd); in do_event_pipe()

123