Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libbpf: add map_get_fd_by_id and map_delete_elem in light skeleton

This allows to have a better control over maps from the kernel when
preloading eBPF programs.

Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20220824134055.1328882-8-benjamin.tissoires@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Benjamin Tissoires and committed by
Alexei Starovoitov
343949e1 b88df697

+23
+23
tools/lib/bpf/skel_internal.h
··· 251 251 return skel_sys_bpf(BPF_MAP_UPDATE_ELEM, &attr, attr_sz); 252 252 } 253 253 254 + static inline int skel_map_delete_elem(int fd, const void *key) 255 + { 256 + const size_t attr_sz = offsetofend(union bpf_attr, flags); 257 + union bpf_attr attr; 258 + 259 + memset(&attr, 0, attr_sz); 260 + attr.map_fd = fd; 261 + attr.key = (long)key; 262 + 263 + return skel_sys_bpf(BPF_MAP_DELETE_ELEM, &attr, attr_sz); 264 + } 265 + 266 + static inline int skel_map_get_fd_by_id(__u32 id) 267 + { 268 + const size_t attr_sz = offsetofend(union bpf_attr, flags); 269 + union bpf_attr attr; 270 + 271 + memset(&attr, 0, attr_sz); 272 + attr.map_id = id; 273 + 274 + return skel_sys_bpf(BPF_MAP_GET_FD_BY_ID, &attr, attr_sz); 275 + } 276 + 254 277 static inline int skel_raw_tracepoint_open(const char *name, int prog_fd) 255 278 { 256 279 const size_t attr_sz = offsetofend(union bpf_attr, raw_tracepoint.prog_fd);