1 #ifndef __BPF_SYS__ 2 #define __BPF_SYS__ 3 4 #include <sys/syscall.h> 5 #include <linux/bpf.h> 6 7 static inline __u64 bpf_ptr_to_u64(const void *ptr) 8 { 9 return (__u64) (unsigned long) ptr; 10 } 11 12 static inline int bpf_lookup_elem(int fd, void *key, void *value) 13 { 14 union bpf_attr attr = { 15 .map_fd = fd, 16 .key = bpf_ptr_to_u64(key), 17 .value = bpf_ptr_to_u64(value), 18 }; 19 20 return syscall(__NR_bpf, BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr)); 21 } 22 23 #endif /* __BPF_SYS__ */ 24