@@ -6607,45 +6607,230 @@ struct sk_reuseport_md {
66076607
66086608#define BPF_TAG_SIZE 8
66096609
6610+ /**
6611+ * struct bpf_prog_info - Information about a BPF program.
6612+ *
6613+ * This structure is used by the bpf(BPF_OBJ_GET_INFO_BY_FD) syscall to retrieve
6614+ * metadata about a loaded BPF program. When values like the jited_prog_insns
6615+ * are desired typically two syscalls will be made, the first to determine the
6616+ * length of the buffers and the second with buffers for the syscall to fill
6617+ * in. The variables within the struct are ordered to minimize padding.
6618+ */
66106619struct bpf_prog_info {
6620+ /**
6621+ * @type: The type of the BPF program (e.g.,
6622+ * BPF_PROG_TYPE_SOCKET_FILTER, BPF_PROG_TYPE_KPROBE). This defines
6623+ * where the program can be attached.
6624+ */
66116625 __u32 type ;
6626+ /**
6627+ * @id: A unique, kernel-assigned ID for the loaded BPF program.
6628+ */
66126629 __u32 id ;
6630+ /**
6631+ * @tag: A user-defined tag for the program, often a hash of the
6632+ * object file it came from. Size is BPF_TAG_SIZE (8 bytes).
6633+ */
66136634 __u8 tag [BPF_TAG_SIZE ];
6635+ /**
6636+ * @jited_prog_len: As an in argument this is the length of the
6637+ * jited_prog_insns buffer. As an out argument, the length of the
6638+ * JIT-compiled (native machine code) program image in bytes.
6639+ */
66146640 __u32 jited_prog_len ;
6641+ /**
6642+ * @xlated_prog_len: As an in argument this is the length of the
6643+ * xlated_prog_insns buffer. As an out argument, the length of the
6644+ * translated BPF bytecode in bytes, after the verifier has potentially
6645+ * modified it. 'xlated' is short for 'translated'.
6646+ */
66156647 __u32 xlated_prog_len ;
6648+ /**
6649+ * @jited_prog_insns: When 0 (NULL) this is ignored by the kernel. When
6650+ * non-zero a pointer to a buffer is expected and the kernel will write
6651+ * jited_prog_len(s) worth of JIT-compiled machine code instructions into
6652+ * the buffer.
6653+ */
66166654 __aligned_u64 jited_prog_insns ;
6655+ /**
6656+ * @xlated_prog_insns: When 0 (NULL) this is ignored by the kernel. When
6657+ * non-zero a pointer to a buffer is expected and the kernel will write
6658+ * xlated_prog_len(s) worth of translated, after BPF verification, BPF
6659+ * bytecode into the buffer.
6660+ */
66176661 __aligned_u64 xlated_prog_insns ;
6618- __u64 load_time ; /* ns since boottime */
6662+ /**
6663+ * @load_time: The timestamp (in nanoseconds since boot time) when the
6664+ * program was loaded into the kernel.
6665+ */
6666+ __u64 load_time ;
6667+ /**
6668+ * @created_by_uid: The user ID of the process that loaded this program.
6669+ */
66196670 __u32 created_by_uid ;
6671+ /**
6672+ * @nr_map_ids: As an in argument this is the length of the map_ids
6673+ * buffer in sizes of u32 (4 bytes). As an out argument, the number of
6674+ * BPF maps used by this BPF program.
6675+ */
66206676 __u32 nr_map_ids ;
6677+ /**
6678+ * @map_ids: When 0 (NULL) this is ignored by the kernel. When non-zero
6679+ * a pointer to a buffer is expected and the kernel will write
6680+ * nr_map_ids(s) worth of u32 kernel allocated BPF map id values into the
6681+ * buffer.
6682+ */
66216683 __aligned_u64 map_ids ;
6684+ /**
6685+ * @name: The name of the program, as specified in the ELF object file.
6686+ * The max length is BPF_OBJ_NAME_LEN (16 characters).
6687+ */
66226688 char name [BPF_OBJ_NAME_LEN ];
6689+ /**
6690+ * @ifindex: If the program is attached to a network device (netdev),
6691+ * this field holds the interface index.
6692+ */
66236693 __u32 ifindex ;
6694+ /**
6695+ * @gpl_compatible: A flag indicating if the program is compatible with
6696+ * a GPL license. This is important for using certain GPL-only helpers.
6697+ */
66246698 __u32 gpl_compatible :1 ;
66256699 __u32 :31 ; /* alignment pad */
6700+ /**
6701+ * @netns_dev: The device identifier of the network namespace the
6702+ * program is attached to.
6703+ */
66266704 __u64 netns_dev ;
6705+ /**
6706+ * @netns_ino: The inode number of the network namespace the program is
6707+ * attached to.
6708+ */
66276709 __u64 netns_ino ;
6710+ /**
6711+ * @nr_jited_ksyms: As an in argument this is the length of the
6712+ * jited_ksyms buffer in sizes of u64 (8 bytes). As an out argument, the
6713+ * number of kernel symbols that the BPF program calls.
6714+ */
66286715 __u32 nr_jited_ksyms ;
6716+ /**
6717+ * @nr_jited_func_lens: As an in argument this is the length of the
6718+ * jited_func_lens buffer in sizes of u32 (4 bytes). As an out argument,
6719+ * the number of distinct functions within the JIT-ed program.
6720+ */
66296721 __u32 nr_jited_func_lens ;
6722+ /**
6723+ * @jited_ksyms: When 0 (NULL) this is ignored by the kernel. When
6724+ * non-zero a pointer to a buffer is expected and the kernel will write
6725+ * nr_jited_ksyms(s) worth of addresses of kernel symbols into the u64
6726+ * buffer.
6727+ */
66306728 __aligned_u64 jited_ksyms ;
6729+ /**
6730+ * @jited_func_lens: When 0 (NULL) this is ignored by the kernel. When
6731+ * non-zero a pointer to a buffer is expected and the kernel will write
6732+ * nr_jited_func_lens(s) worth of lengths into the u32 buffer.
6733+ */
66316734 __aligned_u64 jited_func_lens ;
6735+ /**
6736+ * @btf_id: The ID of the BTF (BPF Type Format) object associated with
6737+ * this program, which contains type information for debugging and
6738+ * introspection.
6739+ */
66326740 __u32 btf_id ;
6741+ /**
6742+ * @func_info_rec_size: The size in bytes of a single `bpf_func_info`
6743+ * record.
6744+ */
66336745 __u32 func_info_rec_size ;
6746+ /**
6747+ * @func_info: When 0 (NULL) this is ignored by the kernel. When
6748+ * non-zero a pointer to a buffer is expected and the kernel will write
6749+ * nr_func_info(s) worth of func_info_rec_size values.
6750+ */
66346751 __aligned_u64 func_info ;
6752+ /**
6753+ * @nr_func_info: As an in argument this is the length of the func_info
6754+ * buffer in sizes of func_info_rec_size. As an out argument, the number
6755+ * of `bpf_func_info` records available.
6756+ */
66356757 __u32 nr_func_info ;
6758+ /**
6759+ * @nr_line_info: As an in argument this is the length of the line_info
6760+ * buffer in sizes of line_info_rec_size. As an out argument, the number
6761+ * of `bpf_line_info` records, which map BPF instructions to source code
6762+ * lines.
6763+ */
66366764 __u32 nr_line_info ;
6765+ /**
6766+ * @line_info: When 0 (NULL) this is ignored by the kernel. When
6767+ * non-zero a pointer to a buffer is expected and the kernel will write
6768+ * nr_line_info(s) worth of line_info_rec_size values.
6769+ */
66376770 __aligned_u64 line_info ;
6771+ /**
6772+ * @jited_line_info: When 0 (NULL) this is ignored by the kernel. When
6773+ * non-zero a pointer to a buffer is expected and the kernel will write
6774+ * nr_jited_line_info(s) worth of jited_line_info_rec_size values.
6775+ */
66386776 __aligned_u64 jited_line_info ;
6777+ /**
6778+ * @nr_line_info: As an in argument this is the length of the
6779+ * jited_line_info buffer in sizes of jited_line_info_rec_size. As an
6780+ * out argument, the number of `bpf_line_info` records, which map JIT-ed
6781+ * instructions to source code lines.
6782+ */
66396783 __u32 nr_jited_line_info ;
6784+ /**
6785+ * @line_info_rec_size: The size in bytes of a `bpf_line_info` record.
6786+ */
66406787 __u32 line_info_rec_size ;
6788+ /**
6789+ * @jited_line_info_rec_size: The size in bytes of a `bpf_line_info`
6790+ * record for JIT-ed code.
6791+ */
66416792 __u32 jited_line_info_rec_size ;
6793+ /**
6794+ * @nr_prog_tags: As an in argument this is the length of the prog_tags
6795+ * buffer in sizes of BPF_TAG_SIZE (8 bytes). As an out argument, the
6796+ * number of program tags, which are hashes of programs that this
6797+ * program can tail-call.
6798+ */
66426799 __u32 nr_prog_tags ;
6800+ /**
6801+ * @prog_tags: When 0 (NULL) this is ignored by the kernel. When
6802+ * non-zero a pointer to a buffer is expected and the kernel will write
6803+ * nr_prog_tags(s) worth of BPF_TAG_SIZE values.
6804+ */
66436805 __aligned_u64 prog_tags ;
6806+ /**
6807+ * @run_time_ns: The total accumulated execution time of the program in
6808+ * nanoseconds.
6809+ */
66446810 __u64 run_time_ns ;
6811+ /**
6812+ * @run_cnt: The total number of times the program has been executed.
6813+ */
66456814 __u64 run_cnt ;
6815+ /**
6816+ * @recursion_misses: The number of failed tail calls due to reaching
6817+ * the recursion limit.
6818+ */
66466819 __u64 recursion_misses ;
6820+ /**
6821+ * @verified_insns: The number of instructions processed by the
6822+ * verifier.
6823+ */
66476824 __u32 verified_insns ;
6825+ /**
6826+ * @attach_btf_obj_id: If attached via BTF (e.g., fentry/fexit), this is
6827+ * the BTF object ID of the target object (e.g., kernel vmlinux).
6828+ */
66486829 __u32 attach_btf_obj_id ;
6830+ /**
6831+ * @attach_btf_id: The BTF type ID of the function or tracepoint this
6832+ * program is attached to.
6833+ */
66496834 __u32 attach_btf_id ;
66506835} __attribute__((aligned (8 )));
66516836
0 commit comments