Skip to content

Commit daabfbc

Browse files
stefano-garzarelladavem330
authored andcommitted
vsock: add 'struct vsock_sock *' param to vsock_core_get_transport()
Since now the 'struct vsock_sock' object contains a pointer to the transport, this patch adds a parameter to the vsock_core_get_transport() to return the right transport assigned to the socket. This patch modifies also the virtio_transport_get_ops(), that uses the vsock_core_get_transport(), adding the 'struct vsock_sock *' parameter. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Jorgen Hansen <jhansen@vmware.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4c7246d commit daabfbc

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

include/net/af_vsock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static inline int vsock_core_init(const struct vsock_transport *t)
166166
void vsock_core_exit(void);
167167

168168
/* The transport may downcast this to access transport-specific functions */
169-
const struct vsock_transport *vsock_core_get_transport(void);
169+
const struct vsock_transport *vsock_core_get_transport(struct vsock_sock *vsk);
170170

171171
/**** UTILS ****/
172172

net/vmw_vsock/af_vsock.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,12 +1999,9 @@ void vsock_core_exit(void)
19991999
}
20002000
EXPORT_SYMBOL_GPL(vsock_core_exit);
20012001

2002-
const struct vsock_transport *vsock_core_get_transport(void)
2002+
const struct vsock_transport *vsock_core_get_transport(struct vsock_sock *vsk)
20032003
{
2004-
/* vsock_register_mutex not taken since only the transport uses this
2005-
* function and only while registered.
2006-
*/
2007-
return transport_single;
2004+
return vsk->transport;
20082005
}
20092006
EXPORT_SYMBOL_GPL(vsock_core_get_transport);
20102007

net/vmw_vsock/virtio_transport_common.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
/* Threshold for detecting small packets to copy */
3030
#define GOOD_COPY_LEN 128
3131

32-
static const struct virtio_transport *virtio_transport_get_ops(void)
32+
static const struct virtio_transport *
33+
virtio_transport_get_ops(struct vsock_sock *vsk)
3334
{
34-
const struct vsock_transport *t = vsock_core_get_transport();
35+
const struct vsock_transport *t = vsock_core_get_transport(vsk);
3536

3637
return container_of(t, struct virtio_transport, transport);
3738
}
@@ -168,7 +169,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
168169
struct virtio_vsock_pkt *pkt;
169170
u32 pkt_len = info->pkt_len;
170171

171-
src_cid = virtio_transport_get_ops()->transport.get_local_cid();
172+
src_cid = virtio_transport_get_ops(vsk)->transport.get_local_cid();
172173
src_port = vsk->local_addr.svm_port;
173174
if (!info->remote_cid) {
174175
dst_cid = vsk->remote_addr.svm_cid;
@@ -201,7 +202,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
201202

202203
virtio_transport_inc_tx_pkt(vvs, pkt);
203204

204-
return virtio_transport_get_ops()->send_pkt(pkt);
205+
return virtio_transport_get_ops(vsk)->send_pkt(pkt);
205206
}
206207

207208
static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,

0 commit comments

Comments
 (0)