#ifdef HAVE_PACKET_EBPF
+#include <sys/time.h>
+#include <sys/resource.h>
+
#include "util-ebpf.h"
#include "util-cpu.h"
return -1;
}
+ /* Sending the eBPF code to the kernel requires a large amount of
+ * locked memory so we set it to unlimited to avoid a ENOPERM error */
+ struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
+ if (setrlimit(RLIMIT_MEMLOCK, &r) != 0) {
+ SCLogError(SC_ERR_MEM_ALLOC, "Unable to lock memory: %s (%d)",
+ strerror(errno), errno);
+ return -1;
+ }
+
bpfobj = bpf_object__open(path);
if (libbpf_get_error(bpfobj)) {
if (err < 0) {
if (err == -EPERM) {
SCLogError(SC_ERR_MEM_ALLOC,
- "Permission issue when loading eBPF object try to "
- "increase memlock limit: %s (%d)",
+ "Permission issue when loading eBPF object: "
+ "%s (%d)",
strerror(err),
err);
} else {