All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>,
	David Miller <davem@davemloft.net>
Cc: jgross@suse.com, ptalbert@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org,
	boris.ostrovsky@oracle.com
Subject: Re: [PATCH net-next RESEND] xen-netfront: avoid packet loss when ethernet header crosses page boundary
Date: Mon, 19 Sep 2016 11:23:53 +0100	[thread overview]
Message-ID: <57DFBCB9.1090500__41657.2125781842$1474280705$gmane$org@citrix.com> (raw)
In-Reply-To: <87mvj4xk8i.fsf@vitty.brq.redhat.com>

On 19/09/16 11:22, Vitaly Kuznetsov wrote:
> David Miller <davem@davemloft.net> writes:
> 
>> From: Vitaly Kuznetsov <vkuznets@redhat.com>
>> Date: Fri, 16 Sep 2016 12:59:14 +0200
>>
>>> @@ -595,6 +596,19 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
>>>  	offset = offset_in_page(skb->data);
>>>  	len = skb_headlen(skb);
>>>  
>>> +	/* The first req should be at least ETH_HLEN size or the packet will be
>>> +	 * dropped by netback.
>>> +	 */
>>> +	if (unlikely(PAGE_SIZE - offset < ETH_HLEN)) {
>>> +		nskb = skb_copy(skb, GFP_ATOMIC);
>>> +		if (!nskb)
>>> +			goto drop;
>>> +		dev_kfree_skb_any(skb);
>>> +		skb = nskb;
>>> +		page = virt_to_page(skb->data);
>>> +		offset = offset_in_page(skb->data);
>>> +	}
>>> +
>>>  	spin_lock_irqsave(&queue->tx_lock, flags);
>>
>> I think you also have to recalculate 'len' in this case too, as
>> skb_headlen() will definitely be different for nskb.
>>
>> In fact, I can't see how this code can work properly without that fix.
> 
> Thank you for your feedback David,
> 
> in my testing (even when I tried doing skb_copy() for all skbs
> unconditionally) skb_headlen(nskb) always equals 'len' so I was under an
> impression that both 'skb->len' and 'skb->data_len' remain the same when
> we do skb_copy(). However, in case you think there are cases when
> headlen changes, I see no problem with re-calculating 'len' as it won't
> bring any significant performace penalty compared to the already added
> skb_copy().

I think you can move the len = skb_headlen(skb) after the if, no need to
recalculate it.

David

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-09-19 10:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-16 10:59 [PATCH net-next RESEND] xen-netfront: avoid packet loss when ethernet header crosses page boundary Vitaly Kuznetsov
2016-09-19  2:26 ` David Miller
2016-09-19  2:26 ` David Miller
2016-09-19 10:22   ` Vitaly Kuznetsov
2016-09-19 10:23     ` David Vrabel
2016-09-19 10:36       ` Vitaly Kuznetsov
2016-09-19 10:36       ` Vitaly Kuznetsov
2016-09-19 10:23     ` David Vrabel [this message]
2016-09-19 10:22   ` Vitaly Kuznetsov
  -- strict thread matches above, loose matches on Subject: below --
2016-09-16 10:59 Vitaly Kuznetsov

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='57DFBCB9.1090500__41657.2125781842$1474280705$gmane$org@citrix.com' \
    --to=david.vrabel@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=davem@davemloft.net \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ptalbert@redhat.com \
    --cc=vkuznets@redhat.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.