diff options
author | Yonghong Song <yhs@fb.com> | 2017-11-30 11:52:42 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2017-11-30 13:55:18 -0500 |
commit | 2b279419567105d63f1e524bb1ac34ae8f918e5d (patch) | |
tree | 92203e2f3d39166854b9cd0513fe08d98ae9f81a /tools | |
parent | 23721a755f98ac846897a013c92cccb281c1bcc8 (diff) |
tools/bpf: adjust rlimit RLIMIT_MEMLOCK for test_verifier_log
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 prog load:
# ./test_verifier_log
Test log_level 0...
ERROR: Program load returned: ret:-1/errno:1, expected ret:-1/errno:22
Changing the default rlimit RLIMIT_MEMLOCK to unlimited makes
the test always pass.
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/test_verifier_log.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/test_verifier_log.c b/tools/testing/selftests/bpf/test_verifier_log.c index 3cc0b561489e..e9626cf5607a 100644 --- a/tools/testing/selftests/bpf/test_verifier_log.c +++ b/tools/testing/selftests/bpf/test_verifier_log.c | |||
@@ -3,6 +3,8 @@ | |||
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | #include <sys/time.h> | ||
7 | #include <sys/resource.h> | ||
6 | 8 | ||
7 | #include <linux/bpf.h> | 9 | #include <linux/bpf.h> |
8 | #include <linux/filter.h> | 10 | #include <linux/filter.h> |
@@ -131,11 +133,16 @@ static void test_log_bad(char *log, size_t log_len, int log_level) | |||
131 | 133 | ||
132 | int main(int argc, char **argv) | 134 | int main(int argc, char **argv) |
133 | { | 135 | { |
136 | struct rlimit limit = { RLIM_INFINITY, RLIM_INFINITY }; | ||
134 | char full_log[LOG_SIZE]; | 137 | char full_log[LOG_SIZE]; |
135 | char log[LOG_SIZE]; | 138 | char log[LOG_SIZE]; |
136 | size_t want_len; | 139 | size_t want_len; |
137 | int i; | 140 | int i; |
138 | 141 | ||
142 | /* allow unlimited locked memory to have more consistent error code */ | ||
143 | if (setrlimit(RLIMIT_MEMLOCK, &limit) < 0) | ||
144 | perror("Unable to lift memlock rlimit"); | ||
145 | |||
139 | memset(log, 1, LOG_SIZE); | 146 | memset(log, 1, LOG_SIZE); |
140 | 147 | ||
141 | /* Test incorrect attr */ | 148 | /* Test incorrect attr */ |