Displaying 20 results from an estimated 60 matches for "vmaddr_cid_any".
2019 Aug 01
0
[PATCH v2 07/11] VSOCK: add AF_VSOCK test cases
...opts->peer_cid, 1234);
+ if (fd < 0) {
+ perror("connect");
+ exit(EXIT_FAILURE);
+ }
+
+ send_byte(fd, 1);
+ close(fd);
+ control_writeln("CLOSED");
+}
+
+static void test_stream_client_close_server(const struct test_opts *opts)
+{
+ int fd;
+
+ fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL);
+ if (fd < 0) {
+ perror("accept");
+ exit(EXIT_FAILURE);
+ }
+
+ control_expectln("CLOSED");
+
+ send_byte(fd, -EPIPE);
+ recv_byte(fd, 1);
+ recv_byte(fd, 0);
+ close(fd);
+}
+
+static void test_stream_server_close_client(const struct test_opts *opts)
+{
+ i...
2019 Oct 09
2
[PATCH v2 07/11] VSOCK: add AF_VSOCK test cases
...E);
> + }
> +
> + send_byte(fd, 1);
> + close(fd);
> + control_writeln("CLOSED");
> +}
> +
> +static void test_stream_client_close_server(const struct test_opts *opts)
> +{
> + int fd;
> +
> + fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL);
> + if (fd < 0) {
> + perror("accept");
> + exit(EXIT_FAILURE);
> + }
> +
> + control_expectln("CLOSED");
> +
> + send_byte(fd, -EPIPE);
> + recv_byte(fd, 1);
> + recv_...
2019 Oct 09
2
[PATCH v2 07/11] VSOCK: add AF_VSOCK test cases
...E);
> + }
> +
> + send_byte(fd, 1);
> + close(fd);
> + control_writeln("CLOSED");
> +}
> +
> +static void test_stream_client_close_server(const struct test_opts *opts)
> +{
> + int fd;
> +
> + fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL);
> + if (fd < 0) {
> + perror("accept");
> + exit(EXIT_FAILURE);
> + }
> +
> + control_expectln("CLOSED");
> +
> + send_byte(fd, -EPIPE);
> + recv_byte(fd, 1);
> + recv_...
2019 Aug 01
13
[PATCH v2 00/11] VSOCK: add vsock_test test suite
The vsock_diag.ko module already has a test suite but the core AF_VSOCK
functionality has no tests. This patch series adds several test cases that
exercise AF_VSOCK SOCK_STREAM socket semantics (send/recv, connect/accept,
half-closed connections, simultaneous connections).
Stefan: Do you think we should have a single application or is better to
split it in single tests (e.g.
2019 Jul 03
3
[PATCH v2 1/3] vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock
...o_vsock *virtio_vsock_get(void)
> -{
> - return the_virtio_vsock;
> -}
> -
> static u32 virtio_transport_get_local_cid(void)
> {
> - struct virtio_vsock *vsock = virtio_vsock_get();
> + struct virtio_vsock *vsock;
> + u32 ret;
>
> - if (!vsock)
> - return VMADDR_CID_ANY;
> + rcu_read_lock();
> + vsock = rcu_dereference(the_virtio_vsock);
> + if (!vsock) {
> + ret = VMADDR_CID_ANY;
> + goto out_rcu;
> + }
>
> - return vsock->guest_cid;
> + ret = vsock->guest_cid;
> +out_rcu:
> + rcu_read_unlock();
> + return ret;
>...
2019 Jul 03
3
[PATCH v2 1/3] vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock
...o_vsock *virtio_vsock_get(void)
> -{
> - return the_virtio_vsock;
> -}
> -
> static u32 virtio_transport_get_local_cid(void)
> {
> - struct virtio_vsock *vsock = virtio_vsock_get();
> + struct virtio_vsock *vsock;
> + u32 ret;
>
> - if (!vsock)
> - return VMADDR_CID_ANY;
> + rcu_read_lock();
> + vsock = rcu_dereference(the_virtio_vsock);
> + if (!vsock) {
> + ret = VMADDR_CID_ANY;
> + goto out_rcu;
> + }
>
> - return vsock->guest_cid;
> + ret = vsock->guest_cid;
> +out_rcu:
> + rcu_read_unlock();
> + return ret;
>...
2019 Oct 23
0
[PATCH net-next 11/14] vsock: add multi-transports support
...ST will use host->guest transport
- remote CID <= VMADDR_CID_HOST will use guest->host transport
- listener sockets are not bound to any transports since no transport
operations are done on it. In this way we can create a listener
socket, also if the transports are not loaded or with VMADDR_CID_ANY
to listen on all transports.
- DGRAM sockets are handled as before, since only the vmci_transport
provides this feature.
Signed-off-by: Stefano Garzarella <sgarzare at redhat.com>
---
RFC -> v1:
- documented VSOCK_TRANSPORT_F_* flags
- fixed vsock_assign_transport() when the socket is...
2019 Sep 27
0
[RFC PATCH 10/13] vsock: add multi-transports support
...ST will use host->guest transport
- remote CID <= VMADDR_CID_HOST will use guest->host transport
- listener sockets are not bound to any transports since no transport
operations are done on it. In this way we can create a listener
socket, also if the transports are not loaded or with VMADDR_CID_ANY
to listen on all transports.
- DGRAM sockets are handled as before, since only the vmci_transport
provides this feature.
Signed-off-by: Stefano Garzarella <sgarzare at redhat.com>
---
RFC:
- I'd like to move MODULE_ALIAS_NETPROTO(PF_VSOCK) to af_vsock.c.
@Jorgen could this break th...
2019 Jul 04
2
[PATCH v2 1/3] vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock
...sock;
>>> -}
>>> -
>>> static u32 virtio_transport_get_local_cid(void)
>>> {
>>> - struct virtio_vsock *vsock = virtio_vsock_get();
>>> + struct virtio_vsock *vsock;
>>> + u32 ret;
>>> - if (!vsock)
>>> - return VMADDR_CID_ANY;
>>> + rcu_read_lock();
>>> + vsock = rcu_dereference(the_virtio_vsock);
>>> + if (!vsock) {
>>> + ret = VMADDR_CID_ANY;
>>> + goto out_rcu;
>>> + }
>>> - return vsock->guest_cid;
>>> + ret = vsock->guest_cid;
>>&...
2019 Jul 04
2
[PATCH v2 1/3] vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock
...sock;
>>> -}
>>> -
>>> static u32 virtio_transport_get_local_cid(void)
>>> {
>>> - struct virtio_vsock *vsock = virtio_vsock_get();
>>> + struct virtio_vsock *vsock;
>>> + u32 ret;
>>> - if (!vsock)
>>> - return VMADDR_CID_ANY;
>>> + rcu_read_lock();
>>> + vsock = rcu_dereference(the_virtio_vsock);
>>> + if (!vsock) {
>>> + ret = VMADDR_CID_ANY;
>>> + goto out_rcu;
>>> + }
>>> - return vsock->guest_cid;
>>> + ret = vsock->guest_cid;
>>&...
2019 Sep 27
0
[RFC PATCH 09/13] hv_sock: set VMADDR_CID_HOST in the hvs_remote_addr_init()
Remote peer is always the host, so we set VMADDR_CID_HOST as
remote CID instead of VMADDR_CID_ANY.
Signed-off-by: Stefano Garzarella <sgarzare at redhat.com>
---
net/vmw_vsock/hyperv_transport.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
index 4f47af2054dd..306310794522 100644
--- a/net/vmw_vs...
2019 Sep 27
0
[RFC PATCH 13/13] vsock: fix bind() behaviour taking care of CID
...ort == vsk->local_addr.svm_port)
+ list_for_each_entry(vsk, vsock_bound_sockets(addr), bound_table) {
+ if (vsock_addr_equals_addr(addr, &vsk->local_addr))
return sk_vsock(vsk);
+ if (addr->svm_port == vsk->local_addr.svm_port &&
+ (vsk->local_addr.svm_cid == VMADDR_CID_ANY ||
+ addr->svm_cid == VMADDR_CID_ANY))
+ return sk_vsock(vsk);
+ }
+
return NULL;
}
--
2.21.0
2019 Oct 23
0
[PATCH net-next 14/14] vsock: fix bind() behaviour taking care of CID
...ort == vsk->local_addr.svm_port)
+ list_for_each_entry(vsk, vsock_bound_sockets(addr), bound_table) {
+ if (vsock_addr_equals_addr(addr, &vsk->local_addr))
return sk_vsock(vsk);
+ if (addr->svm_port == vsk->local_addr.svm_port &&
+ (vsk->local_addr.svm_cid == VMADDR_CID_ANY ||
+ addr->svm_cid == VMADDR_CID_ANY))
+ return sk_vsock(vsk);
+ }
+
return NULL;
}
--
2.21.0
2023 Aug 31
0
[RFC PATCH v2 2/2] test/vsock: shutdowned socket test
...;
>+ exit(EXIT_FAILURE);
>+ }
>+
>+ test_stream_check_sigpipe(fd);
>+
>+ control_writeln("CLIENTDONE");
>+
>+ close(fd);
>+}
>+
>+static void test_stream_shutwr_server(const struct test_opts *opts)
>+{
>+ int fd;
>+
>+ fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL);
>+ if (fd < 0) {
>+ perror("accept");
>+ exit(EXIT_FAILURE);
>+ }
>+
>+ control_expectln("CLIENTDONE");
>+
>+ close(fd);
>+}
>+
>+static void test_stream_shutrd_client(const struct test_opts *opts)
>+{
>+ int fd;
>+
&g...
2019 Nov 11
2
[PATCH net-next 11/14] vsock: add multi-transports support
...st
> on a listener socket).
How about allowing the transport to be set during bind as well? That
would allow an application to ensure that it is using a specific transport,
i.e., if it binds to the host CID, it will use H2G, and if it binds to something
else it will use G2H? You can still use VMADDR_CID_ANY if you want to
initially listen to both transports.
> The remote CID is used to decide which transport to use:
> - remote CID > VMADDR_CID_HOST will use host->guest transport
> - remote CID <= VMADDR_CID_HOST will use guest->host transport
> - listener sockets are no...
2019 Nov 11
2
[PATCH net-next 11/14] vsock: add multi-transports support
...st
> on a listener socket).
How about allowing the transport to be set during bind as well? That
would allow an application to ensure that it is using a specific transport,
i.e., if it binds to the host CID, it will use H2G, and if it binds to something
else it will use G2H? You can still use VMADDR_CID_ANY if you want to
initially listen to both transports.
> The remote CID is used to decide which transport to use:
> - remote CID > VMADDR_CID_HOST will use host->guest transport
> - remote CID <= VMADDR_CID_HOST will use guest->host transport
> - listener sockets are no...
2019 Dec 18
13
[PATCH net-next v3 00/11] VSOCK: add vsock_test test suite
The vsock_diag.ko module already has a test suite but the core AF_VSOCK
functionality has no tests. This patch series adds several test cases that
exercise AF_VSOCK SOCK_STREAM socket semantics (send/recv, connect/accept,
half-closed connections, simultaneous connections).
The v1 of this series was originally sent by Stefan.
v3:
- Patch 6:
* check the byte received in the recv_byte()
* use
2019 Sep 27
0
[RFC PATCH 04/13] vsock: add 'transport' member in the struct vsock_sock
...ruct sockaddr_vm *addr)
* like AF_INET prevents binding to a non-local IP address (in most
* cases), we only allow binding to the local CID.
*/
- cid = transport->get_local_cid();
+ cid = vsk->transport->get_local_cid();
if (addr->svm_cid != cid && addr->svm_cid != VMADDR_CID_ANY)
return -EADDRNOTAVAIL;
@@ -586,6 +588,7 @@ struct sock *__vsock_create(struct net *net,
sk->sk_type = type;
vsk = vsock_sk(sk);
+ vsk->transport = transport_single;
vsock_addr_init(&vsk->local_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY);
vsock_addr_init(&vsk->remote_...
2019 Oct 23
0
[PATCH net-next 04/14] vsock: add 'transport' member in the struct vsock_sock
...ruct sockaddr_vm *addr)
* like AF_INET prevents binding to a non-local IP address (in most
* cases), we only allow binding to the local CID.
*/
- cid = transport->get_local_cid();
+ cid = vsk->transport->get_local_cid();
if (addr->svm_cid != cid && addr->svm_cid != VMADDR_CID_ANY)
return -EADDRNOTAVAIL;
@@ -586,6 +588,7 @@ struct sock *__vsock_create(struct net *net,
sk->sk_type = type;
vsk = vsock_sk(sk);
+ vsk->transport = transport_single;
vsock_addr_init(&vsk->local_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY);
vsock_addr_init(&vsk->remote_...
2019 Jun 28
0
[PATCH v2 1/3] vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock
...ruct virtio_vsock {
u32 guest_cid;
};
-static struct virtio_vsock *virtio_vsock_get(void)
-{
- return the_virtio_vsock;
-}
-
static u32 virtio_transport_get_local_cid(void)
{
- struct virtio_vsock *vsock = virtio_vsock_get();
+ struct virtio_vsock *vsock;
+ u32 ret;
- if (!vsock)
- return VMADDR_CID_ANY;
+ rcu_read_lock();
+ vsock = rcu_dereference(the_virtio_vsock);
+ if (!vsock) {
+ ret = VMADDR_CID_ANY;
+ goto out_rcu;
+ }
- return vsock->guest_cid;
+ ret = vsock->guest_cid;
+out_rcu:
+ rcu_read_unlock();
+ return ret;
}
static void virtio_transport_loopback_work(struct work_struc...