summaryrefslogtreecommitdiff
path: root/bpf.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2015-07-19 14:41:19 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2015-07-20 10:05:05 +0200
commita839a6ad1dd48802e50fddca2747eea511b65826 (patch)
tree2f0f536e7884efad3ab4c8287a46c2e3720f3c00 /bpf.c
parenta1e7c1dc527ca3c37349cebc6fbeaa12a594fcf3 (diff)
bpf: Use sysctl helpers to enable bpf jit compiler
Use sysctl helpers to set /proc/sys/net/core/bpf_jit_enable param. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'bpf.c')
-rw-r--r--bpf.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/bpf.c b/bpf.c
index 25cf25d..2d769ec 100644
--- a/bpf.c
+++ b/bpf.c
@@ -18,6 +18,7 @@
#include "xmalloc.h"
#include "die.h"
#include "str.h"
+#include "sysctl.h"
#define EXTRACT_SHORT(packet) \
((unsigned short) ntohs(*(unsigned short *) packet))
@@ -380,18 +381,7 @@ void bpf_detach_from_sock(int sock)
int enable_kernel_bpf_jit_compiler(void)
{
- int fd;
- ssize_t ret;
- char *file = "/proc/sys/net/core/bpf_jit_enable";
-
- fd = open(file, O_WRONLY);
- if (unlikely(fd < 0))
- return -1;
-
- ret = write(fd, "1", strlen("1"));
-
- close(fd);
- return ret;
+ return sysctl_set_int("net/core/bpf_jit_enable", 1);
}
int __bpf_validate(const struct sock_fprog *bpf)