Lines Matching +full:attr +full:- +full:cnt +full:- +full:name
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,
75 return syscall(__NR_bpf, cmd, attr, size);
78 static inline int sys_bpf_fd(enum bpf_cmd cmd, union bpf_attr *attr,
83 fd = sys_bpf(cmd, attr, size);
87 int sys_bpf_prog_load(union bpf_attr *attr, unsigned int size, int attempts)
92 fd = sys_bpf_fd(BPF_PROG_LOAD, attr, size);
93 } while (fd < 0 && errno == EAGAIN && --attempts > 0);
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/
114 union bpf_attr attr;
118 memset(&attr, 0, attr_sz);
119 attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER;
120 attr.insns = ptr_to_u64(insns);
121 attr.insn_cnt = insn_cnt;
122 attr.license = ptr_to_u64("GPL");
123 attr.prog_token_fd = token_fd;
125 attr.prog_flags |= BPF_F_TOKEN_FD;
127 prog_fd = sys_bpf_fd(BPF_PROG_LOAD, &attr, attr_sz);
141 return libbpf_err(-EBUSY);
151 /* if kernel supports memcg-based accounting, skip bumping RLIMIT_MEMLOCK */
157 /* zero memlock_rlim_max disables auto-bumping RLIMIT_MEMLOCK */
163 return -errno;
176 union bpf_attr attr;
181 memset(&attr, 0, attr_sz);
184 return libbpf_err(-EINVAL);
186 attr.map_type = map_type;
188 libbpf_strlcpy(attr.map_name, map_name, sizeof(attr.map_name));
189 attr.key_size = key_size;
190 attr.value_size = value_size;
191 attr.max_entries = max_entries;
193 attr.btf_fd = OPTS_GET(opts, btf_fd, 0);
194 attr.btf_key_type_id = OPTS_GET(opts, btf_key_type_id, 0);
195 attr.btf_value_type_id = OPTS_GET(opts, btf_value_type_id, 0);
196 attr.btf_vmlinux_value_type_id = OPTS_GET(opts, btf_vmlinux_value_type_id, 0);
197 attr.value_type_btf_obj_fd = OPTS_GET(opts, value_type_btf_obj_fd, 0);
199 attr.inner_map_fd = OPTS_GET(opts, inner_map_fd, 0);
200 attr.map_flags = OPTS_GET(opts, map_flags, 0);
201 attr.map_extra = OPTS_GET(opts, map_extra, 0);
202 attr.numa_node = OPTS_GET(opts, numa_node, 0);
203 attr.map_ifindex = OPTS_GET(opts, map_ifindex, 0);
205 attr.map_token_fd = OPTS_GET(opts, token_fd, 0);
206 attr.excl_prog_hash = ptr_to_u64(OPTS_GET(opts, excl_prog_hash, NULL));
207 attr.excl_prog_hash_size = OPTS_GET(opts, excl_prog_hash_size, 0);
209 fd = sys_bpf_fd(BPF_MAP_CREATE, &attr, attr_sz);
214 alloc_zero_tailing_info(const void *orecord, __u32 cnt,
217 __u64 info_len = (__u64)actual_rec_size * cnt;
227 for (i = 0; i < cnt; i++) {
230 actual_rec_size - expected_rec_size);
249 union bpf_attr attr;
255 return libbpf_err(-EINVAL);
259 return libbpf_err(-EINVAL);
263 memset(&attr, 0, attr_sz);
265 attr.prog_type = prog_type;
266 attr.expected_attach_type = OPTS_GET(opts, expected_attach_type, 0);
268 attr.prog_btf_fd = OPTS_GET(opts, prog_btf_fd, 0);
269 attr.prog_flags = OPTS_GET(opts, prog_flags, 0);
270 attr.prog_ifindex = OPTS_GET(opts, prog_ifindex, 0);
271 attr.kern_version = OPTS_GET(opts, kern_version, 0);
272 attr.prog_token_fd = OPTS_GET(opts, token_fd, 0);
275 libbpf_strlcpy(attr.prog_name, prog_name, sizeof(attr.prog_name));
276 attr.license = ptr_to_u64(license);
279 return libbpf_err(-E2BIG);
281 attr.insns = ptr_to_u64(insns);
282 attr.insn_cnt = (__u32)insn_cnt;
288 return libbpf_err(-EINVAL);
290 attr.attach_btf_id = OPTS_GET(opts, attach_btf_id, 0);
292 attr.attach_prog_fd = attach_prog_fd;
294 attr.attach_btf_obj_fd = attach_btf_obj_fd;
301 return libbpf_err(-EINVAL);
305 attr.func_info_rec_size = func_info_rec_size;
306 attr.func_info = ptr_to_u64(func_info);
307 attr.func_info_cnt = OPTS_GET(opts, func_info_cnt, 0);
311 attr.line_info_rec_size = line_info_rec_size;
312 attr.line_info = ptr_to_u64(line_info);
313 attr.line_info_cnt = OPTS_GET(opts, line_info_cnt, 0);
315 attr.fd_array = ptr_to_u64(OPTS_GET(opts, fd_array, NULL));
316 attr.fd_array_cnt = OPTS_GET(opts, fd_array_cnt, 0);
319 attr.log_buf = ptr_to_u64(log_buf);
320 attr.log_size = log_size;
321 attr.log_level = log_level;
324 fd = sys_bpf_prog_load(&attr, attr_sz, attempts);
325 OPTS_SET(opts, log_true_size, attr.log_true_size);
334 if (!finfo && attr.func_info_cnt &&
335 attr.func_info_rec_size < func_info_rec_size) {
338 attr.func_info_cnt,
340 attr.func_info_rec_size);
346 attr.func_info = ptr_to_u64(finfo);
347 attr.func_info_rec_size = func_info_rec_size;
348 } else if (!linfo && attr.line_info_cnt &&
349 attr.line_info_rec_size < line_info_rec_size) {
351 attr.line_info_cnt,
353 attr.line_info_rec_size);
359 attr.line_info = ptr_to_u64(linfo);
360 attr.line_info_rec_size = line_info_rec_size;
365 fd = sys_bpf_prog_load(&attr, attr_sz, attempts);
366 OPTS_SET(opts, log_true_size, attr.log_true_size);
372 /* log_level == 0 with non-NULL log_buf requires retrying on error
376 attr.log_buf = ptr_to_u64(log_buf);
377 attr.log_size = log_size;
378 attr.log_level = 1;
380 fd = sys_bpf_prog_load(&attr, attr_sz, attempts);
381 OPTS_SET(opts, log_true_size, attr.log_true_size);
394 union bpf_attr attr;
397 memset(&attr, 0, attr_sz);
398 attr.map_fd = fd;
399 attr.key = ptr_to_u64(key);
400 attr.value = ptr_to_u64(value);
401 attr.flags = flags;
403 ret = sys_bpf(BPF_MAP_UPDATE_ELEM, &attr, attr_sz);
410 union bpf_attr attr;
413 memset(&attr, 0, attr_sz);
414 attr.map_fd = fd;
415 attr.key = ptr_to_u64(key);
416 attr.value = ptr_to_u64(value);
418 ret = sys_bpf(BPF_MAP_LOOKUP_ELEM, &attr, attr_sz);
425 union bpf_attr attr;
428 memset(&attr, 0, attr_sz);
429 attr.map_fd = fd;
430 attr.key = ptr_to_u64(key);
431 attr.value = ptr_to_u64(value);
432 attr.flags = flags;
434 ret = sys_bpf(BPF_MAP_LOOKUP_ELEM, &attr, attr_sz);
441 union bpf_attr attr;
444 memset(&attr, 0, attr_sz);
445 attr.map_fd = fd;
446 attr.key = ptr_to_u64(key);
447 attr.value = ptr_to_u64(value);
449 ret = sys_bpf(BPF_MAP_LOOKUP_AND_DELETE_ELEM, &attr, attr_sz);
456 union bpf_attr attr;
459 memset(&attr, 0, attr_sz);
460 attr.map_fd = fd;
461 attr.key = ptr_to_u64(key);
462 attr.value = ptr_to_u64(value);
463 attr.flags = flags;
465 ret = sys_bpf(BPF_MAP_LOOKUP_AND_DELETE_ELEM, &attr, attr_sz);
472 union bpf_attr attr;
475 memset(&attr, 0, attr_sz);
476 attr.map_fd = fd;
477 attr.key = ptr_to_u64(key);
479 ret = sys_bpf(BPF_MAP_DELETE_ELEM, &attr, attr_sz);
486 union bpf_attr attr;
489 memset(&attr, 0, attr_sz);
490 attr.map_fd = fd;
491 attr.key = ptr_to_u64(key);
492 attr.flags = flags;
494 ret = sys_bpf(BPF_MAP_DELETE_ELEM, &attr, attr_sz);
501 union bpf_attr attr;
504 memset(&attr, 0, attr_sz);
505 attr.map_fd = fd;
506 attr.key = ptr_to_u64(key);
507 attr.next_key = ptr_to_u64(next_key);
509 ret = sys_bpf(BPF_MAP_GET_NEXT_KEY, &attr, attr_sz);
516 union bpf_attr attr;
519 memset(&attr, 0, attr_sz);
520 attr.map_fd = fd;
522 ret = sys_bpf(BPF_MAP_FREEZE, &attr, attr_sz);
532 union bpf_attr attr;
536 return libbpf_err(-EINVAL);
538 memset(&attr, 0, attr_sz);
539 attr.batch.map_fd = fd;
540 attr.batch.in_batch = ptr_to_u64(in_batch);
541 attr.batch.out_batch = ptr_to_u64(out_batch);
542 attr.batch.keys = ptr_to_u64(keys);
543 attr.batch.values = ptr_to_u64(values);
544 attr.batch.count = *count;
545 attr.batch.elem_flags = OPTS_GET(opts, elem_flags, 0);
546 attr.batch.flags = OPTS_GET(opts, flags, 0);
548 ret = sys_bpf(cmd, &attr, attr_sz);
549 *count = attr.batch.count;
588 union bpf_attr attr;
592 return libbpf_err(-EINVAL);
594 memset(&attr, 0, attr_sz);
595 attr.path_fd = OPTS_GET(opts, path_fd, 0);
596 attr.pathname = ptr_to_u64((void *)pathname);
597 attr.file_flags = OPTS_GET(opts, file_flags, 0);
598 attr.bpf_fd = fd;
600 ret = sys_bpf(BPF_OBJ_PIN, &attr, attr_sz);
617 union bpf_attr attr;
621 return libbpf_err(-EINVAL);
623 memset(&attr, 0, attr_sz);
624 attr.path_fd = OPTS_GET(opts, path_fd, 0);
625 attr.pathname = ptr_to_u64((void *)pathname);
626 attr.file_flags = OPTS_GET(opts, file_flags, 0);
628 fd = sys_bpf_fd(BPF_OBJ_GET, &attr, attr_sz);
648 union bpf_attr attr;
651 return libbpf_err(-EINVAL);
657 /* validate we don't have unexpected combinations of non-zero fields */
659 return libbpf_err(-EINVAL);
661 memset(&attr, 0, attr_sz);
662 attr.target_fd = target;
663 attr.attach_bpf_fd = prog_fd;
664 attr.attach_type = type;
665 attr.replace_bpf_fd = OPTS_GET(opts, replace_fd, 0);
666 attr.expected_revision = OPTS_GET(opts, expected_revision, 0);
669 attr.attach_flags = flags | BPF_F_ID;
670 attr.relative_id = relative_id;
672 attr.attach_flags = flags;
673 attr.relative_fd = relative_fd;
676 ret = sys_bpf(BPF_PROG_ATTACH, &attr, attr_sz);
686 union bpf_attr attr;
689 return libbpf_err(-EINVAL);
695 /* validate we don't have unexpected combinations of non-zero fields */
697 return libbpf_err(-EINVAL);
699 memset(&attr, 0, attr_sz);
700 attr.target_fd = target;
701 attr.attach_bpf_fd = prog_fd;
702 attr.attach_type = type;
703 attr.expected_revision = OPTS_GET(opts, expected_revision, 0);
706 attr.attach_flags = flags | BPF_F_ID;
707 attr.relative_id = relative_id;
709 attr.attach_flags = flags;
710 attr.relative_fd = relative_fd;
713 ret = sys_bpf(BPF_PROG_DETACH, &attr, attr_sz);
734 union bpf_attr attr;
737 return libbpf_err(-EINVAL);
742 /* validate we don't have unexpected combinations of non-zero fields */
745 return libbpf_err(-EINVAL);
747 return libbpf_err(-EINVAL);
750 memset(&attr, 0, attr_sz);
751 attr.link_create.prog_fd = prog_fd;
752 attr.link_create.target_fd = target_fd;
753 attr.link_create.attach_type = attach_type;
754 attr.link_create.flags = OPTS_GET(opts, flags, 0);
757 attr.link_create.target_btf_id = target_btf_id;
763 attr.link_create.iter_info = ptr_to_u64(OPTS_GET(opts, iter_info, (void *)0));
764 attr.link_create.iter_info_len = iter_info_len;
767 attr.link_create.perf_event.bpf_cookie = OPTS_GET(opts, perf_event.bpf_cookie, 0);
769 return libbpf_err(-EINVAL);
773 attr.link_create.kprobe_multi.flags = OPTS_GET(opts, kprobe_multi.flags, 0);
774 attr.link_create.kprobe_multi.cnt = OPTS_GET(opts, kprobe_multi.cnt, 0);
775 attr.link_create.kprobe_multi.syms = ptr_to_u64(OPTS_GET(opts, kprobe_multi.syms, 0));
776 attr.link_create.kprobe_multi.addrs = ptr_to_u64(OPTS_GET(opts, kprobe_multi.addrs, 0));
777 attr.link_create.kprobe_multi.cookies = ptr_to_u64(OPTS_GET(opts, kprobe_multi.cookies, 0));
779 return libbpf_err(-EINVAL);
783 attr.link_create.uprobe_multi.flags = OPTS_GET(opts, uprobe_multi.flags, 0);
784 attr.link_create.uprobe_multi.cnt = OPTS_GET(opts, uprobe_multi.cnt, 0);
785 attr.link_create.uprobe_multi.path = ptr_to_u64(OPTS_GET(opts, uprobe_multi.path, 0));
786 attr.link_create.uprobe_multi.offsets = ptr_to_u64(OPTS_GET(opts, uprobe_multi.offsets, 0));
787 attr.link_create.uprobe_multi.ref_ctr_offsets = ptr_to_u64(OPTS_GET(opts, uprobe_multi.ref_ctr_offsets, 0));
788 attr.link_create.uprobe_multi.cookies = ptr_to_u64(OPTS_GET(opts, uprobe_multi.cookies, 0));
789 attr.link_create.uprobe_multi.pid = OPTS_GET(opts, uprobe_multi.pid, 0);
791 return libbpf_err(-EINVAL);
798 attr.link_create.tracing.cookie = OPTS_GET(opts, tracing.cookie, 0);
800 return libbpf_err(-EINVAL);
803 attr.link_create.netfilter.pf = OPTS_GET(opts, netfilter.pf, 0);
804 attr.link_create.netfilter.hooknum = OPTS_GET(opts, netfilter.hooknum, 0);
805 attr.link_create.netfilter.priority = OPTS_GET(opts, netfilter.priority, 0);
806 attr.link_create.netfilter.flags = OPTS_GET(opts, netfilter.flags, 0);
808 return libbpf_err(-EINVAL);
815 return libbpf_err(-EINVAL);
817 attr.link_create.tcx.relative_id = relative_id;
818 attr.link_create.flags |= BPF_F_ID;
820 attr.link_create.tcx.relative_fd = relative_fd;
822 attr.link_create.tcx.expected_revision = OPTS_GET(opts, tcx.expected_revision, 0);
824 return libbpf_err(-EINVAL);
831 return libbpf_err(-EINVAL);
833 attr.link_create.netkit.relative_id = relative_id;
834 attr.link_create.flags |= BPF_F_ID;
836 attr.link_create.netkit.relative_fd = relative_fd;
838 attr.link_create.netkit.expected_revision = OPTS_GET(opts, netkit.expected_revision, 0);
840 return libbpf_err(-EINVAL);
874 return libbpf_err(-EINVAL);
876 attr.link_create.cgroup.relative_id = relative_id;
877 attr.link_create.flags |= BPF_F_ID;
879 attr.link_create.cgroup.relative_fd = relative_fd;
881 attr.link_create.cgroup.expected_revision =
884 return libbpf_err(-EINVAL);
888 return libbpf_err(-EINVAL);
892 fd = sys_bpf_fd(BPF_LINK_CREATE, &attr, attr_sz);
898 err = -errno;
899 if (err != -EINVAL)
905 if (attr.link_create.target_fd || attr.link_create.target_btf_id)
929 union bpf_attr attr;
932 memset(&attr, 0, attr_sz);
933 attr.link_detach.link_fd = link_fd;
935 ret = sys_bpf(BPF_LINK_DETACH, &attr, attr_sz);
943 union bpf_attr attr;
947 return libbpf_err(-EINVAL);
950 return libbpf_err(-EINVAL);
952 memset(&attr, 0, attr_sz);
953 attr.link_update.link_fd = link_fd;
954 attr.link_update.new_prog_fd = new_prog_fd;
955 attr.link_update.flags = OPTS_GET(opts, flags, 0);
957 attr.link_update.old_prog_fd = OPTS_GET(opts, old_prog_fd, 0);
959 attr.link_update.old_map_fd = OPTS_GET(opts, old_map_fd, 0);
961 ret = sys_bpf(BPF_LINK_UPDATE, &attr, attr_sz);
968 union bpf_attr attr;
971 memset(&attr, 0, attr_sz);
972 attr.iter_create.link_fd = link_fd;
974 fd = sys_bpf_fd(BPF_ITER_CREATE, &attr, attr_sz);
982 union bpf_attr attr;
986 return libbpf_err(-EINVAL);
988 memset(&attr, 0, attr_sz);
989 attr.query.target_fd = target;
990 attr.query.attach_type = type;
991 attr.query.query_flags = OPTS_GET(opts, query_flags, 0);
992 attr.query.count = OPTS_GET(opts, count, 0);
993 attr.query.prog_ids = ptr_to_u64(OPTS_GET(opts, prog_ids, NULL));
994 attr.query.link_ids = ptr_to_u64(OPTS_GET(opts, link_ids, NULL));
995 attr.query.prog_attach_flags = ptr_to_u64(OPTS_GET(opts, prog_attach_flags, NULL));
996 attr.query.link_attach_flags = ptr_to_u64(OPTS_GET(opts, link_attach_flags, NULL));
998 ret = sys_bpf(BPF_PROG_QUERY, &attr, attr_sz);
1000 OPTS_SET(opts, attach_flags, attr.query.attach_flags);
1001 OPTS_SET(opts, revision, attr.query.revision);
1002 OPTS_SET(opts, count, attr.query.count);
1029 union bpf_attr attr;
1033 return libbpf_err(-EINVAL);
1035 memset(&attr, 0, attr_sz);
1036 attr.test.prog_fd = prog_fd;
1037 attr.test.batch_size = OPTS_GET(opts, batch_size, 0);
1038 attr.test.cpu = OPTS_GET(opts, cpu, 0);
1039 attr.test.flags = OPTS_GET(opts, flags, 0);
1040 attr.test.repeat = OPTS_GET(opts, repeat, 0);
1041 attr.test.duration = OPTS_GET(opts, duration, 0);
1042 attr.test.ctx_size_in = OPTS_GET(opts, ctx_size_in, 0);
1043 attr.test.ctx_size_out = OPTS_GET(opts, ctx_size_out, 0);
1044 attr.test.data_size_in = OPTS_GET(opts, data_size_in, 0);
1045 attr.test.data_size_out = OPTS_GET(opts, data_size_out, 0);
1046 attr.test.ctx_in = ptr_to_u64(OPTS_GET(opts, ctx_in, NULL));
1047 attr.test.ctx_out = ptr_to_u64(OPTS_GET(opts, ctx_out, NULL));
1048 attr.test.data_in = ptr_to_u64(OPTS_GET(opts, data_in, NULL));
1049 attr.test.data_out = ptr_to_u64(OPTS_GET(opts, data_out, NULL));
1051 ret = sys_bpf(BPF_PROG_TEST_RUN, &attr, attr_sz);
1053 OPTS_SET(opts, data_size_out, attr.test.data_size_out);
1054 OPTS_SET(opts, ctx_size_out, attr.test.ctx_size_out);
1055 OPTS_SET(opts, duration, attr.test.duration);
1056 OPTS_SET(opts, retval, attr.test.retval);
1064 union bpf_attr attr;
1067 memset(&attr, 0, attr_sz);
1068 attr.start_id = start_id;
1070 err = sys_bpf(cmd, &attr, attr_sz);
1072 *next_id = attr.next_id;
1101 union bpf_attr attr;
1105 return libbpf_err(-EINVAL);
1107 memset(&attr, 0, attr_sz);
1108 attr.prog_id = id;
1109 attr.open_flags = OPTS_GET(opts, open_flags, 0);
1111 fd = sys_bpf_fd(BPF_PROG_GET_FD_BY_ID, &attr, attr_sz);
1124 union bpf_attr attr;
1128 return libbpf_err(-EINVAL);
1130 memset(&attr, 0, attr_sz);
1131 attr.map_id = id;
1132 attr.open_flags = OPTS_GET(opts, open_flags, 0);
1134 fd = sys_bpf_fd(BPF_MAP_GET_FD_BY_ID, &attr, attr_sz);
1147 union bpf_attr attr;
1151 return libbpf_err(-EINVAL);
1153 memset(&attr, 0, attr_sz);
1154 attr.btf_id = id;
1155 attr.open_flags = OPTS_GET(opts, open_flags, 0);
1156 attr.fd_by_id_token_fd = OPTS_GET(opts, token_fd, 0);
1158 fd = sys_bpf_fd(BPF_BTF_GET_FD_BY_ID, &attr, attr_sz);
1171 union bpf_attr attr;
1175 return libbpf_err(-EINVAL);
1177 memset(&attr, 0, attr_sz);
1178 attr.link_id = id;
1179 attr.open_flags = OPTS_GET(opts, open_flags, 0);
1181 fd = sys_bpf_fd(BPF_LINK_GET_FD_BY_ID, &attr, attr_sz);
1193 union bpf_attr attr;
1196 memset(&attr, 0, attr_sz);
1197 attr.info.bpf_fd = bpf_fd;
1198 attr.info.info_len = *info_len;
1199 attr.info.info = ptr_to_u64(info);
1201 err = sys_bpf(BPF_OBJ_GET_INFO_BY_FD, &attr, attr_sz);
1203 *info_len = attr.info.info_len;
1230 union bpf_attr attr;
1234 return libbpf_err(-EINVAL);
1236 memset(&attr, 0, attr_sz);
1237 attr.raw_tracepoint.prog_fd = prog_fd;
1238 attr.raw_tracepoint.name = ptr_to_u64(OPTS_GET(opts, tp_name, NULL));
1239 attr.raw_tracepoint.cookie = OPTS_GET(opts, cookie, 0);
1241 fd = sys_bpf_fd(BPF_RAW_TRACEPOINT_OPEN, &attr, attr_sz);
1245 int bpf_raw_tracepoint_open(const char *name, int prog_fd)
1247 LIBBPF_OPTS(bpf_raw_tp_opts, opts, .tp_name = name);
1255 union bpf_attr attr;
1263 memset(&attr, 0, attr_sz);
1266 return libbpf_err(-EINVAL);
1273 return libbpf_err(-EINVAL);
1275 return libbpf_err(-EINVAL);
1277 attr.btf = ptr_to_u64(btf_data);
1278 attr.btf_size = btf_size;
1280 attr.btf_flags = OPTS_GET(opts, btf_flags, 0);
1281 attr.btf_token_fd = OPTS_GET(opts, token_fd, 0);
1285 * consistent across low-level and high-level BTF and program loading
1289 attr.btf_log_buf = ptr_to_u64(log_buf);
1290 attr.btf_log_size = (__u32)log_size;
1291 attr.btf_log_level = log_level;
1294 fd = sys_bpf_fd(BPF_BTF_LOAD, &attr, attr_sz);
1296 attr.btf_log_buf = ptr_to_u64(log_buf);
1297 attr.btf_log_size = (__u32)log_size;
1298 attr.btf_log_level = 1;
1299 fd = sys_bpf_fd(BPF_BTF_LOAD, &attr, attr_sz);
1302 OPTS_SET(opts, log_true_size, attr.btf_log_true_size);
1311 union bpf_attr attr;
1314 memset(&attr, 0, attr_sz);
1315 attr.task_fd_query.pid = pid;
1316 attr.task_fd_query.fd = fd;
1317 attr.task_fd_query.flags = flags;
1318 attr.task_fd_query.buf = ptr_to_u64(buf);
1319 attr.task_fd_query.buf_len = *buf_len;
1321 err = sys_bpf(BPF_TASK_FD_QUERY, &attr, attr_sz);
1323 *buf_len = attr.task_fd_query.buf_len;
1324 *prog_id = attr.task_fd_query.prog_id;
1325 *fd_type = attr.task_fd_query.fd_type;
1326 *probe_offset = attr.task_fd_query.probe_offset;
1327 *probe_addr = attr.task_fd_query.probe_addr;
1335 union bpf_attr attr;
1338 memset(&attr, 0, attr_sz);
1339 attr.enable_stats.type = type;
1341 fd = sys_bpf_fd(BPF_ENABLE_STATS, &attr, attr_sz);
1349 union bpf_attr attr;
1353 return libbpf_err(-EINVAL);
1355 memset(&attr, 0, attr_sz);
1356 attr.prog_bind_map.prog_fd = prog_fd;
1357 attr.prog_bind_map.map_fd = map_fd;
1358 attr.prog_bind_map.flags = OPTS_GET(opts, flags, 0);
1360 ret = sys_bpf(BPF_PROG_BIND_MAP, &attr, attr_sz);
1367 union bpf_attr attr;
1371 return libbpf_err(-EINVAL);
1373 memset(&attr, 0, attr_sz);
1374 attr.token_create.bpffs_fd = bpffs_fd;
1375 attr.token_create.flags = OPTS_GET(opts, flags, 0);
1377 fd = sys_bpf_fd(BPF_TOKEN_CREATE, &attr, attr_sz);
1385 union bpf_attr attr;
1389 return libbpf_err(-EINVAL);
1391 memset(&attr, 0, attr_sz);
1392 attr.prog_stream_read.stream_buf = ptr_to_u64(buf);
1393 attr.prog_stream_read.stream_buf_len = buf_len;
1394 attr.prog_stream_read.stream_id = stream_id;
1395 attr.prog_stream_read.prog_fd = prog_fd;
1397 err = sys_bpf(BPF_PROG_STREAM_READ_BY_FD, &attr, attr_sz);