From: Geliang Tang <tanggeliang@xxxxxxxxxx> The types "sotype | SOCK_NONBLOCK" are passed to socket_loopback_reuseport by some tests in sockmap_listen.c, so they must be handled in helper start_server_addr() too. This patch uses SOCK_TYPE_MASK to clear useless bits of "type" before check whether it supports listen for connections. Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx> --- tools/testing/selftests/bpf/network_helpers.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index 6b6734b893e4..919b691c2699 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -28,6 +28,9 @@ #define IPPROTO_MPTCP 262 #endif +#define SOCK_MAX (SOCK_PACKET + 1) +#define SOCK_TYPE_MASK 0xf + #define clean_errno() (errno == 0 ? "None" : strerror(errno)) #define log_err(MSG, ...) ({ \ int __save = errno; \ @@ -121,6 +124,9 @@ int start_server_addr(int type, const struct sockaddr_storage *addr, socklen_t a goto error_close; } + if (type > SOCK_MAX) + type &= SOCK_TYPE_MASK; + if (!opts->nolisten && listen_support(type)) { if (listen(fd, opts->backlog ? MAX(opts->backlog, 0) : 1) < 0) { log_err("Failed to listed on socket"); -- 2.43.0