buglwIP - A Lightweight TCP/IP stack - Bugs: bug #59632, Calling tcp_write() without...

 
 

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

bug #59632: Calling tcp_write() without TCP_WRITE_FLAG_COPY does in fact copy data

Submitter:  Oleg Kobrin <kiabrin>
Submitted:  Mon 07 Dec 2020 05:17:21 PM UTC
   
 
Category:  TCP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Invalid
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

Tue 08 Dec 2020 10:15:37 AM UTC, comment #3: 

In my case: I checked again, writing a packet of 12 bytes without TCP_WRITE_FLAG_COPY set decreases pcb->snd_buf by 12.
Another try:
calling err_t Err = tcp_write(Connects[Sock].pcb, Data, Len, 0);
Len = 2404, pcb->snd_buf = 23722.
After call:
pcb->snd_buf = 21318.
23722 - 21318 = 2404.

Looks like this is due to TCP_OVERSIZE is defined default to TCP_MSS.
Data is copied to oversize buf.

Oleg Kobrin <kiabrin>
Tue 08 Dec 2020 07:19:34 AM UTC, comment #2: 

No, it is not.
pcb->unsent->tcphdr points to header,
pcb->unsent->p->payload points to contents.

Oleg Kobrin <kiabrin>
Tue 08 Dec 2020 05:45:35 AM UTC, comment #1: 

So where's the bug?

pcb->unsent->p->payload points to a small pbuf containing the packet headers. This needs to be allocated for every packet, regardless of whether the packet's payload is copied or not.

Simon Goldschmidt <goldsimon>
Group administrator
Mon 07 Dec 2020 05:17:21 PM UTC, original submission:  

Hello!

Debugging my code on TivaC MCU, NO_OS configuration, I realized after call to tcp_write() with no TCP_WRITE_FLAG_COPY flag that pcb->snd_buf was decreased and real pcb->unsent->p->payload points not to my data, but somewhere inside lwip memory pool.
This is not good, as at high output traffic I experience tcp send buffer overflows, causing data loss.

Oleg Kobrin <kiabrin>

 

(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 (Posted a comment)
  • -email is unavailable- added by kiabrin (Submitted the item)
  • -email is unavailable- added by kiabrin
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-12-08 goldsimon StatusNone Invalid
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2020-12-07 kiabrin Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code