Thread (22 messages) 22 messages, 2 authors, 2021-08-06

Re: [RFC PATCH v1 3/7] vhost/vsock: support MSG_EOR bit processing

From: Arseny Krasnov <hidden>
Date: 2021-08-06 08:41:46
Also in: lkml, netdev

On 06.08.2021 10:28, Stefano Garzarella wrote:
Caution: This is an external email. Be cautious while opening links or attachments.



On Mon, Jul 26, 2021 at 07:33:38PM +0300, Arseny Krasnov wrote:
quoted
It works in the same way as 'end-of-message' bit: if packet has
'EOM' bit, also check for 'EOR' bit.

Signed-off-by: Arseny Krasnov <redacted>
---
drivers/vhost/vsock.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index 3b55de70ac77..3e2b150f9c6f 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -115,6 +115,7 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
              size_t iov_len, payload_len;
              int head;
              bool restore_msg_eom_flag = false;
+              bool restore_msg_eor_flag = false;
Since we now have 2 flags to potentially restore, we could use a single
variable (e.g. uint32_t flags_to_restore), initialized to 0.

We can set all the flags we need to restore and then simply put it
in or with the `pkt->hdr.flags` field.
quoted
              spin_lock_bh(&vsock->send_pkt_list_lock);
              if (list_empty(&vsock->send_pkt_list)) {
@@ -188,6 +189,11 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
                      if (le32_to_cpu(pkt->hdr.flags) & VIRTIO_VSOCK_SEQ_EOM) {
                              pkt->hdr.flags &= ~cpu_to_le32(VIRTIO_VSOCK_SEQ_EOM);
                              restore_msg_eom_flag = true;
+
+                              if (le32_to_cpu(pkt->hdr.flags & VIRTIO_VSOCK_SEQ_EOR)) {
                                                                ^
Here it should be `le32_to_cpu(pkt->hdr.flags) & VIRTIO_VSOCK_SEQ_EOR`
quoted
+                                      pkt->hdr.flags &= ~cpu_to_le32(VIRTIO_VSOCK_SEQ_EOR);
+                                      restore_msg_eor_flag = true;
+                              }
                      }
              }
@@ -224,9 +230,13 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
               * to send it with the next available buffer.
               */
              if (pkt->off < pkt->len) {
-                      if (restore_msg_eom_flag)
+                      if (restore_msg_eom_flag) {
                              pkt->hdr.flags |= cpu_to_le32(VIRTIO_VSOCK_SEQ_EOM);

+                              if (restore_msg_eor_flag)
+                                      pkt->hdr.flags |= cpu_to_le32(VIRTIO_VSOCK_SEQ_EOR);
+                      }
+
If we use a single variable, here we can simply do:

                        pkt->hdr.flags |= cpu_to_le32(flags_to_restore);

Stefano
Thanks, i'll prepare v2 both with spec patch. About spec: i've already sent

patch for SEQPACKET, can i prepare spec patch updating current reviewed

SEQPACKET? E.g. i'll include both EOM and EOR in one patch.


Thank You
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help