Skip to content

Commit 1af7e55

Browse files
Arseny Krasnovmstsirkin
authored andcommitted
vhost/vsock: support MSG_EOR bit processing
'MSG_EOR' handling has similar logic as 'MSG_EOM' - if bit present in packet's header, reset it to 0. Then restore it back if packet processing wasn't completed. Instead of bool variable for each flag, bit mask variable was added: it has logical OR of 'MSG_EOR' and 'MSG_EOM' if needed, to restore flags, this variable is ORed with flags field of packet. Signed-off-by: Arseny Krasnov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]>
1 parent 4111659 commit 1af7e55

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

drivers/vhost/vsock.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
114114
size_t nbytes;
115115
size_t iov_len, payload_len;
116116
int head;
117-
bool restore_flag = false;
117+
u32 flags_to_restore = 0;
118118

119119
spin_lock_bh(&vsock->send_pkt_list_lock);
120120
if (list_empty(&vsock->send_pkt_list)) {
@@ -179,15 +179,20 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
179179
* created dynamically and are initialized with header
180180
* of current packet(except length). But in case of
181181
* SOCK_SEQPACKET, we also must clear message delimeter
182-
* bit(VIRTIO_VSOCK_SEQ_EOM). Otherwise, instead of one
183-
* packet with delimeter(which marks end of message),
184-
* there will be sequence of packets with delimeter
185-
* bit set. After initialized header will be copied to
186-
* rx buffer, this bit will be restored.
182+
* bit (VIRTIO_VSOCK_SEQ_EOM) and MSG_EOR bit
183+
* (VIRTIO_VSOCK_SEQ_EOR) if set. Otherwise,
184+
* there will be sequence of packets with these
185+
* bits set. After initialized header will be copied to
186+
* rx buffer, these required bits will be restored.
187187
*/
188188
if (le32_to_cpu(pkt->hdr.flags) & VIRTIO_VSOCK_SEQ_EOM) {
189189
pkt->hdr.flags &= ~cpu_to_le32(VIRTIO_VSOCK_SEQ_EOM);
190-
restore_flag = true;
190+
flags_to_restore |= VIRTIO_VSOCK_SEQ_EOM;
191+
192+
if (le32_to_cpu(pkt->hdr.flags) & VIRTIO_VSOCK_SEQ_EOR) {
193+
pkt->hdr.flags &= ~cpu_to_le32(VIRTIO_VSOCK_SEQ_EOR);
194+
flags_to_restore |= VIRTIO_VSOCK_SEQ_EOR;
195+
}
191196
}
192197
}
193198

@@ -224,8 +229,7 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
224229
* to send it with the next available buffer.
225230
*/
226231
if (pkt->off < pkt->len) {
227-
if (restore_flag)
228-
pkt->hdr.flags |= cpu_to_le32(VIRTIO_VSOCK_SEQ_EOM);
232+
pkt->hdr.flags |= cpu_to_le32(flags_to_restore);
229233

230234
/* We are queueing the same virtio_vsock_pkt to handle
231235
* the remaining bytes, and we want to deliver it

0 commit comments

Comments
 (0)