Skip to content

Commit

Permalink
bpf: sockmap set rlimit
Browse files Browse the repository at this point in the history
Avoid extra step of setting limit from cmdline and do it directly in
the program.

Signed-off-by: John Fastabend <[email protected]>
Acked-by: Martin KaFai Lau <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
  • Loading branch information
jrfastab authored and borkmann committed Jan 24, 2018
1 parent ede1547 commit 8e0ef38
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions samples/sockmap/sockmap_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <time.h>

#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>

#include <linux/netlink.h>
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8e0ef38

Please sign in to comment.