Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 262f9d81 authored by Eric Dumazet's avatar Eric Dumazet Committed by Daniel Borkmann
Browse files

bpf: do not blindly change rlimit in reuseport net selftest



If the current process has unlimited RLIMIT_MEMLOCK,
we should should leave it as is.

Fixes: 941ff6f1 ("bpf: fix rlimit in reuseport net selftest")
Signed-off-by: default avatarJohn Sperbeck <jsperbeck@google.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent e2a322a0
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -437,15 +437,20 @@ void enable_fastopen(void)
	}
}

static struct rlimit rlim_old, rlim_new;
static struct rlimit rlim_old;

static  __attribute__((constructor)) void main_ctor(void)
{
	getrlimit(RLIMIT_MEMLOCK, &rlim_old);

	if (rlim_old.rlim_cur != RLIM_INFINITY) {
		struct rlimit rlim_new;

		rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20);
		rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20);
		setrlimit(RLIMIT_MEMLOCK, &rlim_new);
	}
}

static __attribute__((destructor)) void main_dtor(void)
{