From 5928ded2b402203db6fe646166b37568717d1f5a Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Thu, 22 Aug 2013 17:20:09 +0000 Subject: [PATCH] Enable Kernel BPF JIT compiler from dumpcap. svn path=/trunk/; revision=51472 --- dumpcap.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dumpcap.c b/dumpcap.c index afed5d8690..bd8dc0c824 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -171,6 +171,25 @@ static void capture_loop_stop(void); /** Close a pipe, or socket if \a from_socket is TRUE */ static void cap_pipe_close(int pipe_fd, gboolean from_socket _U_); +/* Enable kernel BPF jit compiler if available */ +int enable_kernel_bpf_jit_compiler(void) +{ + int fd; + ssize_t ret; + + const char *file = "/proc/sys/net/core/bpf_jit_enable"; + + fd = open(file, O_WRONLY); + if (fd < 0) + return -1; + + ret = write(fd, "1", (unsigned int)strlen("1")); + + close(fd); + return ret; +} + + #if !defined (__linux__) #ifndef HAVE_PCAP_BREAKLOOP /* @@ -4384,6 +4403,8 @@ main(int argc, char *argv[]) #endif /* SIGINFO */ #endif /* _WIN32 */ + enable_kernel_bpf_jit_compiler(); + /* ----------------------------------------------------------------- */ /* Privilege and capability handling */ /* Cases: */