diff options
| author | Michal Luczaj <mhal@rbox.co> | 2025-01-28 14:15:29 +0100 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2025-01-29 18:50:37 -0800 |
| commit | 852a00c4281d3c4cf82020421cc9b5b05d53e93f (patch) | |
| tree | 45a04d944cb83eb833cdaa5a7ed772d993f76ea8 /tools/testing/vsock/vsock_test.c | |
| parent | aa388c72113b7458127b709bdd7d3628af26e9b4 (diff) | |
vsock/test: Introduce vsock_bind()
Add a helper for socket()+bind(). Adapt callers.
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Luigi Leonardi <leonardi@redhat.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://patch.msgid.link/20250128-vsock-transport-vs-autobind-v3-3-1cf57065b770@rbox.co
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/testing/vsock/vsock_test.c')
| -rw-r--r-- | tools/testing/vsock/vsock_test.c | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c index 1eebbc0d5f61..daa4f3ca9b6e 100644 --- a/tools/testing/vsock/vsock_test.c +++ b/tools/testing/vsock/vsock_test.c @@ -113,24 +113,9 @@ static void test_stream_bind_only_client(const struct test_opts *opts) static void test_stream_bind_only_server(const struct test_opts *opts) { - union { - struct sockaddr sa; - struct sockaddr_vm svm; - } addr = { - .svm = { - .svm_family = AF_VSOCK, - .svm_port = opts->peer_port, - .svm_cid = VMADDR_CID_ANY, - }, - }; int fd; - fd = socket(AF_VSOCK, SOCK_STREAM, 0); - - if (bind(fd, &addr.sa, sizeof(addr.svm)) < 0) { - perror("bind"); - exit(EXIT_FAILURE); - } + fd = vsock_bind(VMADDR_CID_ANY, opts->peer_port, SOCK_STREAM); /* Notify the client that the server is ready */ control_writeln("BIND"); |
