aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-02-13 13:35:05 -0500
committerAlexei Starovoitov <ast@kernel.org>2018-02-13 21:02:02 -0500
commit615a9474985799c8b48645b8e95a9b9f0691f56a (patch)
treec570e610ad6b8d6d522d881e0012ffb39e20bac6 /tools
parent41757dcb0c3d8446c549e55163c9fd9561fcf599 (diff)
tools/bpf: adjust rlimit RLIMIT_MEMLOCK for test_tcpbpf_user
The default rlimit RLIMIT_MEMLOCK is 64KB. In certain cases, e.g. in a test machine mimicking our production system, this test may fail due to unable to charge the required memory for map creation: # ./test_tcpbpf_user libbpf: failed to create map (name: 'global_map'): Operation not permitted libbpf: failed to load object 'test_tcpbpf_kern.o' FAILED: load_bpf_file failed for: test_tcpbpf_kern.o Changing the default rlimit RLIMIT_MEMLOCK to unlimited makes the test always pass. Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/test_tcpbpf_user.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/test_tcpbpf_user.c b/tools/testing/selftests/bpf/test_tcpbpf_user.c
index 95a370f3d378..5d73db416460 100644
--- a/tools/testing/selftests/bpf/test_tcpbpf_user.c
+++ b/tools/testing/selftests/bpf/test_tcpbpf_user.c
@@ -11,6 +11,8 @@
11#include <linux/ptrace.h> 11#include <linux/ptrace.h>
12#include <linux/bpf.h> 12#include <linux/bpf.h>
13#include <sys/ioctl.h> 13#include <sys/ioctl.h>
14#include <sys/time.h>
15#include <sys/resource.h>
14#include <sys/types.h> 16#include <sys/types.h>
15#include <sys/stat.h> 17#include <sys/stat.h>
16#include <fcntl.h> 18#include <fcntl.h>
@@ -42,6 +44,7 @@ static int bpf_find_map(const char *test, struct bpf_object *obj,
42 44
43int main(int argc, char **argv) 45int main(int argc, char **argv)
44{ 46{
47 struct rlimit limit = { RLIM_INFINITY, RLIM_INFINITY };
45 const char *file = "test_tcpbpf_kern.o"; 48 const char *file = "test_tcpbpf_kern.o";
46 struct tcpbpf_globals g = {0}; 49 struct tcpbpf_globals g = {0};
47 int cg_fd, prog_fd, map_fd; 50 int cg_fd, prog_fd, map_fd;
@@ -54,6 +57,9 @@ int main(int argc, char **argv)
54 int pid; 57 int pid;
55 int rv; 58 int rv;
56 59
60 if (setrlimit(RLIMIT_MEMLOCK, &limit) < 0)
61 perror("Unable to lift memlock rlimit");
62
57 if (argc > 1 && strcmp(argv[1], "-d") == 0) 63 if (argc > 1 && strcmp(argv[1], "-d") == 0)
58 debug_flag = true; 64 debug_flag = true;
59 65