From patchwork Tue Jul 23 22:22:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13740403 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A21414831C; Tue, 23 Jul 2024 22:23:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721773391; cv=none; b=aZq4Aj2VSr3xKBEblmw0PianGkkUmVWhSZJ9qZJb6kFaWdlPCyYRndbJZMbiBkpQx5z/HLm2faYn6Hg4kbSoYBMjybTQIFgEaxQIZXNnkKB3LzbilDjMt8lsW9WTZBMvIYjuSMgIANBhw6s1kRFK7VWc8LLMnMmss1Cq4sb7asg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721773391; c=relaxed/simple; bh=5om8By3O7JAi0xe/XZSca4IIUIS1286qoC70zrmf0Dk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hk34AMLIBJmOoEGNOFtwBccB93r5vKANm3JDUCUXCSA+S9KD4t7atG0VJlTi28STp+2Yg1kFh1jJ7p8yMOhL3JEoa2BSgn45yM4AoLxggqldin17n1TmFjcH+L7qqvjLkFcpOQyAynBF4puMJpM3Empw37JuhiBV7Vgoms5ryM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=acr3xK2P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="acr3xK2P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A7A9C4AF15; Tue, 23 Jul 2024 22:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721773391; bh=5om8By3O7JAi0xe/XZSca4IIUIS1286qoC70zrmf0Dk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=acr3xK2PzD3aIS+fw4f3hDCeUsa8MyFu4WJqeMIQT5/E3EPx+Km0SZvRFEn9ZIlmF ihKTGUcXH06mdmK3m54kPrnMNL2gEVEy7N9lvrAGjWQo35LDDNIuC5SSg3eN+6lICW /adU40IYjWtz9svqGYCk44f0W557TBNJkhjQHMrIE9ns2SXt/25zWffmGumxKfPE/b sZOTJ5EirkBMw9Rp0EcaEsTMBGRoTLAmnAv8jLAbufaXG9WtKNGWI9fynXUZAveLew Sdmq2i3niJ/Tt3NrQBSFZ0zNeVXHdkVTllq4GqyESWtyF4p25Gbti7dm7bXuRFVMvb BSUL/0l9GiQdg== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 08/15] selftests/bpf: Add nolisten for network_helper_opts Date: Wed, 24 Jul 2024 06:22:14 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang This patch adds a struct member "nolisten" for network_helper_opts, which is used to control whether to invoke listen() or not in start_server_addr(). Also print out a warning if backlog is set for a type not support listen for connections. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/network_helpers.c | 5 ++++- tools/testing/selftests/bpf/network_helpers.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index 8f39adbc2c16..f140a76d3d7f 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -109,11 +109,14 @@ int start_server_addr(int type, const struct sockaddr_storage *addr, socklen_t a goto error_close; } - if (type == SOCK_STREAM) { + if (!opts->nolisten && type == SOCK_STREAM) { if (listen(fd, opts->backlog ? MAX(opts->backlog, 0) : 1) < 0) { log_err("Failed to listed on socket"); goto error_close; } + } else if (opts->backlog) { + log_err("Useless network helper opts: backlog %d", + opts->backlog); } return fd; diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h index ebed1fb1bd49..16f266c53b61 100644 --- a/tools/testing/selftests/bpf/network_helpers.h +++ b/tools/testing/selftests/bpf/network_helpers.h @@ -34,6 +34,7 @@ struct network_helper_opts { * changing the "tcp_syncookies" sysctl from 1 to 2. */ int backlog; + bool nolisten; int (*post_socket_cb)(int fd, void *opts); void *cb_opts; };