Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools/bpf: fix test_sockmap failure

On one of our production test machine, when running
bpf selftest test_sockmap, I got the following error:
# sudo ./test_sockmap
libbpf: failed to create map (name: 'sock_map'): Operation not permitted
libbpf: failed to load object 'test_sockmap_kern.o'
libbpf: Can't get the 0th fd from program sk_skb1: only -1 instances
......
load_bpf_file: (-1) Operation not permitted
ERROR: (-1) load bpf failed

The error is due to not-big-enough rlimit
struct rlimit r = {10 * 1024 * 1024, RLIM_INFINITY};

The test already includes "bpf_rlimit.h", which sets current
and max rlimit to RLIM_INFINITY. Let us just use it.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

authored by

Yonghong Song and committed by
Daniel Borkmann
3e1a61b3 81e167c2

-6
-6
tools/testing/selftests/bpf/test_sockmap.c
··· 1413 1413 1414 1414 int main(int argc, char **argv) 1415 1415 { 1416 - struct rlimit r = {10 * 1024 * 1024, RLIM_INFINITY}; 1417 1416 int iov_count = 1, length = 1024, rate = 1; 1418 1417 struct sockmap_options options = {0}; 1419 1418 int opt, longindex, err, cg_fd = 0; 1420 1419 char *bpf_file = BPF_SOCKMAP_FILENAME; 1421 1420 int test = PING_PONG; 1422 - 1423 - if (setrlimit(RLIMIT_MEMLOCK, &r)) { 1424 - perror("setrlimit(RLIMIT_MEMLOCK)"); 1425 - return 1; 1426 - } 1427 1421 1428 1422 if (argc < 2) 1429 1423 return test_suite();