vsock_test: add SOCK_SEQPACKET tests
Implement two tests of SOCK_SEQPACKET socket: first sends data by several 'write()'s and checks that number of 'read()' were same. Second test checks MSG_TRUNC flag. Cases for connect(), bind(), etc. are not tested, because it is same as for stream socket. Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
6e90a57795
commit
41b792d7a8
@@ -84,7 +84,7 @@ void vsock_wait_remote_close(int fd)
|
||||
}
|
||||
|
||||
/* Connect to <cid, port> and return the file descriptor. */
|
||||
int vsock_stream_connect(unsigned int cid, unsigned int port)
|
||||
static int vsock_connect(unsigned int cid, unsigned int port, int type)
|
||||
{
|
||||
union {
|
||||
struct sockaddr sa;
|
||||
@@ -101,7 +101,7 @@ int vsock_stream_connect(unsigned int cid, unsigned int port)
|
||||
|
||||
control_expectln("LISTENING");
|
||||
|
||||
fd = socket(AF_VSOCK, SOCK_STREAM, 0);
|
||||
fd = socket(AF_VSOCK, type, 0);
|
||||
|
||||
timeout_begin(TIMEOUT);
|
||||
do {
|
||||
@@ -120,11 +120,21 @@ int vsock_stream_connect(unsigned int cid, unsigned int port)
|
||||
return fd;
|
||||
}
|
||||
|
||||
int vsock_stream_connect(unsigned int cid, unsigned int port)
|
||||
{
|
||||
return vsock_connect(cid, port, SOCK_STREAM);
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
int vsock_stream_accept(unsigned int cid, unsigned int port,
|
||||
struct sockaddr_vm *clientaddrp)
|
||||
static int vsock_accept(unsigned int cid, unsigned int port,
|
||||
struct sockaddr_vm *clientaddrp, int type)
|
||||
{
|
||||
union {
|
||||
struct sockaddr sa;
|
||||
@@ -145,7 +155,7 @@ int vsock_stream_accept(unsigned int cid, unsigned int port,
|
||||
int client_fd;
|
||||
int old_errno;
|
||||
|
||||
fd = socket(AF_VSOCK, SOCK_STREAM, 0);
|
||||
fd = socket(AF_VSOCK, type, 0);
|
||||
|
||||
if (bind(fd, &addr.sa, sizeof(addr.svm)) < 0) {
|
||||
perror("bind");
|
||||
@@ -189,6 +199,18 @@ int vsock_stream_accept(unsigned int cid, unsigned int port,
|
||||
return client_fd;
|
||||
}
|
||||
|
||||
int vsock_stream_accept(unsigned int cid, unsigned int port,
|
||||
struct sockaddr_vm *clientaddrp)
|
||||
{
|
||||
return vsock_accept(cid, port, clientaddrp, SOCK_STREAM);
|
||||
}
|
||||
|
||||
int vsock_seqpacket_accept(unsigned int cid, unsigned int port,
|
||||
struct sockaddr_vm *clientaddrp)
|
||||
{
|
||||
return vsock_accept(cid, port, clientaddrp, SOCK_SEQPACKET);
|
||||
}
|
||||
|
||||
/* Transmit one byte and check the return value.
|
||||
*
|
||||
* expected_ret:
|
||||
|
||||
Reference in New Issue
Block a user