diff mbox

[resend] fix non-mergeable buffers packet too large error handling

Message ID 1274130996.8492.7.camel@w-dls.beaverton.ibm.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

David Stevens May 17, 2010, 9:16 p.m. UTC
This patch enforces single-buffer allocation when
mergeable rx buffers is not enabled.

Reported-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David L Stevens <dlstevens@us.ibm.com>



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Michael S. Tsirkin May 18, 2010, 1:53 a.m. UTC | #1
On Mon, May 17, 2010 at 02:16:36PM -0700, David L Stevens wrote:
> This patch enforces single-buffer allocation when
> mergeable rx buffers is not enabled.
> 
> Reported-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: David L Stevens <dlstevens@us.ibm.com>

Thanks! Why are you resending?

> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index 309c570..c346304 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -361,13 +361,21 @@ static void handle_rx(struct vhost_net *net)
>  			break;
>  		}
>  		/* TODO: Should check and handle checksum. */
> -		if (vhost_has_feature(&net->dev, VIRTIO_NET_F_MRG_RXBUF) &&
> -		    memcpy_toiovecend(vq->hdr, (unsigned char *)&headcount,
> -				      offsetof(typeof(hdr), num_buffers),
> -				      sizeof hdr.num_buffers)) {
> -			vq_err(vq, "Failed num_buffers write");
> +		if (vhost_has_feature(&net->dev, VIRTIO_NET_F_MRG_RXBUF)) {
> +			if (memcpy_toiovecend(vq->hdr,
> +					      (unsigned char *)&headcount,
> +					      offsetof(typeof(hdr),
> +					      num_buffers),
> +					      sizeof hdr.num_buffers)) {
> +				vq_err(vq, "Failed num_buffers write");
> +				vhost_discard_desc(vq, headcount);
> +				break;
> +			}
> +		} else if (headcount > 1) {
> +			vq_err(vq, "rx packet too large (%d) for guest",
> +			       sock_len);
>  			vhost_discard_desc(vq, headcount);
> -			break;
> +			continue;
>  		}
>  		vhost_add_used_and_signal_n(&net->dev, vq, vq->heads,
>  					    headcount);
> 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 309c570..c346304 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -361,13 +361,21 @@  static void handle_rx(struct vhost_net *net)
 			break;
 		}
 		/* TODO: Should check and handle checksum. */
-		if (vhost_has_feature(&net->dev, VIRTIO_NET_F_MRG_RXBUF) &&
-		    memcpy_toiovecend(vq->hdr, (unsigned char *)&headcount,
-				      offsetof(typeof(hdr), num_buffers),
-				      sizeof hdr.num_buffers)) {
-			vq_err(vq, "Failed num_buffers write");
+		if (vhost_has_feature(&net->dev, VIRTIO_NET_F_MRG_RXBUF)) {
+			if (memcpy_toiovecend(vq->hdr,
+					      (unsigned char *)&headcount,
+					      offsetof(typeof(hdr),
+					      num_buffers),
+					      sizeof hdr.num_buffers)) {
+				vq_err(vq, "Failed num_buffers write");
+				vhost_discard_desc(vq, headcount);
+				break;
+			}
+		} else if (headcount > 1) {
+			vq_err(vq, "rx packet too large (%d) for guest",
+			       sock_len);
 			vhost_discard_desc(vq, headcount);
-			break;
+			continue;
 		}
 		vhost_add_used_and_signal_n(&net->dev, vq, vq->heads,
 					    headcount);