summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorJohn Fastabend <john.fastabend@gmail.com>2018-01-22 10:37:11 -0800
committerDaniel Borkmann <daniel@iogearbox.net>2018-01-24 10:46:59 +0100
commit8e0ef38052c81b08310a8e31a2e6da0a32359257 (patch)
tree77175c98ce2d3d79ce460254407b991bf783b5d1 /samples
parentede154776c8bf5b1032b1d619db15485b9f34387 (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>
Diffstat (limited to 'samples')
-rw-r--r--samples/sockmap/sockmap_user.c7
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 @@
#include <time.h>
#include <sys/time.h>
+#include <sys/resource.h>
#include <sys/types.h>
#include <linux/netlink.h>
@@ -447,6 +448,7 @@ enum {
int main(int argc, char **argv)
{
int iov_count = 1, length = 1024, rate = 1, verbose = 0;
+ struct rlimit r = {10 * 1024 * 1024, RLIM_INFINITY};
int opt, longindex, err, cg_fd = 0;
int test = PING_PONG;
char filename[256];
@@ -501,6 +503,11 @@ int main(int argc, char **argv)
return -1;
}
+ if (setrlimit(RLIMIT_MEMLOCK, &r)) {
+ perror("setrlimit(RLIMIT_MEMLOCK)");
+ return 1;
+ }
+
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
running = 1;