buglwIP - A Lightweight TCP/IP stack - Bugs: bug #29361, ip_frag has problems with...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #29361: ip_frag has problems with zero-copy DMA MACs

Submitted by:  Simon Goldschmidt <goldsimon>
Submitted on:  Sat 27 Mar 2010 05:54:02 PM UTC  
 
Category: IPv4Severity: 3 - Normal
Item Group: Crash ErrorStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: CVS Head

Mon 21 Jun 2010 06:51:18 PM UTC, comment #4:

Finally found the time to implement "custom" pbufs. I also set IP_FRAG_USES_STATIC_BUF=0 as default to be on the safe side (as =1 has problems with DMA-enabled MACs and lwIP should work OK with default settings).

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Mon 14 Jun 2010 08:32:03 PM UTC, comment #3:

Since noone seems to bother, I'll implement this (and task #7896) by adding a new pbuf type that expects a 'free' function pointer right after the current struct pbuf (I'll add a struct definition for that). This way, bot (zero-copy-)drivers and the IP_FRAG code can allocate their own pbufs as they have to.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Fri 30 Apr 2010 07:13:44 PM UTC, comment #2:

I think this has to be solved for 1.4.0 since it might involve API changes.

I'd fix this by adding flag to pbufs which indicates that there's a function-pointer for freeing right after the pbuf. We can then use a PBUF_ROM for sending, allocated in a special pool the items of which are big enough to store a PBUF_ROM, a function pointer and a pointer to the original pbuf. Then, every fragment can increase the original pbuf's ref-counter when allocated and decrease it when sent.

I'll prepare a patch for that.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Sun 28 Mar 2010 10:31:58 AM UTC, comment #1:

This bug can currently be avoided only by setting IP_FRAG_USES_STATIC_BUF==0 and LWIP_NETIF_TX_SINGLE_PBUF==1, which creates a new PBUF_RAM for each fragment, which comes at the downside of a memcpy.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Sat 27 Mar 2010 05:54:02 PM UTC, original submission:

This is kind of a duplicate to bug #29271 (Application can't re-use pbufs), but it's in the stack, not in applications, and we need to remember to fix it.

A zero-copy MAC that uses DMA might not have fully transmitted a packet when netif->output returns. In that case, it should probably increase the pbuf's ref-count and decrease it when done. This conflicts with both:
a)IP_FRAG_USES_STATIC_BUF==1 where one single static buffer is used as well as
b) IP_FRAG_USES_STATIC_BUF==0 where a (new) PBUF_REF points at the data to send but the ref-count of the initial pbuf isn't increased (thus it would be freed right after ip_frag returns)

Fixing a) is easy as long as we are OK with allocating a new PBUF_RAM here instead of a static buffer (we do a memcpy in both cases, plus on low-memory systems, IP_FRAG is probably turned off, anyway).

Fixing b) is not that easy: we would have to increase the ref-count of the original pbuf and decrease it again when the last PBUF_REF is freed. We might need a "custom" pbuf type here, that can call specific code on actually freeing a pbuf - or some kind of "chained" pbuf_free...

Any ideas? The current code is only safe on non-DMA systems.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by goldsimon (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 21 Jun 2010 06:51:18 PM UTCgoldsimonCategoryNone=>IPv4
      Item GroupNone=>Crash Error
      StatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Fri 30 Apr 2010 07:13:44 PM UTCgoldsimonStatusNone=>In Progress
      Assigned toNone=>goldsimon
      Planned Release=>1.4.0

    Back to the top


    Powered by Savane 3.1-cleanup1