Lines Matching +full:union +full:- +full:value
1 // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
6 * Copyright (C) 2013-2015 Alexei Starovoitov <ast@kernel.org>
72 static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr, in sys_bpf()
78 static inline int sys_bpf_fd(enum bpf_cmd cmd, union bpf_attr *attr, in sys_bpf_fd()
87 int sys_bpf_prog_load(union bpf_attr *attr, unsigned int size, int attempts) in sys_bpf_prog_load()
93 } while (fd < 0 && errno == EAGAIN && --attempts > 0); in sys_bpf_prog_load()
98 /* Probe whether kernel switched from memlock-based (RLIMIT_MEMLOCK) to
99 * memcg-based memory accounting for BPF maps and progs. This was done in [0].
101 * the same 5.11 Linux release ([1]), to detect memcg-based accounting for BPF.
103 * [0] https://lore.kernel.org/bpf/20201201215900.3569844-1-guro@fb.com/
108 const size_t attr_sz = offsetofend(union bpf_attr, attach_btf_obj_fd); in probe_memcg_account()
114 union bpf_attr attr; in probe_memcg_account()
138 return libbpf_err(-EBUSY); in libbpf_set_memlock_rlim()
148 /* if kernel supports memcg-based accounting, skip bumping RLIMIT_MEMLOCK */ in bump_rlimit_memlock()
154 /* zero memlock_rlim_max disables auto-bumping RLIMIT_MEMLOCK */ in bump_rlimit_memlock()
160 return -errno; in bump_rlimit_memlock()
172 const size_t attr_sz = offsetofend(union bpf_attr, map_extra); in bpf_map_create()
173 union bpf_attr attr; in bpf_map_create()
181 return libbpf_err(-EINVAL); in bpf_map_create()
222 actual_rec_size - expected_rec_size); in alloc_zero_tailing_info()
235 const size_t attr_sz = offsetofend(union bpf_attr, log_true_size); in bpf_prog_load()
241 union bpf_attr attr; in bpf_prog_load()
247 return libbpf_err(-EINVAL); in bpf_prog_load()
251 return libbpf_err(-EINVAL); in bpf_prog_load()
270 return libbpf_err(-E2BIG); in bpf_prog_load()
279 return libbpf_err(-EINVAL); in bpf_prog_load()
292 return libbpf_err(-EINVAL); in bpf_prog_load()
362 /* log_level == 0 with non-NULL log_buf requires retrying on error in bpf_prog_load()
380 int bpf_map_update_elem(int fd, const void *key, const void *value, in bpf_map_update_elem() argument
383 const size_t attr_sz = offsetofend(union bpf_attr, flags); in bpf_map_update_elem()
384 union bpf_attr attr; in bpf_map_update_elem()
390 attr.value = ptr_to_u64(value); in bpf_map_update_elem()
397 int bpf_map_lookup_elem(int fd, const void *key, void *value) in bpf_map_lookup_elem() argument
399 const size_t attr_sz = offsetofend(union bpf_attr, flags); in bpf_map_lookup_elem()
400 union bpf_attr attr; in bpf_map_lookup_elem()
406 attr.value = ptr_to_u64(value); in bpf_map_lookup_elem()
412 int bpf_map_lookup_elem_flags(int fd, const void *key, void *value, __u64 flags) in bpf_map_lookup_elem_flags() argument
414 const size_t attr_sz = offsetofend(union bpf_attr, flags); in bpf_map_lookup_elem_flags()
415 union bpf_attr attr; in bpf_map_lookup_elem_flags()
421 attr.value = ptr_to_u64(value); in bpf_map_lookup_elem_flags()
428 int bpf_map_lookup_and_delete_elem(int fd, const void *key, void *value) in bpf_map_lookup_and_delete_elem() argument
430 const size_t attr_sz = offsetofend(union bpf_attr, flags); in bpf_map_lookup_and_delete_elem()
431 union bpf_attr attr; in bpf_map_lookup_and_delete_elem()
437 attr.value = ptr_to_u64(value); in bpf_map_lookup_and_delete_elem()
443 int bpf_map_lookup_and_delete_elem_flags(int fd, const void *key, void *value, __u64 flags) in bpf_map_lookup_and_delete_elem_flags() argument
445 const size_t attr_sz = offsetofend(union bpf_attr, flags); in bpf_map_lookup_and_delete_elem_flags()
446 union bpf_attr attr; in bpf_map_lookup_and_delete_elem_flags()
452 attr.value = ptr_to_u64(value); in bpf_map_lookup_and_delete_elem_flags()
461 const size_t attr_sz = offsetofend(union bpf_attr, flags); in bpf_map_delete_elem()
462 union bpf_attr attr; in bpf_map_delete_elem()
475 const size_t attr_sz = offsetofend(union bpf_attr, flags); in bpf_map_delete_elem_flags()
476 union bpf_attr attr; in bpf_map_delete_elem_flags()
490 const size_t attr_sz = offsetofend(union bpf_attr, next_key); in bpf_map_get_next_key()
491 union bpf_attr attr; in bpf_map_get_next_key()
505 const size_t attr_sz = offsetofend(union bpf_attr, map_fd); in bpf_map_freeze()
506 union bpf_attr attr; in bpf_map_freeze()
521 const size_t attr_sz = offsetofend(union bpf_attr, batch); in bpf_map_batch_common()
522 union bpf_attr attr; in bpf_map_batch_common()
526 return libbpf_err(-EINVAL); in bpf_map_batch_common()
577 const size_t attr_sz = offsetofend(union bpf_attr, path_fd); in bpf_obj_pin_opts()
578 union bpf_attr attr; in bpf_obj_pin_opts()
582 return libbpf_err(-EINVAL); in bpf_obj_pin_opts()
606 const size_t attr_sz = offsetofend(union bpf_attr, path_fd); in bpf_obj_get_opts()
607 union bpf_attr attr; in bpf_obj_get_opts()
611 return libbpf_err(-EINVAL); in bpf_obj_get_opts()
635 const size_t attr_sz = offsetofend(union bpf_attr, expected_revision); in bpf_prog_attach_opts()
638 union bpf_attr attr; in bpf_prog_attach_opts()
641 return libbpf_err(-EINVAL); in bpf_prog_attach_opts()
647 /* validate we don't have unexpected combinations of non-zero fields */ in bpf_prog_attach_opts()
649 return libbpf_err(-EINVAL); in bpf_prog_attach_opts()
673 const size_t attr_sz = offsetofend(union bpf_attr, expected_revision); in bpf_prog_detach_opts()
676 union bpf_attr attr; in bpf_prog_detach_opts()
679 return libbpf_err(-EINVAL); in bpf_prog_detach_opts()
685 /* validate we don't have unexpected combinations of non-zero fields */ in bpf_prog_detach_opts()
687 return libbpf_err(-EINVAL); in bpf_prog_detach_opts()
721 const size_t attr_sz = offsetofend(union bpf_attr, link_create); in bpf_link_create()
724 union bpf_attr attr; in bpf_link_create()
727 return libbpf_err(-EINVAL); in bpf_link_create()
732 /* validate we don't have unexpected combinations of non-zero fields */ in bpf_link_create()
735 return libbpf_err(-EINVAL); in bpf_link_create()
737 return libbpf_err(-EINVAL); in bpf_link_create()
759 return libbpf_err(-EINVAL); in bpf_link_create()
768 return libbpf_err(-EINVAL); in bpf_link_create()
779 return libbpf_err(-EINVAL); in bpf_link_create()
787 return libbpf_err(-EINVAL); in bpf_link_create()
795 return libbpf_err(-EINVAL); in bpf_link_create()
802 return libbpf_err(-EINVAL); in bpf_link_create()
811 return libbpf_err(-EINVAL); in bpf_link_create()
815 return libbpf_err(-EINVAL); in bpf_link_create()
825 err = -errno; in bpf_link_create()
826 if (err != -EINVAL) in bpf_link_create()
855 const size_t attr_sz = offsetofend(union bpf_attr, link_detach); in bpf_link_detach()
856 union bpf_attr attr; in bpf_link_detach()
869 const size_t attr_sz = offsetofend(union bpf_attr, link_update); in bpf_link_update()
870 union bpf_attr attr; in bpf_link_update()
874 return libbpf_err(-EINVAL); in bpf_link_update()
877 return libbpf_err(-EINVAL); in bpf_link_update()
894 const size_t attr_sz = offsetofend(union bpf_attr, iter_create); in bpf_iter_create()
895 union bpf_attr attr; in bpf_iter_create()
908 const size_t attr_sz = offsetofend(union bpf_attr, query); in bpf_prog_query_opts()
909 union bpf_attr attr; in bpf_prog_query_opts()
913 return libbpf_err(-EINVAL); in bpf_prog_query_opts()
955 const size_t attr_sz = offsetofend(union bpf_attr, test); in bpf_prog_test_run_opts()
956 union bpf_attr attr; in bpf_prog_test_run_opts()
960 return libbpf_err(-EINVAL); in bpf_prog_test_run_opts()
990 const size_t attr_sz = offsetofend(union bpf_attr, open_flags); in bpf_obj_get_next_id()
991 union bpf_attr attr; in bpf_obj_get_next_id()
1027 const size_t attr_sz = offsetofend(union bpf_attr, open_flags); in bpf_prog_get_fd_by_id_opts()
1028 union bpf_attr attr; in bpf_prog_get_fd_by_id_opts()
1032 return libbpf_err(-EINVAL); in bpf_prog_get_fd_by_id_opts()
1050 const size_t attr_sz = offsetofend(union bpf_attr, open_flags); in bpf_map_get_fd_by_id_opts()
1051 union bpf_attr attr; in bpf_map_get_fd_by_id_opts()
1055 return libbpf_err(-EINVAL); in bpf_map_get_fd_by_id_opts()
1073 const size_t attr_sz = offsetofend(union bpf_attr, open_flags); in bpf_btf_get_fd_by_id_opts()
1074 union bpf_attr attr; in bpf_btf_get_fd_by_id_opts()
1078 return libbpf_err(-EINVAL); in bpf_btf_get_fd_by_id_opts()
1096 const size_t attr_sz = offsetofend(union bpf_attr, open_flags); in bpf_link_get_fd_by_id_opts()
1097 union bpf_attr attr; in bpf_link_get_fd_by_id_opts()
1101 return libbpf_err(-EINVAL); in bpf_link_get_fd_by_id_opts()
1118 const size_t attr_sz = offsetofend(union bpf_attr, info); in bpf_obj_get_info_by_fd()
1119 union bpf_attr attr; in bpf_obj_get_info_by_fd()
1155 const size_t attr_sz = offsetofend(union bpf_attr, raw_tracepoint); in bpf_raw_tracepoint_open()
1156 union bpf_attr attr; in bpf_raw_tracepoint_open()
1169 const size_t attr_sz = offsetofend(union bpf_attr, btf_log_true_size); in bpf_btf_load()
1170 union bpf_attr attr; in bpf_btf_load()
1181 return libbpf_err(-EINVAL); in bpf_btf_load()
1188 return libbpf_err(-EINVAL); in bpf_btf_load()
1190 return libbpf_err(-EINVAL); in bpf_btf_load()
1196 * consistent across low-level and high-level BTF and program loading in bpf_btf_load()
1221 const size_t attr_sz = offsetofend(union bpf_attr, task_fd_query); in bpf_task_fd_query()
1222 union bpf_attr attr; in bpf_task_fd_query()
1245 const size_t attr_sz = offsetofend(union bpf_attr, enable_stats); in bpf_enable_stats()
1246 union bpf_attr attr; in bpf_enable_stats()
1259 const size_t attr_sz = offsetofend(union bpf_attr, prog_bind_map); in bpf_prog_bind_map()
1260 union bpf_attr attr; in bpf_prog_bind_map()
1264 return libbpf_err(-EINVAL); in bpf_prog_bind_map()