From: Lorenz Bauer <lmb@cloudflare.com>
To: john.fastabend@gmail.com, Shuah Khan <shuah@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Cc: kernel-team@cloudflare.com, Lorenz Bauer <lmb@cloudflare.com>,
linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH bpf-next v3 09/12] selftests: bpf: don't listen() on UDP sockets
Date: Wed, 4 Mar 2020 11:13:14 +0100 [thread overview]
Message-ID: <20200304101318.5225-10-lmb@cloudflare.com> (raw)
In-Reply-To: <20200304101318.5225-1-lmb@cloudflare.com>
Most tests for TCP sockmap can be adapted to UDP sockmap if the
listen call is skipped. Rename listen_loopback, etc. to socket_loopback
and skip listen() for SOCK_DGRAM.
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
.../selftests/bpf/prog_tests/sockmap_listen.c | 47 ++++++++++---------
1 file changed, 25 insertions(+), 22 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
index b1b2acea0638..4ba41dd26d6b 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
@@ -230,7 +230,7 @@ static int enable_reuseport(int s, int progfd)
return 0;
}
-static int listen_loopback_reuseport(int family, int sotype, int progfd)
+static int socket_loopback_reuseport(int family, int sotype, int progfd)
{
struct sockaddr_storage addr;
socklen_t len;
@@ -249,6 +249,9 @@ static int listen_loopback_reuseport(int family, int sotype, int progfd)
if (err)
goto close;
+ if (sotype == SOCK_DGRAM)
+ return s;
+
err = xlisten(s, SOMAXCONN);
if (err)
goto close;
@@ -259,9 +262,9 @@ static int listen_loopback_reuseport(int family, int sotype, int progfd)
return -1;
}
-static int listen_loopback(int family, int sotype)
+static int socket_loopback(int family, int sotype)
{
- return listen_loopback_reuseport(family, sotype, -1);
+ return socket_loopback_reuseport(family, sotype, -1);
}
static void test_insert_invalid(int family, int sotype, int mapfd)
@@ -333,7 +336,7 @@ static void test_insert_listening(int family, int sotype, int mapfd)
u32 key;
int s;
- s = listen_loopback(family, sotype);
+ s = socket_loopback(family, sotype);
if (s < 0)
return;
@@ -349,7 +352,7 @@ static void test_delete_after_insert(int family, int sotype, int mapfd)
u32 key;
int s;
- s = listen_loopback(family, sotype);
+ s = socket_loopback(family, sotype);
if (s < 0)
return;
@@ -366,7 +369,7 @@ static void test_delete_after_close(int family, int sotype, int mapfd)
u64 value;
u32 key;
- s = listen_loopback(family, sotype);
+ s = socket_loopback(family, sotype);
if (s < 0)
return;
@@ -390,7 +393,7 @@ static void test_lookup_after_insert(int family, int sotype, int mapfd)
u32 key;
int s;
- s = listen_loopback(family, sotype);
+ s = socket_loopback(family, sotype);
if (s < 0)
return;
@@ -417,7 +420,7 @@ static void test_lookup_after_delete(int family, int sotype, int mapfd)
u64 value;
u32 key;
- s = listen_loopback(family, sotype);
+ s = socket_loopback(family, sotype);
if (s < 0)
return;
@@ -439,7 +442,7 @@ static void test_lookup_32_bit_value(int family, int sotype, int mapfd)
u32 key, value32;
int err, s;
- s = listen_loopback(family, sotype);
+ s = socket_loopback(family, sotype);
if (s < 0)
return;
@@ -470,11 +473,11 @@ static void test_update_listening(int family, int sotype, int mapfd)
u64 value;
u32 key;
- s1 = listen_loopback(family, sotype);
+ s1 = socket_loopback(family, sotype);
if (s1 < 0)
return;
- s2 = listen_loopback(family, sotype);
+ s2 = socket_loopback(family, sotype);
if (s2 < 0)
goto close_s1;
@@ -500,7 +503,7 @@ static void test_destroy_orphan_child(int family, int sotype, int mapfd)
u64 value;
u32 key;
- s = listen_loopback(family, sotype);
+ s = socket_loopback(family, sotype);
if (s < 0)
return;
@@ -534,7 +537,7 @@ static void test_clone_after_delete(int family, int sotype, int mapfd)
u64 value;
u32 key;
- s = listen_loopback(family, sotype);
+ s = socket_loopback(family, sotype);
if (s < 0)
return;
@@ -570,7 +573,7 @@ static void test_accept_after_delete(int family, int sotype, int mapfd)
socklen_t len;
u64 value;
- s = listen_loopback(family, sotype);
+ s = socket_loopback(family, sotype);
if (s == -1)
return;
@@ -624,7 +627,7 @@ static void test_accept_before_delete(int family, int sotype, int mapfd)
socklen_t len;
u64 value;
- s = listen_loopback(family, sotype);
+ s = socket_loopback(family, sotype);
if (s == -1)
return;
@@ -735,7 +738,7 @@ static void test_syn_recv_insert_delete(int family, int sotype, int mapfd)
int err, s;
u64 value;
- s = listen_loopback(family, sotype | SOCK_NONBLOCK);
+ s = socket_loopback(family, sotype | SOCK_NONBLOCK);
if (s < 0)
return;
@@ -877,7 +880,7 @@ static void redir_to_connected(int family, int sotype, int sock_mapfd,
zero_verdict_count(verd_mapfd);
- s = listen_loopback(family, sotype | SOCK_NONBLOCK);
+ s = socket_loopback(family, sotype | SOCK_NONBLOCK);
if (s < 0)
return;
@@ -1009,7 +1012,7 @@ static void redir_to_listening(int family, int sotype, int sock_mapfd,
zero_verdict_count(verd_mapfd);
- s = listen_loopback(family, sotype | SOCK_NONBLOCK);
+ s = socket_loopback(family, sotype | SOCK_NONBLOCK);
if (s < 0)
return;
@@ -1120,7 +1123,7 @@ static void test_reuseport_select_listening(int family, int sotype,
zero_verdict_count(verd_map);
- s = listen_loopback_reuseport(family, sotype, reuseport_prog);
+ s = socket_loopback_reuseport(family, sotype, reuseport_prog);
if (s < 0)
return;
@@ -1174,7 +1177,7 @@ static void test_reuseport_select_connected(int family, int sotype,
zero_verdict_count(verd_map);
- s = listen_loopback_reuseport(family, sotype, reuseport_prog);
+ s = socket_loopback_reuseport(family, sotype, reuseport_prog);
if (s < 0)
return;
@@ -1249,11 +1252,11 @@ static void test_reuseport_mixed_groups(int family, int sotype, int sock_map,
zero_verdict_count(verd_map);
/* Create two listeners, each in its own reuseport group */
- s1 = listen_loopback_reuseport(family, sotype, reuseport_prog);
+ s1 = socket_loopback_reuseport(family, sotype, reuseport_prog);
if (s1 < 0)
return;
- s2 = listen_loopback_reuseport(family, sotype, reuseport_prog);
+ s2 = socket_loopback_reuseport(family, sotype, reuseport_prog);
if (s2 < 0)
goto close_srv1;
--
2.20.1
next prev parent reply other threads:[~2020-03-04 10:13 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-04 10:13 [PATCH bpf-next v3 00/12] bpf: sockmap, sockhash: support storing UDP sockets Lorenz Bauer
2020-03-04 10:13 ` [PATCH bpf-next v3 01/12] bpf: sockmap: only check ULP for TCP sockets Lorenz Bauer
2020-03-05 12:00 ` Jakub Sitnicki
2020-03-06 14:56 ` John Fastabend
2020-03-04 10:13 ` [PATCH bpf-next v3 02/12] skmsg: update saved hooks only once Lorenz Bauer
2020-03-05 12:03 ` Jakub Sitnicki
2020-03-06 15:00 ` John Fastabend
2020-03-04 10:13 ` [PATCH bpf-next v3 03/12] bpf: tcp: move assertions into tcp_bpf_get_proto Lorenz Bauer
2020-03-05 12:10 ` Jakub Sitnicki
2020-03-06 15:25 ` John Fastabend
2020-03-04 10:13 ` [PATCH bpf-next v3 04/12] bpf: tcp: guard declarations with CONFIG_NET_SOCK_MSG Lorenz Bauer
2020-03-05 12:14 ` Jakub Sitnicki
2020-03-04 10:13 ` [PATCH bpf-next v3 05/12] bpf: sockmap: move generic sockmap hooks from BPF TCP Lorenz Bauer
2020-03-05 12:32 ` Jakub Sitnicki
2020-03-06 15:28 ` John Fastabend
2020-03-04 10:13 ` [PATCH bpf-next v3 06/12] bpf: sockmap: simplify sock_map_init_proto Lorenz Bauer
2020-03-05 12:39 ` Jakub Sitnicki
2020-03-06 15:29 ` John Fastabend
2020-03-04 10:13 ` [PATCH bpf-next v3 07/12] bpf: add sockmap hooks for UDP sockets Lorenz Bauer
2020-03-06 15:44 ` John Fastabend
2020-03-04 10:13 ` [PATCH bpf-next v3 08/12] bpf: sockmap: add UDP support Lorenz Bauer
2020-03-06 15:31 ` John Fastabend
2020-03-04 10:13 ` Lorenz Bauer [this message]
2020-03-05 12:53 ` [PATCH bpf-next v3 09/12] selftests: bpf: don't listen() on UDP sockets Jakub Sitnicki
2020-03-06 15:36 ` John Fastabend
2020-03-04 10:13 ` [PATCH bpf-next v3 10/12] selftests: bpf: add tests for UDP sockets in sockmap Lorenz Bauer
2020-03-06 15:38 ` John Fastabend
2020-03-04 10:13 ` [PATCH bpf-next v3 11/12] selftests: bpf: enable UDP sockmap reuseport tests Lorenz Bauer
2020-03-05 12:56 ` Jakub Sitnicki
2020-03-06 15:39 ` John Fastabend
2020-03-04 10:13 ` [PATCH bpf-next v3 12/12] bpf, doc: update maintainers for L7 BPF Lorenz Bauer
2020-03-05 12:58 ` Jakub Sitnicki
2020-03-05 12:59 ` [PATCH bpf-next v3 00/12] bpf: sockmap, sockhash: support storing UDP sockets Jakub Sitnicki
2020-03-06 15:45 ` John Fastabend
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200304101318.5225-10-lmb@cloudflare.com \
--to=lmb@cloudflare.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@cloudflare.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).