All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zoltan Kiss <zoltan.kiss@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH net 1/4] xen-netback: Fix handling frag_list on grant op error path
Date: Fri, 18 Jul 2014 18:47:55 +0100	[thread overview]
Message-ID: <53C95DCB.90806@citrix.com> (raw)
In-Reply-To: <20140718152435.GN7142@zion.uk.xensource.com>

On 18/07/14 16:24, Wei Liu wrote:
> On Thu, Jul 17, 2014 at 08:09:49PM +0100, Zoltan Kiss wrote:
>> The error handling for skb's with frag_list was completely wrong, it caused
>> double unmap attempts to happen if the error was on the first skb. Move it to
>> the right place in the loop.
>>
>> Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com>
>> Reported-by: Armin Zentai <armin.zentai@ezit.hu>
>> Cc: netdev@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> Cc: xen-devel@lists.xenproject.org
>> ---
>> diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
>> index 1844a47..604ff71 100644
>> --- a/drivers/net/xen-netback/netback.c
>> +++ b/drivers/net/xen-netback/netback.c
>> @@ -1030,10 +1030,16 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue,
>>   {
>>   	struct gnttab_map_grant_ref *gop_map = *gopp_map;
>>   	u16 pending_idx = XENVIF_TX_CB(skb)->pending_idx;
>> +	/* This points to the shinfo of the actually checked skb, which could be
>> +	 * either the first or the one on the frag_list
>> +	 */
>
> I think "checked skb" should be "skb being checked". Feel free to
> disagree as I'm not native English speaker. :-/
>
>>   	struct skb_shared_info *shinfo = skb_shinfo(skb);
>> +	/* If this is non-NULL, we are currently checking the frag_list skb, and
>> +	 * this points to the shinfo of the first one
>> +	 */
>> +	struct skb_shared_info *first_shinfo = NULL;
>>   	int nr_frags = shinfo->nr_frags;
>>   	int i, err;
>> -	struct sk_buff *first_skb = NULL;
>>
>>   	/* Check status of header. */
>>   	err = (*gopp_copy)->status;
>> @@ -1086,31 +1092,28 @@ check_frags:
>>   			xenvif_idx_unmap(queue, pending_idx);
>>   		}
>>
>> +		/* And if we found the error while checking the frag_list, unmap
>> +		 * the first skb's frags
>> +		 */
>> +		if (first_shinfo) {
>> +			for (j = 0; j < first_shinfo->nr_frags; j++) {
>> +				pending_idx = frag_get_pending_idx(&first_shinfo->frags[j]);
>> +				xenvif_idx_unmap(queue, pending_idx);
>> +			}
>> +		}
>> +
>>   		/* Remember the error: invalidate all subsequent fragments. */
>>   		err = newerr;
>>   	}
>>
>> -	if (skb_has_frag_list(skb)) {
>> -		first_skb = skb;
>> -		skb = shinfo->frag_list;
>> -		shinfo = skb_shinfo(skb);
>> +	if (skb_has_frag_list(skb) && !first_shinfo) {
>
> Will it ever come to the point that we have another skb in this skb's
> frag list? Is there any reason prevents you from looping over the
> (possible) subsequent skbs? I guess if the error is deep in the list
> it's a bit hard to bookkeep...
>
>> +		first_shinfo = skb_shinfo(skb);
>> +		shinfo = skb_shinfo(skb_shinfo(skb)->frag_list);
>
> In that case I would suggest you add
> BUG_ON(skb_has_frag_list(skb_shinfo(skb)->frag_list)). I think having
> more nested frag_list should be a bug in current design.

There are already 3 things which prevents this
- in count_requests we drop the packet if it has more than 
XEN_NETBK_LEGACY_SLOTS_MAX slots
- in get_requests there is a BUG_ON(frag_overflow > MAX_SKB_FRAGS), 
which shouldn't really due to the prev point
- in the same funciont we create a frag_list skb exactly once

  parent reply	other threads:[~2014-07-18 17:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17 19:09 [PATCH net 0/4] xen-netback: Fixing up xenvif_tx_check_gop Zoltan Kiss
2014-07-17 19:09 ` [PATCH net 1/4] xen-netback: Fix handling frag_list on grant op error path Zoltan Kiss
2014-07-17 19:09 ` Zoltan Kiss
2014-07-18 15:24   ` Wei Liu
2014-07-18 17:47     ` Zoltan Kiss
2014-07-18 17:47     ` Zoltan Kiss [this message]
2014-07-18 15:24   ` Wei Liu
2014-07-17 19:09 ` [PATCH net 2/4] xen-netback: Fix releasing frag_list skbs in " Zoltan Kiss
2014-07-18 15:24   ` Wei Liu
2014-07-18 15:24   ` Wei Liu
2014-07-17 19:09 ` Zoltan Kiss
2014-07-17 19:09 ` [PATCH net 3/4] xen-netback: Fix releasing header slot on " Zoltan Kiss
2014-07-18 15:25   ` Wei Liu
2014-07-18 18:06     ` Zoltan Kiss
2014-07-18 18:06     ` Zoltan Kiss
2014-07-18 15:25   ` Wei Liu
2014-07-17 19:09 ` Zoltan Kiss
2014-07-17 19:09 ` [PATCH net 4/4] xen-netback: Fix pointer incrementation to avoid incorrect logging Zoltan Kiss
2014-07-17 19:09 ` Zoltan Kiss
2014-07-18 15:25   ` Wei Liu
2014-07-18 15:25   ` Wei Liu

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=53C95DCB.90806@citrix.com \
    --to=zoltan.kiss@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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.