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 --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;