mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 12:17:12 +09:00
UPSTREAM: vsock: track pkt owner vsock
[ Upstream commit36d277bac8] So that we can cancel a queued pkt later if necessary. Signed-off-by: Peng Tao <bergwolf@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit6f1848e778) Bug: 121166534 Test: Ran cuttlefish with android-4.4 + vsock adb tunnel Signed-off-by: Cody Schuffelen <schuffelen@google.com> Change-Id: I29b8bacf06eaf57a91291c1d088802c0dea7fed0
This commit is contained in:
committed by
Alistair Strachan
parent
982b533c5d
commit
2b8dd4215e
@@ -48,6 +48,8 @@ struct virtio_vsock_pkt {
|
||||
struct virtio_vsock_hdr hdr;
|
||||
struct work_struct work;
|
||||
struct list_head list;
|
||||
/* socket refcnt not held, only use for cancellation */
|
||||
struct vsock_sock *vsk;
|
||||
void *buf;
|
||||
u32 len;
|
||||
u32 off;
|
||||
@@ -56,6 +58,7 @@ struct virtio_vsock_pkt {
|
||||
|
||||
struct virtio_vsock_pkt_info {
|
||||
u32 remote_cid, remote_port;
|
||||
struct vsock_sock *vsk;
|
||||
struct msghdr *msg;
|
||||
u32 pkt_len;
|
||||
u16 type;
|
||||
|
||||
@@ -57,6 +57,7 @@ virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
|
||||
pkt->len = len;
|
||||
pkt->hdr.len = cpu_to_le32(len);
|
||||
pkt->reply = info->reply;
|
||||
pkt->vsk = info->vsk;
|
||||
|
||||
if (info->msg && len > 0) {
|
||||
pkt->buf = kmalloc(len, GFP_KERNEL);
|
||||
@@ -180,6 +181,7 @@ static int virtio_transport_send_credit_update(struct vsock_sock *vsk,
|
||||
struct virtio_vsock_pkt_info info = {
|
||||
.op = VIRTIO_VSOCK_OP_CREDIT_UPDATE,
|
||||
.type = type,
|
||||
.vsk = vsk,
|
||||
};
|
||||
|
||||
return virtio_transport_send_pkt_info(vsk, &info);
|
||||
@@ -519,6 +521,7 @@ int virtio_transport_connect(struct vsock_sock *vsk)
|
||||
struct virtio_vsock_pkt_info info = {
|
||||
.op = VIRTIO_VSOCK_OP_REQUEST,
|
||||
.type = VIRTIO_VSOCK_TYPE_STREAM,
|
||||
.vsk = vsk,
|
||||
};
|
||||
|
||||
return virtio_transport_send_pkt_info(vsk, &info);
|
||||
@@ -534,6 +537,7 @@ int virtio_transport_shutdown(struct vsock_sock *vsk, int mode)
|
||||
VIRTIO_VSOCK_SHUTDOWN_RCV : 0) |
|
||||
(mode & SEND_SHUTDOWN ?
|
||||
VIRTIO_VSOCK_SHUTDOWN_SEND : 0),
|
||||
.vsk = vsk,
|
||||
};
|
||||
|
||||
return virtio_transport_send_pkt_info(vsk, &info);
|
||||
@@ -560,6 +564,7 @@ virtio_transport_stream_enqueue(struct vsock_sock *vsk,
|
||||
.type = VIRTIO_VSOCK_TYPE_STREAM,
|
||||
.msg = msg,
|
||||
.pkt_len = len,
|
||||
.vsk = vsk,
|
||||
};
|
||||
|
||||
return virtio_transport_send_pkt_info(vsk, &info);
|
||||
@@ -581,6 +586,7 @@ static int virtio_transport_reset(struct vsock_sock *vsk,
|
||||
.op = VIRTIO_VSOCK_OP_RST,
|
||||
.type = VIRTIO_VSOCK_TYPE_STREAM,
|
||||
.reply = !!pkt,
|
||||
.vsk = vsk,
|
||||
};
|
||||
|
||||
/* Send RST only if the original pkt is not a RST pkt */
|
||||
@@ -826,6 +832,7 @@ virtio_transport_send_response(struct vsock_sock *vsk,
|
||||
.remote_cid = le64_to_cpu(pkt->hdr.src_cid),
|
||||
.remote_port = le32_to_cpu(pkt->hdr.src_port),
|
||||
.reply = true,
|
||||
.vsk = vsk,
|
||||
};
|
||||
|
||||
return virtio_transport_send_pkt_info(vsk, &info);
|
||||
|
||||
Reference in New Issue
Block a user