Commit b93f8877 authored by Arseny Krasnov's avatar Arseny Krasnov Committed by David S. Miller

virtio/vsock: set packet's type in virtio_transport_send_pkt_info()

There is no need to set type of packet which differs from type
of socket, so move passing type of packet from 'info' structure
to  'virtio_transport_send_pkt_info()' function. Since at current
time only stream type is supported, set it directly in 'virtio_
transport_send_pkt_info()', so callers don't need to set it.
Signed-off-by: default avatarArseny Krasnov <arseny.krasnov@kaspersky.com>
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8cb48554
...@@ -179,6 +179,8 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk, ...@@ -179,6 +179,8 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
struct virtio_vsock_pkt *pkt; struct virtio_vsock_pkt *pkt;
u32 pkt_len = info->pkt_len; u32 pkt_len = info->pkt_len;
info->type = VIRTIO_VSOCK_TYPE_STREAM;
t_ops = virtio_transport_get_ops(vsk); t_ops = virtio_transport_get_ops(vsk);
if (unlikely(!t_ops)) if (unlikely(!t_ops))
return -EFAULT; return -EFAULT;
...@@ -270,12 +272,10 @@ void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit) ...@@ -270,12 +272,10 @@ void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit)
EXPORT_SYMBOL_GPL(virtio_transport_put_credit); EXPORT_SYMBOL_GPL(virtio_transport_put_credit);
static int virtio_transport_send_credit_update(struct vsock_sock *vsk, static int virtio_transport_send_credit_update(struct vsock_sock *vsk,
int type,
struct virtio_vsock_hdr *hdr) struct virtio_vsock_hdr *hdr)
{ {
struct virtio_vsock_pkt_info info = { struct virtio_vsock_pkt_info info = {
.op = VIRTIO_VSOCK_OP_CREDIT_UPDATE, .op = VIRTIO_VSOCK_OP_CREDIT_UPDATE,
.type = type,
.vsk = vsk, .vsk = vsk,
}; };
...@@ -383,11 +383,8 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk, ...@@ -383,11 +383,8 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk,
* messages, we set the limit to a high value. TODO: experiment * messages, we set the limit to a high value. TODO: experiment
* with different values. * with different values.
*/ */
if (free_space < VIRTIO_VSOCK_MAX_PKT_BUF_SIZE) { if (free_space < VIRTIO_VSOCK_MAX_PKT_BUF_SIZE)
virtio_transport_send_credit_update(vsk, virtio_transport_send_credit_update(vsk, NULL);
VIRTIO_VSOCK_TYPE_STREAM,
NULL);
}
return total; return total;
...@@ -496,8 +493,7 @@ void virtio_transport_notify_buffer_size(struct vsock_sock *vsk, u64 *val) ...@@ -496,8 +493,7 @@ void virtio_transport_notify_buffer_size(struct vsock_sock *vsk, u64 *val)
vvs->buf_alloc = *val; vvs->buf_alloc = *val;
virtio_transport_send_credit_update(vsk, VIRTIO_VSOCK_TYPE_STREAM, virtio_transport_send_credit_update(vsk, NULL);
NULL);
} }
EXPORT_SYMBOL_GPL(virtio_transport_notify_buffer_size); EXPORT_SYMBOL_GPL(virtio_transport_notify_buffer_size);
...@@ -624,7 +620,6 @@ int virtio_transport_connect(struct vsock_sock *vsk) ...@@ -624,7 +620,6 @@ int virtio_transport_connect(struct vsock_sock *vsk)
{ {
struct virtio_vsock_pkt_info info = { struct virtio_vsock_pkt_info info = {
.op = VIRTIO_VSOCK_OP_REQUEST, .op = VIRTIO_VSOCK_OP_REQUEST,
.type = VIRTIO_VSOCK_TYPE_STREAM,
.vsk = vsk, .vsk = vsk,
}; };
...@@ -636,7 +631,6 @@ int virtio_transport_shutdown(struct vsock_sock *vsk, int mode) ...@@ -636,7 +631,6 @@ int virtio_transport_shutdown(struct vsock_sock *vsk, int mode)
{ {
struct virtio_vsock_pkt_info info = { struct virtio_vsock_pkt_info info = {
.op = VIRTIO_VSOCK_OP_SHUTDOWN, .op = VIRTIO_VSOCK_OP_SHUTDOWN,
.type = VIRTIO_VSOCK_TYPE_STREAM,
.flags = (mode & RCV_SHUTDOWN ? .flags = (mode & RCV_SHUTDOWN ?
VIRTIO_VSOCK_SHUTDOWN_RCV : 0) | VIRTIO_VSOCK_SHUTDOWN_RCV : 0) |
(mode & SEND_SHUTDOWN ? (mode & SEND_SHUTDOWN ?
...@@ -665,7 +659,6 @@ virtio_transport_stream_enqueue(struct vsock_sock *vsk, ...@@ -665,7 +659,6 @@ virtio_transport_stream_enqueue(struct vsock_sock *vsk,
{ {
struct virtio_vsock_pkt_info info = { struct virtio_vsock_pkt_info info = {
.op = VIRTIO_VSOCK_OP_RW, .op = VIRTIO_VSOCK_OP_RW,
.type = VIRTIO_VSOCK_TYPE_STREAM,
.msg = msg, .msg = msg,
.pkt_len = len, .pkt_len = len,
.vsk = vsk, .vsk = vsk,
...@@ -688,7 +681,6 @@ static int virtio_transport_reset(struct vsock_sock *vsk, ...@@ -688,7 +681,6 @@ static int virtio_transport_reset(struct vsock_sock *vsk,
{ {
struct virtio_vsock_pkt_info info = { struct virtio_vsock_pkt_info info = {
.op = VIRTIO_VSOCK_OP_RST, .op = VIRTIO_VSOCK_OP_RST,
.type = VIRTIO_VSOCK_TYPE_STREAM,
.reply = !!pkt, .reply = !!pkt,
.vsk = vsk, .vsk = vsk,
}; };
...@@ -1000,7 +992,6 @@ virtio_transport_send_response(struct vsock_sock *vsk, ...@@ -1000,7 +992,6 @@ virtio_transport_send_response(struct vsock_sock *vsk,
{ {
struct virtio_vsock_pkt_info info = { struct virtio_vsock_pkt_info info = {
.op = VIRTIO_VSOCK_OP_RESPONSE, .op = VIRTIO_VSOCK_OP_RESPONSE,
.type = VIRTIO_VSOCK_TYPE_STREAM,
.remote_cid = le64_to_cpu(pkt->hdr.src_cid), .remote_cid = le64_to_cpu(pkt->hdr.src_cid),
.remote_port = le32_to_cpu(pkt->hdr.src_port), .remote_port = le32_to_cpu(pkt->hdr.src_port),
.reply = true, .reply = true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment