]> granicus.if.org Git - strace/commit
bpf: decode bpf_attr.info field used by BPF_OBJ_GET_INFO_BY_FD command
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 5 Mar 2018 14:56:35 +0000 (15:56 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 28 May 2018 17:34:50 +0000 (17:34 +0000)
commitccde0129ea3e77a5fe19db328b2fb3f1a5353a18
treebf4bf75e470901f0e9007eeb267b235576d4b2eb
parent9228e78d4f96d4f6c81451c86634d7cdc3d7807b
bpf: decode bpf_attr.info field used by BPF_OBJ_GET_INFO_BY_FD command

* bpf_attr.h [!BPF_TAG_SIZE] (BPF_TAG_SIZE): Define.
[BPF_TAG_SIZE]: Check that BPF_TAG_SIZE is 8.
(struct bpf_map_info_struct, struct bpf_prog_info_struct): New
structures.
(bpf_map_info_struct_size, expected_bpf_map_info_struct_size,
bpf_prog_info_struct_size, expected_bpf_prog_info_struct_size): New
macro constants.
* bpf.c (print_bpf_obj_info_fn): New type.
(print_bpf_map_info, print_bpf_prog_info, fetch_bpf_obj_info,
print_bpf_obj_info_addr, print_bpf_obj_info): New functions.
(BEGIN_BPF_CMD_DECODER(BPF_OBJ_GET_INFO_BY_FD)): Print bpf_fd and info_len
fields only on entering, call print_bpf_obj_info for printing info field.
* tests/bpf.c (BPF_OBJ_GET_INFO_BY_FD_checks): Print info field
as a pointer.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
bpf.c
bpf_attr.h
tests/bpf.c