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

Submitter:  Simon Goldschmidt <goldsimon>
Submitted:  Sat 27 Mar 2010 05:54:02 PM UTC
   
 
Category:  IPv4 Severity:  3 - Normal
Item Group:  Crash Error Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned 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>
Group administrator
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>
Group administrator
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>
Group administrator
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>
Group administrator
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>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-06-21 goldsimon CategoryNone IPv4
        Item GroupNone Crash Error
        StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2010-04-30 goldsimon StatusNone In Progress
        Assigned toNone goldsimon
        Planned Release 1.4.0

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code