libbpf: Convert st_ops->data to shadow type.
authorKui-Feng Lee <thinker.li@gmail.com>
Thu, 29 Feb 2024 06:45:20 +0000 (22:45 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 29 Feb 2024 22:23:52 +0000 (14:23 -0800)
commit69e4a9d2b3f5adf5af4feeab0a9f505da971265a
tree0b044a41286a8648b98c65ca50b1ccb20b9dadb9
parent3644d285462a60c80ac225d508fcfe705640d2b4
libbpf: Convert st_ops->data to shadow type.

Convert st_ops->data to the shadow type of the struct_ops map. The shadow
type of a struct_ops type is a variant of the original struct type
providing a way to access/change the values in the maps of the struct_ops
type.

bpf_map__initial_value() will return st_ops->data for struct_ops types. The
skeleton is going to use it as the pointer to the shadow type of the
original struct type.

One of the main differences between the original struct type and the shadow
type is that all function pointers of the shadow type are converted to
pointers of struct bpf_program. Users can replace these bpf_program
pointers with other BPF programs. The st_ops->progs[] will be updated
before updating the value of a map to reflect the changes made by users.

Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240229064523.2091270-3-thinker.li@gmail.com
tools/lib/bpf/libbpf.c