From patchwork Sat Jul 6 14:45:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13725843 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 78C5A29CA; Sat, 6 Jul 2024 14:47:06 +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=1720277226; cv=none; b=CLAsPsW8JidvFRk/k7s6V4fWPfjb76IiptT4lA7ElVlBVt76TYGJcYjP0jZeSXZQdFRYTyfeAm4yjZxUgYSFxyyAbhId3sdyZnYJwQZJUtiW+SqRR8ZujqRo9bMg2Qf/sWLz5ftwZ9fnsxmaQCTZqTIVcYqpLKRiEqJB7tUfx34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720277226; c=relaxed/simple; bh=rRP0ZiPRY0W17MVOWxZwWV5aU8LBd+K/G2ydWK7Wq+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t/ikW+3XaxB4esG3GvoFLmMmAFhfKXZ0c62xTYMNUw48oqkR0967w5rma0zL1DDPbQraQCPDFbiYB8jFDBOkkeOft6uC6xLsXJh1fOEqDtD2AUlPSY+RF3dF8nWv7u3ZgPrAhgYf/+UvwhwQtSBxHTaOzp0ZmtVvCh1Il7862Xo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZsRDpVoK; 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="ZsRDpVoK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13F14C2BD10; Sat, 6 Jul 2024 14:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720277226; bh=rRP0ZiPRY0W17MVOWxZwWV5aU8LBd+K/G2ydWK7Wq+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZsRDpVoKRgDfUdrTaFNNlxrZBGRJn9d850X26fGxYJwmY99YFVzLJ9tjNgMP9Vstw TF4V2Hz4miROXglieVcPaxcAgoniDNiE/ziKX0T8TgDCqaT3C0xPFA8dexNOU/DTc5 686U8yCFVoANf5v81aBBmveVRp0vq24vI6q+8+7Cpn1ZfPAo6NjsShFN/sMhjcHEp6 YW4IfkQOtaWFAFhFiIuWbViQan6DUS0JQXFm1renRHu5QwkI+lqdaneEfNt56euvTG ut8omie6FfxuRdgr3TkM9SIxZoBNJ+9rwtMSZyTiN31ZZZVJcqeacC3rcsJvn3eG6Y zjGI7nE3xbpSw== 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 v9 04/11] selftests/bpf: Use make_sockaddr in sockmap_ktls Date: Sat, 6 Jul 2024 22:45:49 +0800 Message-ID: <7125742ccf22a673a9ea66fa11eed0be24301516.1720276189.git.tanggeliang@kylinos.cn> 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 uses public helper make_sockaddr() exported in network_helpers.h instead of open-coding in sockmap_ktls.c. This can avoid duplicate code. Acked-by: Eduard Zingerman Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/sockmap_ktls.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c b/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c index a794aa688ab5..3c223601e8b6 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c @@ -59,23 +59,11 @@ static void test_sockmap_ktls_update_fails_when_sock_has_ulp(int family, int map { struct sockaddr_storage addr = {}; socklen_t len = sizeof(addr); - struct sockaddr_in6 *v6; - struct sockaddr_in *v4; int err, s, zero = 0; - switch (family) { - case AF_INET: - v4 = (struct sockaddr_in *)&addr; - v4->sin_family = AF_INET; - break; - case AF_INET6: - v6 = (struct sockaddr_in6 *)&addr; - v6->sin6_family = AF_INET6; - break; - default: - PRINT_FAIL("unsupported socket family %d", family); + err = make_sockaddr(family, NULL, 0, &addr, &len); + if (!ASSERT_OK(err, "make_sockaddr")) return; - } s = socket(family, SOCK_STREAM, 0); if (!ASSERT_GE(s, 0, "socket"))