All of lore.kernel.org
 help / color / mirror / Atom feed
From: f.storniolo95@gmail.com
To: luigi.leonardi@outlook.com, kvm@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, mst@redhat.com,
	imbrenda@linux.vnet.ibm.com, kuba@kernel.org, asias@redhat.com,
	stefanha@redhat.com, pabeni@redhat.com, sgarzare@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	Filippo Storniolo <f.storniolo95@gmail.com>
Subject: [PATCH net 3/4] test/vsock: refactor vsock_accept
Date: Fri,  3 Nov 2023 18:55:50 +0100	[thread overview]
Message-ID: <20231103175551.41025-4-f.storniolo95@gmail.com> (raw)
In-Reply-To: <20231103175551.41025-1-f.storniolo95@gmail.com>

From: Filippo Storniolo <f.storniolo95@gmail.com>

This is a preliminary patch to introduce SOCK_STREAM bind connect test.
vsock_accept() is split into vsock_listen() and vsock_accept().

Co-developed-by: Luigi Leonardi <luigi.leonardi@outlook.com>
Signed-off-by: Luigi Leonardi <luigi.leonardi@outlook.com>
Signed-off-by: Filippo Storniolo <f.storniolo95@gmail.com>
---
 tools/testing/vsock/util.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
index 698b0b44a2ee..2fc96f29bdf2 100644
--- a/tools/testing/vsock/util.c
+++ b/tools/testing/vsock/util.c
@@ -136,11 +136,8 @@ int vsock_seqpacket_connect(unsigned int cid, unsigned int port)
 	return vsock_connect(cid, port, SOCK_SEQPACKET);
 }
 
-/* Listen on <cid, port> and return the first incoming connection.  The remote
- * address is stored to clientaddrp.  clientaddrp may be NULL.
- */
-static int vsock_accept(unsigned int cid, unsigned int port,
-			struct sockaddr_vm *clientaddrp, int type)
+/* Listen on <cid, port> and return the file descriptor. */
+static int vsock_listen(unsigned int cid, unsigned int port, int type)
 {
 	union {
 		struct sockaddr sa;
@@ -152,14 +149,7 @@ static int vsock_accept(unsigned int cid, unsigned int port,
 			.svm_cid = cid,
 		},
 	};
-	union {
-		struct sockaddr sa;
-		struct sockaddr_vm svm;
-	} clientaddr;
-	socklen_t clientaddr_len = sizeof(clientaddr.svm);
 	int fd;
-	int client_fd;
-	int old_errno;
 
 	fd = socket(AF_VSOCK, type, 0);
 	if (fd < 0) {
@@ -177,6 +167,24 @@ static int vsock_accept(unsigned int cid, unsigned int port,
 		exit(EXIT_FAILURE);
 	}
 
+	return fd;
+}
+
+/* Listen on <cid, port> and return the first incoming connection.  The remote
+ * address is stored to clientaddrp.  clientaddrp may be NULL.
+ */
+static int vsock_accept(unsigned int cid, unsigned int port,
+			struct sockaddr_vm *clientaddrp, int type)
+{
+	union {
+		struct sockaddr sa;
+		struct sockaddr_vm svm;
+	} clientaddr;
+	socklen_t clientaddr_len = sizeof(clientaddr.svm);
+	int fd, client_fd, old_errno;
+
+	fd = vsock_listen(cid, port, type);
+
 	control_writeln("LISTENING");
 
 	timeout_begin(TIMEOUT);
-- 
2.41.0


  parent reply	other threads:[~2023-11-03 17:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03 17:55 [PATCH net 0/4] vsock: fix server prevents clients from reconnecting f.storniolo95
2023-11-03 17:55 ` [PATCH net 1/4] vsock/virtio: remove socket from connected/bound list on shutdown f.storniolo95
2023-11-06 10:43   ` Stefano Garzarella
2023-11-06 10:43     ` Stefano Garzarella
2023-11-03 17:55 ` [PATCH net 2/4] test/vsock fix: add missing check on socket creation f.storniolo95
2023-11-06 10:46   ` Stefano Garzarella
2023-11-06 10:46     ` Stefano Garzarella
2023-11-03 17:55 ` f.storniolo95 [this message]
2023-11-06 10:47   ` [PATCH net 3/4] test/vsock: refactor vsock_accept Stefano Garzarella
2023-11-06 10:47     ` Stefano Garzarella
2023-11-03 17:55 ` [PATCH net 4/4] test/vsock: add dobule bind connect test f.storniolo95
2023-11-06 10:48   ` Stefano Garzarella
2023-11-06 10:48     ` Stefano Garzarella
2023-11-06 10:50 ` [PATCH net 0/4] vsock: fix server prevents clients from reconnecting Stefano Garzarella
2023-11-06 10:50   ` Stefano Garzarella
2023-11-07 22:30 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231103175551.41025-4-f.storniolo95@gmail.com \
    --to=f.storniolo95@gmail.com \
    --cc=asias@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=imbrenda@linux.vnet.ibm.com \
    --cc=kuba@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luigi.leonardi@outlook.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.