• Home
  • Raw
  • Download

Lines Matching refs:fd

49 	int fd;  in test_hashmap()  local
51 fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value), in test_hashmap()
53 if (fd < 0) { in test_hashmap()
61 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); in test_hashmap()
65 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 && in test_hashmap()
70 assert(bpf_map_update_elem(fd, &key, &value, -1) == -1 && in test_hashmap()
74 assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && value == 1234); in test_hashmap()
78 assert(bpf_map_lookup_elem(fd, &key, &value) == -1 && errno == ENOENT); in test_hashmap()
81 assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == -1 && in test_hashmap()
86 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == 0); in test_hashmap()
92 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 && in test_hashmap()
97 assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == 0); in test_hashmap()
99 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); in test_hashmap()
101 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 && in test_hashmap()
106 assert(bpf_map_delete_elem(fd, &key) == -1 && errno == ENOENT); in test_hashmap()
109 assert(bpf_map_get_next_key(fd, NULL, &first_key) == 0 && in test_hashmap()
111 assert(bpf_map_get_next_key(fd, &key, &next_key) == 0 && in test_hashmap()
113 assert(bpf_map_get_next_key(fd, &next_key, &next_key) == 0 && in test_hashmap()
116 assert(bpf_map_get_next_key(fd, &next_key, &next_key) == -1 && in test_hashmap()
121 assert(bpf_map_delete_elem(fd, &key) == 0); in test_hashmap()
123 assert(bpf_map_delete_elem(fd, &key) == 0); in test_hashmap()
124 assert(bpf_map_delete_elem(fd, &key) == -1 && errno == ENOENT); in test_hashmap()
128 assert(bpf_map_get_next_key(fd, NULL, &next_key) == -1 && in test_hashmap()
130 assert(bpf_map_get_next_key(fd, &key, &next_key) == -1 && in test_hashmap()
133 close(fd); in test_hashmap()
138 int fd, i, j; in test_hashmap_sizes() local
142 fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j, in test_hashmap_sizes()
144 if (fd < 0) { in test_hashmap_sizes()
151 close(fd); in test_hashmap_sizes()
162 int fd, i; in test_hashmap_percpu() local
164 fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_HASH, sizeof(key), in test_hashmap_percpu()
166 if (fd < 0) { in test_hashmap_percpu()
177 assert(bpf_map_update_elem(fd, &key, value, BPF_ANY) == 0); in test_hashmap_percpu()
181 assert(bpf_map_update_elem(fd, &key, value, BPF_NOEXIST) == -1 && in test_hashmap_percpu()
186 assert(bpf_map_update_elem(fd, &key, value, -1) == -1 && in test_hashmap_percpu()
193 assert(bpf_map_lookup_elem(fd, &key, value) == 0 && in test_hashmap_percpu()
198 assert(bpf_map_lookup_elem(fd, &key, value) == -1 && errno == ENOENT); in test_hashmap_percpu()
201 assert(bpf_map_update_elem(fd, &key, value, BPF_EXIST) == -1 && in test_hashmap_percpu()
207 assert(bpf_map_update_elem(fd, &key, value, BPF_NOEXIST) == 0); in test_hashmap_percpu()
214 assert(bpf_map_update_elem(fd, &key, value, BPF_NOEXIST) == -1 && in test_hashmap_percpu()
218 assert(bpf_map_delete_elem(fd, &key) == -1 && errno == ENOENT); in test_hashmap_percpu()
221 assert(bpf_map_get_next_key(fd, NULL, &first_key) == 0 && in test_hashmap_percpu()
223 while (!bpf_map_get_next_key(fd, &key, &next_key)) { in test_hashmap_percpu()
231 assert(bpf_map_lookup_elem(fd, &next_key, value) == 0); in test_hashmap_percpu()
242 assert(bpf_map_update_elem(fd, &key, value, BPF_EXIST) == 0); in test_hashmap_percpu()
246 assert(bpf_map_delete_elem(fd, &key) == 0); in test_hashmap_percpu()
248 assert(bpf_map_delete_elem(fd, &key) == 0); in test_hashmap_percpu()
249 assert(bpf_map_delete_elem(fd, &key) == -1 && errno == ENOENT); in test_hashmap_percpu()
253 assert(bpf_map_get_next_key(fd, NULL, &next_key) == -1 && in test_hashmap_percpu()
255 assert(bpf_map_get_next_key(fd, &key, &next_key) == -1 && in test_hashmap_percpu()
258 close(fd); in test_hashmap_percpu()
263 int fd, i, max_entries = 1000; in test_hashmap_walk() local
267 fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value), in test_hashmap_walk()
269 if (fd < 0) { in test_hashmap_walk()
276 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == 0); in test_hashmap_walk()
279 for (i = 0; bpf_map_get_next_key(fd, !i ? NULL : &key, in test_hashmap_walk()
282 assert(bpf_map_lookup_elem(fd, &key, &value) == 0); in test_hashmap_walk()
287 assert(bpf_map_get_next_key(fd, NULL, &key) == 0); in test_hashmap_walk()
289 next_key_valid = bpf_map_get_next_key(fd, &key, &next_key) == 0; in test_hashmap_walk()
290 assert(bpf_map_lookup_elem(fd, &key, &value) == 0); in test_hashmap_walk()
292 assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == 0); in test_hashmap_walk()
298 for (i = 0; bpf_map_get_next_key(fd, !i ? NULL : &key, in test_hashmap_walk()
301 assert(bpf_map_lookup_elem(fd, &key, &value) == 0); in test_hashmap_walk()
306 close(fd); in test_hashmap_walk()
311 int key, next_key, fd; in test_arraymap() local
314 fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value), in test_arraymap()
316 if (fd < 0) { in test_arraymap()
324 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); in test_arraymap()
327 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 && in test_arraymap()
331 assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && value == 1234); in test_arraymap()
335 assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && value == 0); in test_arraymap()
341 assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == -1 && in test_arraymap()
345 assert(bpf_map_lookup_elem(fd, &key, &value) == -1 && errno == ENOENT); in test_arraymap()
348 assert(bpf_map_get_next_key(fd, NULL, &next_key) == 0 && in test_arraymap()
350 assert(bpf_map_get_next_key(fd, &key, &next_key) == 0 && in test_arraymap()
352 assert(bpf_map_get_next_key(fd, &next_key, &next_key) == 0 && in test_arraymap()
354 assert(bpf_map_get_next_key(fd, &next_key, &next_key) == -1 && in test_arraymap()
359 assert(bpf_map_delete_elem(fd, &key) == -1 && errno == EINVAL); in test_arraymap()
361 close(fd); in test_arraymap()
368 int key, next_key, fd, i; in test_arraymap_percpu() local
370 fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_ARRAY, sizeof(key), in test_arraymap_percpu()
372 if (fd < 0) { in test_arraymap_percpu()
382 assert(bpf_map_update_elem(fd, &key, values, BPF_ANY) == 0); in test_arraymap_percpu()
385 assert(bpf_map_update_elem(fd, &key, values, BPF_NOEXIST) == -1 && in test_arraymap_percpu()
389 assert(bpf_map_lookup_elem(fd, &key, values) == 0 && in test_arraymap_percpu()
394 assert(bpf_map_lookup_elem(fd, &key, values) == 0 && in test_arraymap_percpu()
400 assert(bpf_map_update_elem(fd, &key, values, BPF_EXIST) == -1 && in test_arraymap_percpu()
404 assert(bpf_map_lookup_elem(fd, &key, values) == -1 && errno == ENOENT); in test_arraymap_percpu()
407 assert(bpf_map_get_next_key(fd, NULL, &next_key) == 0 && in test_arraymap_percpu()
409 assert(bpf_map_get_next_key(fd, &key, &next_key) == 0 && in test_arraymap_percpu()
411 assert(bpf_map_get_next_key(fd, &next_key, &next_key) == 0 && in test_arraymap_percpu()
413 assert(bpf_map_get_next_key(fd, &next_key, &next_key) == -1 && in test_arraymap_percpu()
418 assert(bpf_map_delete_elem(fd, &key) == -1 && errno == EINVAL); in test_arraymap_percpu()
420 close(fd); in test_arraymap_percpu()
431 int key, fd, i; in test_arraymap_percpu_many_keys() local
433 fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_ARRAY, sizeof(key), in test_arraymap_percpu_many_keys()
435 if (fd < 0) { in test_arraymap_percpu_many_keys()
445 assert(bpf_map_update_elem(fd, &key, values, BPF_ANY) == 0); in test_arraymap_percpu_many_keys()
451 assert(bpf_map_lookup_elem(fd, &key, values) == 0); in test_arraymap_percpu_many_keys()
457 close(fd); in test_arraymap_percpu_many_keys()
462 int fd; in test_devmap() local
465 fd = bpf_create_map(BPF_MAP_TYPE_DEVMAP, sizeof(key), sizeof(value), in test_devmap()
467 if (fd < 0) { in test_devmap()
472 close(fd); in test_devmap()
479 int fd, i; in test_queuemap() local
486 fd = bpf_create_map(BPF_MAP_TYPE_QUEUE, 4, sizeof(val), MAP_SIZE, in test_queuemap()
488 assert(fd < 0 && errno == EINVAL); in test_queuemap()
490 fd = bpf_create_map(BPF_MAP_TYPE_QUEUE, 0, sizeof(val), MAP_SIZE, in test_queuemap()
494 assert(fd < 0 && errno == EINVAL); in test_queuemap()
497 if (fd < 0) { in test_queuemap()
504 assert(bpf_map_update_elem(fd, NULL, &vals[i], 0) == 0); in test_queuemap()
507 assert(bpf_map_update_elem(fd, NULL, &val, 0) == -1 && in test_queuemap()
511 assert(bpf_map_lookup_elem(fd, NULL, &val) == 0 && val == vals[0]); in test_queuemap()
515 assert(bpf_map_update_elem(fd, NULL, &vals[i], BPF_EXIST) == 0); in test_queuemap()
519 assert(bpf_map_lookup_and_delete_elem(fd, NULL, &val) == 0 && in test_queuemap()
523 assert(bpf_map_lookup_and_delete_elem(fd, NULL, &val) == -1 && in test_queuemap()
527 assert(bpf_map_delete_elem(fd, NULL) == -1 && errno == EINVAL); in test_queuemap()
528 assert(bpf_map_get_next_key(fd, NULL, NULL) == -1 && errno == EINVAL); in test_queuemap()
530 close(fd); in test_queuemap()
537 int fd, i; in test_stackmap() local
544 fd = bpf_create_map(BPF_MAP_TYPE_STACK, 4, sizeof(val), MAP_SIZE, in test_stackmap()
546 assert(fd < 0 && errno == EINVAL); in test_stackmap()
548 fd = bpf_create_map(BPF_MAP_TYPE_STACK, 0, sizeof(val), MAP_SIZE, in test_stackmap()
552 assert(fd < 0 && errno == EINVAL); in test_stackmap()
555 if (fd < 0) { in test_stackmap()
562 assert(bpf_map_update_elem(fd, NULL, &vals[i], 0) == 0); in test_stackmap()
565 assert(bpf_map_update_elem(fd, NULL, &val, 0) == -1 && in test_stackmap()
569 assert(bpf_map_lookup_elem(fd, NULL, &val) == 0 && val == vals[i - 1]); in test_stackmap()
573 assert(bpf_map_update_elem(fd, NULL, &vals[i], BPF_EXIST) == 0); in test_stackmap()
577 assert(bpf_map_lookup_and_delete_elem(fd, NULL, &val) == 0 && in test_stackmap()
581 assert(bpf_map_lookup_and_delete_elem(fd, NULL, &val) == -1 && in test_stackmap()
585 assert(bpf_map_delete_elem(fd, NULL) == -1 && errno == EINVAL); in test_stackmap()
586 assert(bpf_map_get_next_key(fd, NULL, NULL) == -1 && errno == EINVAL); in test_stackmap()
588 close(fd); in test_stackmap()
604 int err, i, fd, udp, sfd[6] = {0xdeadbeef}; in test_sockmap() local
679 fd = bpf_create_map(BPF_MAP_TYPE_SOCKMAP, in test_sockmap()
682 if (fd < 0) { in test_sockmap()
683 printf("Failed to create sockmap %i\n", fd); in test_sockmap()
690 err = bpf_map_update_elem(fd, &i, &udp, BPF_ANY); in test_sockmap()
699 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_ANY); in test_sockmap()
712 err = bpf_prog_attach(-1, fd, BPF_SK_SKB_STREAM_PARSER, 0); in test_sockmap()
718 err = bpf_prog_attach(-1, fd, BPF_SK_SKB_STREAM_VERDICT, 0); in test_sockmap()
724 err = bpf_prog_attach(-1, fd, BPF_SK_MSG_VERDICT, 0); in test_sockmap()
730 err = bpf_prog_attach(-1, fd, __MAX_BPF_ATTACH_TYPE, 0); in test_sockmap()
736 err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER); in test_sockmap()
742 err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT); in test_sockmap()
748 err = bpf_prog_detach(fd, BPF_SK_MSG_VERDICT); in test_sockmap()
754 err = bpf_prog_detach(fd, __MAX_BPF_ATTACH_TYPE); in test_sockmap()
950 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_NOEXIST); in test_sockmap()
956 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_ANY); in test_sockmap()
962 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_EXIST); in test_sockmap()
970 err = bpf_map_delete_elem(fd, &i); in test_sockmap()
978 err = bpf_prog_attach(parse_prog, fd, in test_sockmap()
984 err = bpf_prog_attach(verdict_prog, fd, in test_sockmap()
992 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_ANY); in test_sockmap()
998 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_NOEXIST); in test_sockmap()
1004 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_EXIST); in test_sockmap()
1062 close(fd); in test_sockmap()
1079 close(fd); in test_sockmap()
1092 int fd, i, value; in test_map_large() local
1094 fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value), in test_map_large()
1096 if (fd < 0) { in test_map_large()
1105 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == 0); in test_map_large()
1109 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 && in test_map_large()
1113 assert(bpf_map_get_next_key(fd, NULL, &key) == 0); in test_map_large()
1116 assert(bpf_map_get_next_key(fd, &key, &key) == 0); in test_map_large()
1117 assert(bpf_map_get_next_key(fd, &key, &key) == -1 && errno == ENOENT); in test_map_large()
1120 assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && value == 0); in test_map_large()
1122 assert(bpf_map_lookup_elem(fd, &key, &value) == -1 && errno == ENOENT); in test_map_large()
1124 close(fd); in test_map_large()
1175 int fd = ((int *)data)[0]; in test_update_delete() local
1182 assert(bpf_map_update_elem(fd, &key, &value, in test_update_delete()
1184 assert(bpf_map_update_elem(fd, &key, &value, in test_update_delete()
1187 assert(bpf_map_delete_elem(fd, &key) == 0); in test_update_delete()
1194 int i, fd, key = 0, value = 0; in test_map_parallel() local
1197 fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value), in test_map_parallel()
1199 if (fd < 0) { in test_map_parallel()
1210 data[0] = fd; in test_map_parallel()
1215 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 && in test_map_parallel()
1219 assert(bpf_map_get_next_key(fd, NULL, &key) == 0); in test_map_parallel()
1222 assert(bpf_map_get_next_key(fd, &key, &key) == 0); in test_map_parallel()
1223 assert(bpf_map_get_next_key(fd, &key, &key) == -1 && errno == ENOENT); in test_map_parallel()
1229 assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && in test_map_parallel()
1239 assert(bpf_map_get_next_key(fd, NULL, &key) == -1 && errno == ENOENT); in test_map_parallel()
1240 assert(bpf_map_get_next_key(fd, &key, &key) == -1 && errno == ENOENT); in test_map_parallel()
1245 int fd, key = 0, value = 0; in test_map_rdonly() local
1247 fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value), in test_map_rdonly()
1249 if (fd < 0) { in test_map_rdonly()
1258 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == -1 && in test_map_rdonly()
1262 assert(bpf_map_lookup_elem(fd, &key, &value) == -1 && errno == ENOENT); in test_map_rdonly()
1263 assert(bpf_map_get_next_key(fd, &key, &value) == -1 && errno == ENOENT); in test_map_rdonly()
1268 int fd, key = 0, value = 0; in test_map_wronly() local
1270 fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value), in test_map_wronly()
1272 if (fd < 0) { in test_map_wronly()
1281 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); in test_map_wronly()
1284 assert(bpf_map_lookup_elem(fd, &key, &value) == -1 && errno == EPERM); in test_map_wronly()
1285 assert(bpf_map_get_next_key(fd, &key, &value) == -1 && errno == EPERM); in test_map_wronly()
1376 int fd; in test_reuseport_array() local
1520 fd = fd64; in test_reuseport_array()
1521 err = bpf_map_update_elem(map_fd, &index3, &fd, BPF_NOEXIST); in test_reuseport_array()
1528 close(fd); in test_reuseport_array()