Hi,
I'm trying to run sockex2 and sockex3 but got the error:
[root@vm-dev bpf]# ./sockex2
failed to create a map: 1 Operation not permitted
Then I found that I have max locked memory set to 64K, after reconfig
to unlimited then the bpf map is created and sockex2/3 works fine.
The hash_map created in sockex2_kern.c should be less than 64k (1024
entry * (sizeof (__be32) + sizeof(struct pair)), so I don't understand
why increasing max locked memory solves the error.
Or should we increase the lock memory in the beginning?
--- a/samples/bpf/sockex2_user.c
+++ b/samples/bpf/sockex2_user.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <sys/resource.h>
#include <assert.h>
#include <linux/bpf.h>
#include "libbpf.h"
@@ -13,11 +14,13 @@ struct pair {
int main(int ac, char **argv)
{
+ struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
char filename[256];
FILE *f;
int i, sock;
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
+ setrlimit(RLIMIT_MEMLOCK, &r);
if (load_bpf_file(filename)) {
printf("%s", bpf_log_buf);
Thanks,
William