public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] vhost_user: Drop packet with unsupported iovec array
@ 2025-01-21 13:16 Laurent Vivier
  2025-01-21 14:05 ` Stefano Brivio
  0 siblings, 1 reply; 2+ messages in thread
From: Laurent Vivier @ 2025-01-21 13:16 UTC (permalink / raw)
  To: passt-dev; +Cc: Laurent Vivier

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-21 14:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-21 13:16 [PATCH] vhost_user: Drop packet with unsupported iovec array Laurent Vivier
2025-01-21 14:05 ` Stefano Brivio

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).