diff options
author | Daniel Mack <daniel@zonque.org> | 2016-10-18 17:57:10 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-11-20 17:28:50 +0100 |
commit | b605cf820c4831451fd009825a914d6f98045219 (patch) | |
tree | 6320971d755d18f28b3387d9de29ea28052d57a8 /src/basic/missing_syscall.h | |
parent | 294d3039be600ee7fbe43222fcf7084c99e63b94 (diff) |
Add abstraction model for BPF programs
This object takes a number of bpf_insn members and wraps them together with
the in-kernel reference id. Will be needed by the firewall code.
Diffstat (limited to 'src/basic/missing_syscall.h')
-rw-r--r-- | src/basic/missing_syscall.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/basic/missing_syscall.h b/src/basic/missing_syscall.h index 664724c00..2f596cf54 100644 --- a/src/basic/missing_syscall.h +++ b/src/basic/missing_syscall.h @@ -23,6 +23,8 @@ /* Missing glibc definitions to access certain kernel APIs */ #if 0 /// UNNEEDED by elogind +#include <sys/types.h> + #if !HAVE_DECL_PIVOT_ROOT static inline int pivot_root(const char *new_root, const char *put_old) { return syscall(SYS_pivot_root, new_root, put_old); @@ -318,3 +320,33 @@ static inline ssize_t copy_file_range(int fd_in, loff_t *off_in, # endif } #endif + +#if !HAVE_DECL_BPF +# ifndef __NR_bpf +# if defined __i386__ +# define __NR_bpf 357 +# elif defined __x86_64__ +# define __NR_bpf 321 +# elif defined __aarch64__ +# define __NR_bpf 280 +# elif defined __sparc__ +# define __NR_bpf 349 +# elif defined __s390__ +# define __NR_bpf 351 +# else +# warning "__NR_bpf not defined for your architecture" +# endif +# endif + +union bpf_attr; + +static inline int bpf(int cmd, union bpf_attr *attr, size_t size) { +#ifdef __NR_bpf + return (int) syscall(__NR_bpf, cmd, attr, size); +#else + errno = ENOSYS; + return -1; +#endif +} + +#endif |