1 #ifndef __SOCKMAP_HELPERS__
2 #define __SOCKMAP_HELPERS__
4 #include "socket_helpers.h"
6 #define MAX_TEST_NAME 80
8 #define __always_unused __attribute__((__unused__))
10 #define xbpf_map_delete_elem(fd, key) \
12 int __ret = bpf_map_delete_elem((fd), (key)); \
14 FAIL_ERRNO("map_delete"); \
18 #define xbpf_map_lookup_elem(fd, key, val) \
20 int __ret = bpf_map_lookup_elem((fd), (key), (val)); \
22 FAIL_ERRNO("map_lookup"); \
26 #define xbpf_map_update_elem(fd, key, val, flags) \
28 int __ret = bpf_map_update_elem((fd), (key), (val), (flags)); \
30 FAIL_ERRNO("map_update"); \
34 #define xbpf_prog_attach(prog, target, type, flags) \
37 bpf_prog_attach((prog), (target), (type), (flags)); \
39 FAIL_ERRNO("prog_attach(" #type ")"); \
43 #define xbpf_prog_detach2(prog, target, type) \
45 int __ret = bpf_prog_detach2((prog), (target), (type)); \
47 FAIL_ERRNO("prog_detach2(" #type ")"); \
51 #define xpthread_create(thread, attr, func, arg) \
53 int __ret = pthread_create((thread), (attr), (func), (arg)); \
56 FAIL_ERRNO("pthread_create"); \
60 #define xpthread_join(thread, retval) \
62 int __ret = pthread_join((thread), (retval)); \
65 FAIL_ERRNO("pthread_join"); \
69 static inline int add_to_sockmap(int sock_mapfd, int fd1, int fd2)
77 err = xbpf_map_update_elem(sock_mapfd, &key, &value, BPF_NOEXIST);
83 return xbpf_map_update_elem(sock_mapfd, &key, &value, BPF_NOEXIST);
86 #endif // __SOCKMAP_HELPERS__