diff options
author | John Fastabend <john.fastabend@gmail.com> | 2018-01-22 13:37:11 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-01-24 04:46:59 -0500 |
commit | 8e0ef38052c81b08310a8e31a2e6da0a32359257 (patch) | |
tree | 77175c98ce2d3d79ce460254407b991bf783b5d1 | |
parent | ede154776c8bf5b1032b1d619db15485b9f34387 (diff) |
bpf: sockmap set rlimit
Avoid extra step of setting limit from cmdline and do it directly in
the program.
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r-- | samples/sockmap/sockmap_user.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/samples/sockmap/sockmap_user.c b/samples/sockmap/sockmap_user.c index fe943c903310..7c25c0c112bc 100644 --- a/samples/sockmap/sockmap_user.c +++ b/samples/sockmap/sockmap_user.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <time.h> | 27 | #include <time.h> |
28 | 28 | ||
29 | #include <sys/time.h> | 29 | #include <sys/time.h> |
30 | #include <sys/resource.h> | ||
30 | #include <sys/types.h> | 31 | #include <sys/types.h> |
31 | 32 | ||
32 | #include <linux/netlink.h> | 33 | #include <linux/netlink.h> |
@@ -447,6 +448,7 @@ enum { | |||
447 | int main(int argc, char **argv) | 448 | int main(int argc, char **argv) |
448 | { | 449 | { |
449 | int iov_count = 1, length = 1024, rate = 1, verbose = 0; | 450 | int iov_count = 1, length = 1024, rate = 1, verbose = 0; |
451 | struct rlimit r = {10 * 1024 * 1024, RLIM_INFINITY}; | ||
450 | int opt, longindex, err, cg_fd = 0; | 452 | int opt, longindex, err, cg_fd = 0; |
451 | int test = PING_PONG; | 453 | int test = PING_PONG; |
452 | char filename[256]; | 454 | char filename[256]; |
@@ -501,6 +503,11 @@ int main(int argc, char **argv) | |||
501 | return -1; | 503 | return -1; |
502 | } | 504 | } |
503 | 505 | ||
506 | if (setrlimit(RLIMIT_MEMLOCK, &r)) { | ||
507 | perror("setrlimit(RLIMIT_MEMLOCK)"); | ||
508 | return 1; | ||
509 | } | ||
510 | |||
504 | snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); | 511 | snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); |
505 | 512 | ||
506 | running = 1; | 513 | running = 1; |