diff options
author | Anders Broman <anders.broman@ericsson.com> | 2013-08-22 17:20:09 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2013-08-22 17:20:09 +0000 |
commit | 5928ded2b402203db6fe646166b37568717d1f5a (patch) | |
tree | b720fd0b177cc106892711623e57223a984d2c0d /dumpcap.c | |
parent | cc2a6a47a9b4156a31b4f2f28a35fa61c19f860d (diff) |
Enable Kernel BPF JIT compiler from dumpcap.
svn path=/trunk/; revision=51472
Diffstat (limited to 'dumpcap.c')
-rw-r--r-- | dumpcap.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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: */ |