public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: passt-dev@passt.top
Cc: Laurent Vivier <lvivier@redhat.com>
Subject: [PATCH] vhost_user: Drop packet with unsupported iovec array
Date: Tue, 21 Jan 2025 14:16:02 +0100	[thread overview]
Message-ID: <20250121131602.1128671-1-lvivier@redhat.com> (raw)

If the iovec array cannot be managed, drop it rather than
passing the second entry to tap_add_packet().

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 vu_common.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/vu_common.c b/vu_common.c
index aa5ca7b0e750..f43d8ac45748 100644
--- a/vu_common.c
+++ b/vu_common.c
@@ -195,15 +195,17 @@ static void vu_handle_tx(struct vu_dev *vdev, int index,
 				        hdrlen);
 		} else {
 			/* vnet header can be in a separate iovec */
-			if (elem[count].out_num != 2)
+			if (elem[count].out_num != 2) {
 				debug("virtio-net transmit queue contains more than one buffer ([%d]: %u)",
 				      count, elem[count].out_num);
-			if (elem[count].out_sg[0].iov_len != (size_t)hdrlen)
+			} else if (elem[count].out_sg[0].iov_len != (size_t)hdrlen) {
 				debug("virtio-net transmit queue entry not aligned on hdrlen ([%d]: %d != %zu)",
-				count, hdrlen, elem[count].out_sg[0].iov_len);
-			tap_add_packet(vdev->context,
-				       elem[count].out_sg[1].iov_len,
-				       (char *)elem[count].out_sg[1].iov_base);
+				      count, hdrlen, elem[count].out_sg[0].iov_len);
+			} else {
+				tap_add_packet(vdev->context,
+					       elem[count].out_sg[1].iov_len,
+					       (char *)elem[count].out_sg[1].iov_base);
+			}
 		}
 
 		count++;
-- 
@@ -195,15 +195,17 @@ static void vu_handle_tx(struct vu_dev *vdev, int index,
 				        hdrlen);
 		} else {
 			/* vnet header can be in a separate iovec */
-			if (elem[count].out_num != 2)
+			if (elem[count].out_num != 2) {
 				debug("virtio-net transmit queue contains more than one buffer ([%d]: %u)",
 				      count, elem[count].out_num);
-			if (elem[count].out_sg[0].iov_len != (size_t)hdrlen)
+			} else if (elem[count].out_sg[0].iov_len != (size_t)hdrlen) {
 				debug("virtio-net transmit queue entry not aligned on hdrlen ([%d]: %d != %zu)",
-				count, hdrlen, elem[count].out_sg[0].iov_len);
-			tap_add_packet(vdev->context,
-				       elem[count].out_sg[1].iov_len,
-				       (char *)elem[count].out_sg[1].iov_base);
+				      count, hdrlen, elem[count].out_sg[0].iov_len);
+			} else {
+				tap_add_packet(vdev->context,
+					       elem[count].out_sg[1].iov_len,
+					       (char *)elem[count].out_sg[1].iov_base);
+			}
 		}
 
 		count++;
-- 
2.47.1


             reply	other threads:[~2025-01-21 13:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-21 13:16 Laurent Vivier [this message]
2025-01-21 14:05 ` [PATCH] vhost_user: Drop packet with unsupported iovec array Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250121131602.1128671-1-lvivier@redhat.com \
    --to=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).