1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-23 00:20:52 -05:00

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>
This commit is contained in:
John Fastabend 2018-01-22 10:37:11 -08:00 committed by Daniel Borkmann
parent ede154776c
commit 8e0ef38052

View file

@ -27,6 +27,7 @@
#include <time.h> #include <time.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h> #include <sys/types.h>
#include <linux/netlink.h> #include <linux/netlink.h>
@ -447,6 +448,7 @@ enum {
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int iov_count = 1, length = 1024, rate = 1, verbose = 0; 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 opt, longindex, err, cg_fd = 0;
int test = PING_PONG; int test = PING_PONG;
char filename[256]; char filename[256];
@ -501,6 +503,11 @@ int main(int argc, char **argv)
return -1; return -1;
} }
if (setrlimit(RLIMIT_MEMLOCK, &r)) {
perror("setrlimit(RLIMIT_MEMLOCK)");
return 1;
}
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
running = 1; running = 1;