diff mbox series

[bpf-next,09/15] selftests/bpf: Use start_server_str in crypto_sanity

Message ID 11d7a17f7245e17d29c1001461af6260b62ea610.1721771340.git.tanggeliang@kylinos.cn
State New
Headers show
Series [bpf-next,01/15] selftests/bpf: Use start_server_str in skc_to_unix_sock | expand

Commit Message

Geliang Tang July 23, 2024, 10:22 p.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

This patch uses start_server_str() to start a AF_ALG server in test
crypto_sanity, since no listen is needed in this test, nolisten flag
of network_helper_opts is set.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 .../testing/selftests/bpf/prog_tests/crypto_sanity.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/crypto_sanity.c b/tools/testing/selftests/bpf/prog_tests/crypto_sanity.c
index b1a3a49a822a..9b7a26c79123 100644
--- a/tools/testing/selftests/bpf/prog_tests/crypto_sanity.c
+++ b/tools/testing/selftests/bpf/prog_tests/crypto_sanity.c
@@ -20,16 +20,12 @@  static int opfd = -1, tfmfd = -1;
 static const char algo[] = "ecb(aes)";
 static int init_afalg(void)
 {
-	struct sockaddr_alg sa = {
-		.salg_family = AF_ALG,
-		.salg_type = "skcipher",
-		.salg_name = "ecb(aes)"
+	struct network_helper_opts opts = {
+		.nolisten = true,
 	};
 
-	tfmfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
-	if (tfmfd == -1)
-		return errno;
-	if (bind(tfmfd, (struct sockaddr *)&sa, sizeof(sa)) == -1)
+	tfmfd = start_server_str(AF_ALG, SOCK_SEQPACKET, "skcipher ecb(aes)", 0, &opts);
+	if (!ASSERT_OK_FD(tfmfd, "start_server_addr"))
 		return errno;
 	if (setsockopt(tfmfd, SOL_ALG, ALG_SET_KEY, crypto_key, 16) == -1)
 		return errno;