From: Vadim Kochan <[email protected]>

Use sysctl helpers to set /proc/sys/net/core/bpf_jit_enable param.

Signed-off-by: Vadim Kochan <[email protected]>
---
 astraceroute/Makefile |  1 +
 bpf.c                 | 14 ++------------
 bpfc/Makefile         |  1 +
 netsniff-ng/Makefile  |  1 +
 4 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/astraceroute/Makefile b/astraceroute/Makefile
index 2e80a11..bbf9e88 100644
--- a/astraceroute/Makefile
+++ b/astraceroute/Makefile
@@ -17,6 +17,7 @@ astraceroute-objs =   xmalloc.o \
                        dev.o \
                        ring.o \
                        die.o \
+                       sysctl.o \
                        astraceroute.o
 
 ifeq ($(CONFIG_GEOIP), 1)
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)
diff --git a/bpfc/Makefile b/bpfc/Makefile
index b8a3787..b687bd1 100644
--- a/bpfc/Makefile
+++ b/bpfc/Makefile
@@ -6,6 +6,7 @@ bpfc-objs =     xmalloc.o \
                bpf_lexer.yy.o \
                bpf_parser.tab.o \
                die.o \
+               sysctl.o \
                bpfc.o
 
 bpfc-lex =     bpf_lexer.yy.o
diff --git a/netsniff-ng/Makefile b/netsniff-ng/Makefile
index 33701a4..03e306e 100644
--- a/netsniff-ng/Makefile
+++ b/netsniff-ng/Makefile
@@ -66,6 +66,7 @@ netsniff-ng-objs =    dissector.o \
                        timer.o \
                        mac80211.o \
                        die.o \
+                       sysctl.o \
                        netsniff-ng.o
 
 ifeq ($(CONFIG_LIBPCAP), 1)
-- 
2.4.2

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to