All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, David Miller <davem@davemloft.net>,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH stable 2/2] virtio-net: make all RX paths handle erors consistently
Date: Thu, 26 Dec 2013 15:28:58 +0800	[thread overview]
Message-ID: <52BBDABA.1080804@redhat.com> (raw)
In-Reply-To: <1387983339-1172-3-git-send-email-mst@redhat.com>

On 12/25/2013 10:56 PM, Michael S. Tsirkin wrote:
> receive mergeable now handles errors internally.
> Do same for big and small packet paths, otherwise
> the logic is too hard to follow.
>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> (cherry picked from commit f121159d72091f25afb22007c833e60a6845e912)
> ---
>  drivers/net/virtio_net.c | 56 +++++++++++++++++++++++++++++++-----------------
>  1 file changed, 36 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 435076f..c0ed6d5 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -297,6 +297,34 @@ static struct sk_buff *page_to_skb(struct receive_queue *rq,
>  	return skb;
>  }
>  
> +static struct sk_buff *receive_small(void *buf, unsigned int len)
> +{
> +	struct sk_buff * skb = buf;
> +
> +	len -= sizeof(struct virtio_net_hdr);
> +	skb_trim(skb, len);
> +
> +	return skb;
> +}
> +
> +static struct sk_buff *receive_big(struct net_device *dev,
> +				   struct receive_queue *rq,
> +				   void *buf)
> +{
> +	struct page *page = buf;
> +	struct sk_buff *skb = page_to_skb(rq, page, 0);
> +
> +	if (unlikely(!skb))
> +		goto err;
> +
> +	return skb;
> +
> +err:
> +	dev->stats.rx_dropped++;
> +	give_pages(rq, page);
> +	return NULL;
> +}
> +
>  static struct sk_buff *receive_mergeable(struct net_device *dev,
>  					 struct receive_queue *rq,
>  					 void *buf,
> @@ -360,7 +388,6 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
>  	struct net_device *dev = vi->dev;
>  	struct virtnet_stats *stats = this_cpu_ptr(vi->stats);
>  	struct sk_buff *skb;
> -	struct page *page;
>  	struct skb_vnet_hdr *hdr;
>  
>  	if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) {
> @@ -372,26 +399,15 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
>  			dev_kfree_skb(buf);
>  		return;
>  	}
> +	if (vi->mergeable_rx_bufs)
> +		skb = receive_mergeable(dev, rq, buf, len);
> +	else if (vi->big_packets)
> +		skb = receive_big(dev, rq, buf);
> +	else
> +		skb = receive_small(buf, len);
>  
> -	if (!vi->mergeable_rx_bufs && !vi->big_packets) {
> -		skb = buf;
> -		len -= sizeof(struct virtio_net_hdr);
> -		skb_trim(skb, len);
> -	} else {
> -		page = buf;
> -		if (vi->mergeable_rx_bufs) {
> -			skb = receive_mergeable(dev, rq, page, len);
> -			if (unlikely(!skb))
> -				return;
> -		} else {
> -			skb = page_to_skb(rq, page, len);
> -			if (unlikely(!skb)) {
> -				dev->stats.rx_dropped++;
> -				give_pages(rq, page);
> -				return;
> -			}
> -		}
> -	}
> +	if (unlikely(!skb))
> +		return;
>  
>  	hdr = skb_vnet_hdr(skb);
>  
Ack-ed by: Jason Wang <jasowang@redhat.com>

WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, netdev@vger.kernel.org
Cc: David Miller <davem@davemloft.net>,
	Rusty Russell <rusty@rustcorp.com.au>,
	virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH stable 2/2] virtio-net: make all RX paths handle erors consistently
Date: Thu, 26 Dec 2013 15:28:58 +0800	[thread overview]
Message-ID: <52BBDABA.1080804@redhat.com> (raw)
In-Reply-To: <1387983339-1172-3-git-send-email-mst@redhat.com>

On 12/25/2013 10:56 PM, Michael S. Tsirkin wrote:
> receive mergeable now handles errors internally.
> Do same for big and small packet paths, otherwise
> the logic is too hard to follow.
>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> (cherry picked from commit f121159d72091f25afb22007c833e60a6845e912)
> ---
>  drivers/net/virtio_net.c | 56 +++++++++++++++++++++++++++++++-----------------
>  1 file changed, 36 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 435076f..c0ed6d5 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -297,6 +297,34 @@ static struct sk_buff *page_to_skb(struct receive_queue *rq,
>  	return skb;
>  }
>  
> +static struct sk_buff *receive_small(void *buf, unsigned int len)
> +{
> +	struct sk_buff * skb = buf;
> +
> +	len -= sizeof(struct virtio_net_hdr);
> +	skb_trim(skb, len);
> +
> +	return skb;
> +}
> +
> +static struct sk_buff *receive_big(struct net_device *dev,
> +				   struct receive_queue *rq,
> +				   void *buf)
> +{
> +	struct page *page = buf;
> +	struct sk_buff *skb = page_to_skb(rq, page, 0);
> +
> +	if (unlikely(!skb))
> +		goto err;
> +
> +	return skb;
> +
> +err:
> +	dev->stats.rx_dropped++;
> +	give_pages(rq, page);
> +	return NULL;
> +}
> +
>  static struct sk_buff *receive_mergeable(struct net_device *dev,
>  					 struct receive_queue *rq,
>  					 void *buf,
> @@ -360,7 +388,6 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
>  	struct net_device *dev = vi->dev;
>  	struct virtnet_stats *stats = this_cpu_ptr(vi->stats);
>  	struct sk_buff *skb;
> -	struct page *page;
>  	struct skb_vnet_hdr *hdr;
>  
>  	if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) {
> @@ -372,26 +399,15 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
>  			dev_kfree_skb(buf);
>  		return;
>  	}
> +	if (vi->mergeable_rx_bufs)
> +		skb = receive_mergeable(dev, rq, buf, len);
> +	else if (vi->big_packets)
> +		skb = receive_big(dev, rq, buf);
> +	else
> +		skb = receive_small(buf, len);
>  
> -	if (!vi->mergeable_rx_bufs && !vi->big_packets) {
> -		skb = buf;
> -		len -= sizeof(struct virtio_net_hdr);
> -		skb_trim(skb, len);
> -	} else {
> -		page = buf;
> -		if (vi->mergeable_rx_bufs) {
> -			skb = receive_mergeable(dev, rq, page, len);
> -			if (unlikely(!skb))
> -				return;
> -		} else {
> -			skb = page_to_skb(rq, page, len);
> -			if (unlikely(!skb)) {
> -				dev->stats.rx_dropped++;
> -				give_pages(rq, page);
> -				return;
> -			}
> -		}
> -	}
> +	if (unlikely(!skb))
> +		return;
>  
>  	hdr = skb_vnet_hdr(skb);
>  
Ack-ed by: Jason Wang <jasowang@redhat.com>

  reply	other threads:[~2013-12-26  7:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-25 14:56 [PATCH stable 0/2] virtio-net: backport error handling bugfix Michael S. Tsirkin
2013-12-25 14:56 ` [PATCH stable 1/2] virtio_net: fix error handling for mergeable buffers Michael S. Tsirkin
2013-12-25 14:56   ` Michael S. Tsirkin
2013-12-25 18:33   ` Michael Dalton
2013-12-25 18:33     ` Michael Dalton
2013-12-25 19:19     ` Michael S. Tsirkin
2013-12-25 19:19       ` Michael S. Tsirkin
2013-12-26  6:35       ` Michael Dalton
2013-12-26  6:35         ` Michael Dalton
2013-12-26  7:28   ` Jason Wang
2013-12-26  7:28     ` Jason Wang
2013-12-25 14:56 ` [PATCH stable 2/2] virtio-net: make all RX paths handle erors consistently Michael S. Tsirkin
2013-12-25 14:56   ` Michael S. Tsirkin
2013-12-26  7:28   ` Jason Wang [this message]
2013-12-26  7:28     ` Jason Wang
2013-12-26  7:31   ` Zhi Yong Wu
2013-12-26  7:31     ` Zhi Yong Wu
2013-12-25 20:13 ` [PATCH stable] virtio_net: don't leak memory or block when too many frags Michael S. Tsirkin
2013-12-25 20:13   ` Michael S. Tsirkin
2013-12-26  6:35   ` Michael Dalton
2013-12-26  6:35     ` Michael Dalton

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=52BBDABA.1080804@redhat.com \
    --to=jasowang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.