From patchwork Tue Jun 25 05:42:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13710635 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 9DB3D145A1E; Tue, 25 Jun 2024 05:42:59 +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=1719294179; cv=none; b=O00Nak7O6iMlYPjDL1KfZhgtwW+dveup1d7zZKJ04SQLOiKZrJCrh3iZbWjnDWOnVdOtuHYNbU2cw6BRh2I7naUSr9r+6WhUYQw6evE5eid3KMGGcHLv5poBm0bLUoxLt5Xl2M1w/5/1LNwfmpsbqJn2vLa5hx2LFqBHppGjiqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719294179; c=relaxed/simple; bh=RPUpwnHqWv9OF1LgymXpVyycZoyJsq5oTKQuRymN69I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=poPW86ZxWiHXQ17DxAN+YasvJkTF/n/abh6FfeiViH8ufZ7UM6LYGwkWp+sZOi0qBt+dFJB/nH6j66KyGHwkuK1nvFcU/dcjCHVb515Wlr7fozagBYujjCyMA5howrQhehPKhHJqQnfmp7OOy2d/qKeFF+wEbVbAi6GUgrxDRfA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FppMrEEl; 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="FppMrEEl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA30FC4AF0A; Tue, 25 Jun 2024 05:42:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719294179; bh=RPUpwnHqWv9OF1LgymXpVyycZoyJsq5oTKQuRymN69I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FppMrEElFJXBqWoo3/g9otLOKFdXIhSrrs3U+24R//5mO3iTR26+zOYUZsDF6GcPt iA/71p4oV4hesImPZwAExOREf27VPX8CN9J4HA3ejZpj+tQEPbQf/Qtmt5l7NWBj5l KLSWs69ErWW9iVQ9U80N0BNMY4rK1BnjI+bFOv5mFEcpAST4ajfI1UosjiEFnrV72T dwxN+UeojrDpq0a73XiYFhAgdcJkU9DGZ9NWM5G1S6m9948MO0XUAkbK1hmbjT7bzF 1hcDyNOeKyWDZfJm2FDdgdJ94c7r1gUKnDq47zIpxQ6aHRDU5xlCTCLGegKqVEOrqr 9v/63BuM+mQ+Q== 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 , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next v5 2/9] selftests/bpf: Use start_server_str in sockmap_ktls Date: Tue, 25 Jun 2024 13:42:29 +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 Include network_helpers.h in prog_tests/sockmap_ktls.c, use public network helper start_server_str() instead of local defined function tcp_server(). This can avoid duplicate code. Technically, this is not a one-for-one replacement, as start_server_str() also does bind(). But the difference does not seem to matter. Acked-by: Eduard Zingerman Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/sockmap_ktls.c | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c b/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c index 2d0796314862..4dc7933bb556 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c @@ -6,25 +6,11 @@ #include #include "test_progs.h" +#include "network_helpers.h" #define MAX_TEST_NAME 80 #define TCP_ULP 31 -static int tcp_server(int family) -{ - int err, s; - - s = socket(family, SOCK_STREAM, 0); - if (!ASSERT_GE(s, 0, "socket")) - return -1; - - err = listen(s, SOMAXCONN); - if (!ASSERT_OK(err, "listen")) - return -1; - - return s; -} - static int disconnect(int fd) { struct sockaddr unspec = { AF_UNSPEC }; @@ -35,11 +21,14 @@ static int disconnect(int fd) /* Disconnect (unhash) a kTLS socket after removing it from sockmap. */ static void test_sockmap_ktls_disconnect_after_delete(int family, int map) { + struct network_helper_opts opts = { + .backlog = SOMAXCONN, + }; struct sockaddr_storage addr = {0}; socklen_t len = sizeof(addr); int err, cli, srv, zero = 0; - srv = tcp_server(family); + srv = start_server_str(family, SOCK_STREAM, NULL, 0, &opts); if (srv == -1) return;