From patchwork Sat Jun 22 01:23:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13708169 X-Patchwork-Delegate: bpf@iogearbox.net 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 0051D4C6B; Sat, 22 Jun 2024 01:24:05 +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=1719019446; cv=none; b=GT4Pl8j+kCthDZk6BYp+G3CuPcJsH6lGmf71aMopJbAHucZJI1QAFzv6vgplIR4ziKne+SnsclYVwfCbFcUu0uCVm1gjMIRP20BFuQyagSf3EtXgltfo1La1Goirxpw3MB/Brpq8FdtNZAn17Bs6qJyPTHUlh6HbI//1yLneAS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719019446; c=relaxed/simple; bh=bjmSYjP2RFZmTcSMLnDjwyAItZFAXOlLRE/0dxToen8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QvHcbMgwP94UPCAilLz+WyrUziVSeyQXrCtAdg0zGGWwZJTAZ9cGc00uMk6wzuEKQjzwar6lAuPSLDr51bZQNoWEC6lhodMYaSQsuR85vc0OrpomLiS2JclmHwaUY6Y/Ed137fKu0UHSOlJ+cLJEKPp9SE8H+VE0acUPSgV91ZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OMnH+dPg; 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="OMnH+dPg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A94E9C4AF0E; Sat, 22 Jun 2024 01:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719019445; bh=bjmSYjP2RFZmTcSMLnDjwyAItZFAXOlLRE/0dxToen8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OMnH+dPgXH3joL+VRQH8cay+r75KJhUjhWW7RlKCkqBeceLpyGvmle9dC3wabYKjW dzeZQ9OOxBtnxCz8KlTJiC8j3Ee2z0TQTb/kjXb4XrKTMbGOAf6t43mV5OUaMvCt8Z CbBQCKBIWzrUaTsNEyHRhf7xehPrpJ+8lagutHRZgKfb+qstxQQNc/LV013wYoBbf2 wwV6WJ2vrnCeNqEAlEkVnMLd3c4M1KCAEbNYNguGmBUQhB+/SJZ8CmvuUFbTvLc6Xn WltndDaB6Gnq2xRHvtD+G6Z1QXSidDOZnbzJukwzIIjbzOCvAwrWm4JDpHUz0exau/ 7cIwPltQQsuuQ== 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 v2 1/7] selftests/bpf: Use start_server in sockmap_ktls Date: Sat, 22 Jun 2024 09:23:41 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang Include network_helpers.h in prog_tests/sockmap_ktls.c, use public network helper start_server() instead of the local defined function tcp_server(). This can avoid duplicate code. Technically, this is not a one-for-one replacement, as start_server() also does bind() and it's listen backlog is 1, not SOMAXCONN. But the difference does not seem to matter. Acked-by: Eduard Zingerman Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/sockmap_ktls.c | 18 ++---------------- 1 file changed, 2 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..9cc881b38669 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 }; @@ -39,7 +25,7 @@ static void test_sockmap_ktls_disconnect_after_delete(int family, int map) socklen_t len = sizeof(addr); int err, cli, srv, zero = 0; - srv = tcp_server(family); + srv = start_server(family, SOCK_STREAM, NULL, 0, 0); if (srv == -1) return;