All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Question]Why a skb with frag_list causes BUG_ON in function skb_segment
       [not found] <60A73B7A161A82449A7DB7B382BFD1553712AF1C@SZXEMA504-MBS.china.huawei.com>
@ 2015-07-30  4:26 ` Jason Wang
  2015-07-30  5:01   ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Wang @ 2015-07-30  4:26 UTC (permalink / raw)
  To: Zhangjie (HZ), linux-kernel@vger.kernel.org, mst@redhat.com
  Cc: Qinchuanyu, Yewudi, liuyongan 00175866, netdev@vger.kernel.org

cc netdev for more experts

On 07/28/2015 04:53 PM, Zhangjie (HZ) wrote:
>
> Hi,
>
> I generate a skb as follows:
>
> It has a linear data region, 17 frags and the last fragment is in
> skb_shinfo(skb)->frag_list.
>
> Before this skb is sent to driver, dev_hard_start_xmit() will segment
> it first(skb has frag_list,
>
> so we get true from netif_needs_gso()), then the skb is passed to
> function skb_segment().
>
> Then, BUG_ON() happened.
>
> while (pos < offset + len) {
>
>         if (i >= nfrags) {
>
>                 BUG_ON(skb_headlen(list_skb));    (skbuff.c:3120)
>
>                 …
>
>         }
>
>         …
>
> }
>
> A skb that has no frags but frag_list also causes BUG_ON().
>
> I wonder if skb like follows is legal? Could skb in frag_list have
> linear data region?
>
>  
>
>  
>
> Thanks
>
> Zhangjie
>


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

* Re: [Question]Why a skb with frag_list causes BUG_ON in function skb_segment
  2015-07-30  4:26 ` [Question]Why a skb with frag_list causes BUG_ON in function skb_segment Jason Wang
@ 2015-07-30  5:01   ` Eric Dumazet
  2015-07-30  5:56       ` Zhangjie (HZ)
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2015-07-30  5:01 UTC (permalink / raw)
  To: Jason Wang
  Cc: Zhangjie (HZ), linux-kernel@vger.kernel.org, mst@redhat.com,
	Qinchuanyu, Yewudi, liuyongan 00175866, netdev@vger.kernel.org

On Thu, 2015-07-30 at 12:26 +0800, Jason Wang wrote:
> cc netdev for more experts
> 
> On 07/28/2015 04:53 PM, Zhangjie (HZ) wrote:
> >
> > Hi,
> >
> > I generate a skb as follows:
> >
> > It has a linear data region, 17 frags and the last fragment is in
> > skb_shinfo(skb)->frag_list.
> >
> > Before this skb is sent to driver, dev_hard_start_xmit() will segment
> > it first(skb has frag_list,
> >
> > so we get true from netif_needs_gso()), then the skb is passed to
> > function skb_segment().
> >
> > Then, BUG_ON() happened.
> >
> > while (pos < offset + len) {
> >
> >         if (i >= nfrags) {
> >
> >                 BUG_ON(skb_headlen(list_skb));    (skbuff.c:3120)
> >
> >                 …
> >
> >         }
> >
> >         …
> >
> > }
> >
> > A skb that has no frags but frag_list also causes BUG_ON().
> >
> > I wonder if skb like follows is legal? Could skb in frag_list have
> > linear data region?

The answer is : skb_segment() is very complex but does not handle all
possible cases.

skb found in skb_shinfo(skb)->frag_list must not have anything in their
skb->head. This would require very expensive logic and memory
allocations and copies.

Make sure you follow this rule in your driver, or even better leave this
work to GRO engine.




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

* RE: [Question]Why a skb with frag_list causes BUG_ON in function skb_segment
  2015-07-30  5:01   ` Eric Dumazet
@ 2015-07-30  5:56       ` Zhangjie (HZ)
  0 siblings, 0 replies; 4+ messages in thread
From: Zhangjie (HZ) @ 2015-07-30  5:56 UTC (permalink / raw)
  To: Eric Dumazet, Jason Wang
  Cc: linux-kernel@vger.kernel.org, mst@redhat.com, Qinchuanyu, Yewudi,
	liuyongan 00175866, netdev@vger.kernel.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1896 bytes --]

Get it.
Eric, thanks for your explaination. :-)

Jason, thank you! I will remember cc netdev@vger.kernel.org next time.

-----Original Message-----
From: Eric Dumazet [mailto:eric.dumazet@gmail.com] 
Sent: Thursday, July 30, 2015 1:01 PM
To: Jason Wang
Cc: Zhangjie (HZ); linux-kernel@vger.kernel.org; mst@redhat.com; Qinchuanyu; Yewudi; liuyongan 00175866; netdev@vger.kernel.org
Subject: Re: [Question]Why a skb with frag_list causes BUG_ON in function skb_segment

On Thu, 2015-07-30 at 12:26 +0800, Jason Wang wrote:
> cc netdev for more experts
> 
> On 07/28/2015 04:53 PM, Zhangjie (HZ) wrote:
> >
> > Hi,
> >
> > I generate a skb as follows:
> >
> > It has a linear data region, 17 frags and the last fragment is in 
> > skb_shinfo(skb)->frag_list.
> >
> > Before this skb is sent to driver, dev_hard_start_xmit() will 
> > segment it first(skb has frag_list,
> >
> > so we get true from netif_needs_gso()), then the skb is passed to 
> > function skb_segment().
> >
> > Then, BUG_ON() happened.
> >
> > while (pos < offset + len) {
> >
> >         if (i >= nfrags) {
> >
> >                 BUG_ON(skb_headlen(list_skb));    (skbuff.c:3120)
> >
> >                 …
> >
> >         }
> >
> >         …
> >
> > }
> >
> > A skb that has no frags but frag_list also causes BUG_ON().
> >
> > I wonder if skb like follows is legal? Could skb in frag_list have 
> > linear data region?

The answer is : skb_segment() is very complex but does not handle all possible cases.

skb found in skb_shinfo(skb)->frag_list must not have anything in their
skb->head. This would require very expensive logic and memory
allocations and copies.

Make sure you follow this rule in your driver, or even better leave this work to GRO engine.



ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* RE: [Question]Why a skb with frag_list causes BUG_ON in function skb_segment
@ 2015-07-30  5:56       ` Zhangjie (HZ)
  0 siblings, 0 replies; 4+ messages in thread
From: Zhangjie (HZ) @ 2015-07-30  5:56 UTC (permalink / raw)
  To: Eric Dumazet, Jason Wang
  Cc: linux-kernel@vger.kernel.org, mst@redhat.com, Qinchuanyu, Yewudi,
	liuyongan 00175866, netdev@vger.kernel.org

Get it.
Eric, thanks for your explaination. :-)

Jason, thank you! I will remember cc netdev@vger.kernel.org next time.

-----Original Message-----
From: Eric Dumazet [mailto:eric.dumazet@gmail.com] 
Sent: Thursday, July 30, 2015 1:01 PM
To: Jason Wang
Cc: Zhangjie (HZ); linux-kernel@vger.kernel.org; mst@redhat.com; Qinchuanyu; Yewudi; liuyongan 00175866; netdev@vger.kernel.org
Subject: Re: [Question]Why a skb with frag_list causes BUG_ON in function skb_segment

On Thu, 2015-07-30 at 12:26 +0800, Jason Wang wrote:
> cc netdev for more experts
> 
> On 07/28/2015 04:53 PM, Zhangjie (HZ) wrote:
> >
> > Hi,
> >
> > I generate a skb as follows:
> >
> > It has a linear data region, 17 frags and the last fragment is in 
> > skb_shinfo(skb)->frag_list.
> >
> > Before this skb is sent to driver, dev_hard_start_xmit() will 
> > segment it first(skb has frag_list,
> >
> > so we get true from netif_needs_gso()), then the skb is passed to 
> > function skb_segment().
> >
> > Then, BUG_ON() happened.
> >
> > while (pos < offset + len) {
> >
> >         if (i >= nfrags) {
> >
> >                 BUG_ON(skb_headlen(list_skb));    (skbuff.c:3120)
> >
> >                 …
> >
> >         }
> >
> >         …
> >
> > }
> >
> > A skb that has no frags but frag_list also causes BUG_ON().
> >
> > I wonder if skb like follows is legal? Could skb in frag_list have 
> > linear data region?

The answer is : skb_segment() is very complex but does not handle all possible cases.

skb found in skb_shinfo(skb)->frag_list must not have anything in their
skb->head. This would require very expensive logic and memory
allocations and copies.

Make sure you follow this rule in your driver, or even better leave this work to GRO engine.




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

end of thread, other threads:[~2015-07-30  5:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <60A73B7A161A82449A7DB7B382BFD1553712AF1C@SZXEMA504-MBS.china.huawei.com>
2015-07-30  4:26 ` [Question]Why a skb with frag_list causes BUG_ON in function skb_segment Jason Wang
2015-07-30  5:01   ` Eric Dumazet
2015-07-30  5:56     ` Zhangjie (HZ)
2015-07-30  5:56       ` Zhangjie (HZ)

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.