diff options
author | William Tu <u9012063@gmail.com> | 2016-06-22 00:05:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-06-25 12:03:46 -0400 |
commit | eb88d58559b756065667f97ef5891b5c23c57c76 (patch) | |
tree | 90238ad85a721b7ff9658f0f1064f7bc9ffe3158 /samples | |
parent | 176275a261fbffa4e1c009b97265fabac428c891 (diff) |
samples/bpf: set max locked memory to ulimited
Signed-off-by: William Tu <u9012063@gmail.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/bpf/sockex2_user.c | 3 | ||||
-rw-r--r-- | samples/bpf/sockex3_user.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/samples/bpf/sockex2_user.c b/samples/bpf/sockex2_user.c index 29a276d766fc..8a4085c2d117 100644 --- a/samples/bpf/sockex2_user.c +++ b/samples/bpf/sockex2_user.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "bpf_load.h" | 5 | #include "bpf_load.h" |
6 | #include <unistd.h> | 6 | #include <unistd.h> |
7 | #include <arpa/inet.h> | 7 | #include <arpa/inet.h> |
8 | #include <sys/resource.h> | ||
8 | 9 | ||
9 | struct pair { | 10 | struct pair { |
10 | __u64 packets; | 11 | __u64 packets; |
@@ -13,11 +14,13 @@ struct pair { | |||
13 | 14 | ||
14 | int main(int ac, char **argv) | 15 | int main(int ac, char **argv) |
15 | { | 16 | { |
17 | struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY}; | ||
16 | char filename[256]; | 18 | char filename[256]; |
17 | FILE *f; | 19 | FILE *f; |
18 | int i, sock; | 20 | int i, sock; |
19 | 21 | ||
20 | snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); | 22 | snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); |
23 | setrlimit(RLIMIT_MEMLOCK, &r); | ||
21 | 24 | ||
22 | if (load_bpf_file(filename)) { | 25 | if (load_bpf_file(filename)) { |
23 | printf("%s", bpf_log_buf); | 26 | printf("%s", bpf_log_buf); |
diff --git a/samples/bpf/sockex3_user.c b/samples/bpf/sockex3_user.c index 2617772d060d..d4184ab5f3ac 100644 --- a/samples/bpf/sockex3_user.c +++ b/samples/bpf/sockex3_user.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "bpf_load.h" | 5 | #include "bpf_load.h" |
6 | #include <unistd.h> | 6 | #include <unistd.h> |
7 | #include <arpa/inet.h> | 7 | #include <arpa/inet.h> |
8 | #include <sys/resource.h> | ||
8 | 9 | ||
9 | struct flow_keys { | 10 | struct flow_keys { |
10 | __be32 src; | 11 | __be32 src; |
@@ -23,11 +24,13 @@ struct pair { | |||
23 | 24 | ||
24 | int main(int argc, char **argv) | 25 | int main(int argc, char **argv) |
25 | { | 26 | { |
27 | struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY}; | ||
26 | char filename[256]; | 28 | char filename[256]; |
27 | FILE *f; | 29 | FILE *f; |
28 | int i, sock; | 30 | int i, sock; |
29 | 31 | ||
30 | snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); | 32 | snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); |
33 | setrlimit(RLIMIT_MEMLOCK, &r); | ||
31 | 34 | ||
32 | if (load_bpf_file(filename)) { | 35 | if (load_bpf_file(filename)) { |
33 | printf("%s", bpf_log_buf); | 36 | printf("%s", bpf_log_buf); |