* [PATCH net] bpf: fix rlimit in reuseport net selftest
@ 2018-02-09 13:49 Daniel Borkmann
2018-02-09 19:11 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2018-02-09 13:49 UTC (permalink / raw)
To: davem; +Cc: naresh.kamboju, alexei.starovoitov, netdev, Daniel Borkmann
Fix two issues in the reuseport_bpf selftests that were
reported by Linaro CI:
[...]
+ ./reuseport_bpf
---- IPv4 UDP ----
Testing EBPF mod 10...
Reprograming, testing mod 5...
./reuseport_bpf: ebpf error. log:
0: (bf) r6 = r1
1: (20) r0 = *(u32 *)skb[0]
2: (97) r0 %= 10
3: (95) exit
processed 4 insns
: Operation not permitted
+ echo FAIL
[...]
---- IPv4 TCP ----
Testing EBPF mod 10...
./reuseport_bpf: failed to bind send socket: Address already in use
+ echo FAIL
[...]
For the former adjust rlimit since this was the cause of
failure for loading the BPF prog, and for the latter add
SO_REUSEADDR.
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Link: https://bugs.linaro.org/show_bug.cgi?id=3502
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
tools/testing/selftests/net/reuseport_bpf.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/reuseport_bpf.c b/tools/testing/selftests/net/reuseport_bpf.c
index 4a82174..cad14cd 100644
--- a/tools/testing/selftests/net/reuseport_bpf.c
+++ b/tools/testing/selftests/net/reuseport_bpf.c
@@ -21,6 +21,7 @@
#include <sys/epoll.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/resource.h>
#include <unistd.h>
#ifndef ARRAY_SIZE
@@ -190,11 +191,14 @@ static void send_from(struct test_params p, uint16_t sport, char *buf,
struct sockaddr * const saddr = new_any_sockaddr(p.send_family, sport);
struct sockaddr * const daddr =
new_loopback_sockaddr(p.send_family, p.recv_port);
- const int fd = socket(p.send_family, p.protocol, 0);
+ const int fd = socket(p.send_family, p.protocol, 0), one = 1;
if (fd < 0)
error(1, errno, "failed to create send socket");
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)))
+ error(1, errno, "failed to set reuseaddr");
+
if (bind(fd, saddr, sockaddr_size()))
error(1, errno, "failed to bind send socket");
@@ -433,6 +437,21 @@ void enable_fastopen(void)
}
}
+static struct rlimit rlim_old, rlim_new;
+
+static __attribute__((constructor)) void main_ctor(void)
+{
+ getrlimit(RLIMIT_MEMLOCK, &rlim_old);
+ 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)
+{
+ setrlimit(RLIMIT_MEMLOCK, &rlim_old);
+}
+
int main(void)
{
fprintf(stderr, "---- IPv4 UDP ----\n");
--
2.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] bpf: fix rlimit in reuseport net selftest
2018-02-09 13:49 [PATCH net] bpf: fix rlimit in reuseport net selftest Daniel Borkmann
@ 2018-02-09 19:11 ` David Miller
2018-02-09 19:40 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2018-02-09 19:11 UTC (permalink / raw)
To: daniel; +Cc: naresh.kamboju, alexei.starovoitov, netdev
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Fri, 9 Feb 2018 14:49:44 +0100
> Fix two issues in the reuseport_bpf selftests that were
> reported by Linaro CI:
...
> For the former adjust rlimit since this was the cause of
> failure for loading the BPF prog, and for the latter add
> SO_REUSEADDR.
>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Link: https://bugs.linaro.org/show_bug.cgi?id=3502
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Daniel, do you want me to apply this directly or will I get it from
the bpf tree soon?
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] bpf: fix rlimit in reuseport net selftest
2018-02-09 19:11 ` David Miller
@ 2018-02-09 19:40 ` Daniel Borkmann
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2018-02-09 19:40 UTC (permalink / raw)
To: David Miller; +Cc: naresh.kamboju, alexei.starovoitov, netdev
On 02/09/2018 08:11 PM, David Miller wrote:
> From: Daniel Borkmann <daniel@iogearbox.net>
> Date: Fri, 9 Feb 2018 14:49:44 +0100
>
>> Fix two issues in the reuseport_bpf selftests that were
>> reported by Linaro CI:
> ...
>> For the former adjust rlimit since this was the cause of
>> failure for loading the BPF prog, and for the latter add
>> SO_REUSEADDR.
>>
>> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
>> Link: https://bugs.linaro.org/show_bug.cgi?id=3502
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>
> Daniel, do you want me to apply this directly or will I get it from
> the bpf tree soon?
Feel free to take it directly, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-09 19:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-09 13:49 [PATCH net] bpf: fix rlimit in reuseport net selftest Daniel Borkmann
2018-02-09 19:11 ` David Miller
2018-02-09 19:40 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).