samples/bpf: set max locked memory to ulimited
authorWilliam Tu <u9012063@gmail.com>
Wed, 22 Jun 2016 04:05:58 +0000 (21:05 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 25 Jun 2016 16:03:46 +0000 (12:03 -0400)
Signed-off-by: William Tu <u9012063@gmail.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
samples/bpf/sockex2_user.c
samples/bpf/sockex3_user.c

index 29a276d766fc91fb0c0552ed5ebf0ef51146775b..8a4085c2d117acf2e1a47a8d85f6a21f7bbeff5e 100644 (file)
@@ -5,6 +5,7 @@
 #include "bpf_load.h"
 #include <unistd.h>
 #include <arpa/inet.h>
+#include <sys/resource.h>
 
 struct pair {
        __u64 packets;
@@ -13,11 +14,13 @@ struct pair {
 
 int main(int ac, char **argv)
 {
+       struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
        char filename[256];
        FILE *f;
        int i, sock;
 
        snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
+       setrlimit(RLIMIT_MEMLOCK, &r);
 
        if (load_bpf_file(filename)) {
                printf("%s", bpf_log_buf);
index 2617772d060d07d521ecacabfe93093b0bb11517..d4184ab5f3ac29897e25a43ffbc9462f900bd0ca 100644 (file)
@@ -5,6 +5,7 @@
 #include "bpf_load.h"
 #include <unistd.h>
 #include <arpa/inet.h>
+#include <sys/resource.h>
 
 struct flow_keys {
        __be32 src;
@@ -23,11 +24,13 @@ struct pair {
 
 int main(int argc, char **argv)
 {
+       struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
        char filename[256];
        FILE *f;
        int i, sock;
 
        snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
+       setrlimit(RLIMIT_MEMLOCK, &r);
 
        if (load_bpf_file(filename)) {
                printf("%s", bpf_log_buf);