diff options
author | Eric Dumazet <edumazet@google.com> | 2018-10-05 22:38:46 -0400 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-10-08 04:30:55 -0400 |
commit | 262f9d811c7608f1e74258ceecfe1fa213bdf912 (patch) | |
tree | 34c246bea7c2c7a7b737e879118098bb521b797a /tools | |
parent | e2a322a0c8ce3d825e8a56c063ce3f81b719083c (diff) |
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: 941ff6f11c02 ("bpf: fix rlimit in reuseport net selftest")
Signed-off-by: John Sperbeck <jsperbeck@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/net/reuseport_bpf.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/testing/selftests/net/reuseport_bpf.c b/tools/testing/selftests/net/reuseport_bpf.c index cad14cd0ea92..b5277106df1f 100644 --- a/tools/testing/selftests/net/reuseport_bpf.c +++ b/tools/testing/selftests/net/reuseport_bpf.c | |||
@@ -437,14 +437,19 @@ void enable_fastopen(void) | |||
437 | } | 437 | } |
438 | } | 438 | } |
439 | 439 | ||
440 | static struct rlimit rlim_old, rlim_new; | 440 | static struct rlimit rlim_old; |
441 | 441 | ||
442 | static __attribute__((constructor)) void main_ctor(void) | 442 | static __attribute__((constructor)) void main_ctor(void) |
443 | { | 443 | { |
444 | getrlimit(RLIMIT_MEMLOCK, &rlim_old); | 444 | getrlimit(RLIMIT_MEMLOCK, &rlim_old); |
445 | rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20); | 445 | |
446 | rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20); | 446 | if (rlim_old.rlim_cur != RLIM_INFINITY) { |
447 | setrlimit(RLIMIT_MEMLOCK, &rlim_new); | 447 | struct rlimit rlim_new; |
448 | |||
449 | rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20); | ||
450 | rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20); | ||
451 | setrlimit(RLIMIT_MEMLOCK, &rlim_new); | ||
452 | } | ||
448 | } | 453 | } |
449 | 454 | ||
450 | static __attribute__((destructor)) void main_dtor(void) | 455 | static __attribute__((destructor)) void main_dtor(void) |