Skip to content

Commit

Permalink
tools/bpf: adjust rlimit RLIMIT_MEMLOCK for test_verifier_log
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
yonghong-song authored and borkmann committed Nov 30, 2017
1 parent 23721a7 commit 2b27941
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/testing/selftests/bpf/test_verifier_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>

#include <linux/bpf.h>
#include <linux/filter.h>
Expand Down Expand Up @@ -131,11 +133,16 @@ static void test_log_bad(char *log, size_t log_len, int log_level)

int main(int argc, char **argv)
{
struct rlimit limit = { RLIM_INFINITY, RLIM_INFINITY };
char full_log[LOG_SIZE];
char log[LOG_SIZE];
size_t want_len;
int i;

/* allow unlimited locked memory to have more consistent error code */
if (setrlimit(RLIMIT_MEMLOCK, &limit) < 0)
perror("Unable to lift memlock rlimit");

memset(log, 1, LOG_SIZE);

/* Test incorrect attr */
Expand Down

0 comments on commit 2b27941

Please sign in to comment.