I found I still missed something. Here is the new patch.
In pbuf.c
828 struct pbuf *
829
pbuf_take(struct pbuf *p)
830 {
831
- struct pbuf *q , *prev, *head;
+ struct pbuf *q ,
*prev, *head, *ori_head;
.....
841 - if (p->flags == PBUF_FLAG_REF)
{
.....
836 - head = p;
+ head = ori_head =
p;
.....
841 - pbuf_free(p);
.....
868 /* remove linkage from original pbuf
*/
869 - p->next = NULL;
.....
901 /* p->flags != PBUF_FLAG_REF
*/
902 - } else {
903 -
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: skipping pbuf not of type
PBUF_REF\n"));
904 - }
.....
911 + p=ori_head;
912 return
head;
913 }
Bo-Er
----- Original Message -----
Sent: Tuesday, December 14, 2004 3:01
PM
Subject: [lwip-users] Bug of ARP?
Hi all,
I'm using lwIP 1.0.0 and found a problem look like a lwIP's bug. I
don't know if there is
anyone had mentioned it before(There seems to be many bugs fixing
recently). I just explain
what I found here.
In gereral, LwIP will queue packets as there is no matching entry in the
ARP table. It uses
p = pbuf_take(q) to copy sent packet 'q' to internal pbuf
'p' and make q=p.The 'p' will be
queued in arp_table[i].p and be freed
after timeout or it can be sent out. This will cause some
problems in TCP. Since TCP needs to keep sent packets in
unacked queue until ack is
arriving, those packets may be freed in ARP before ack is
received by TCP. Except TCP,
ICMP and UDP will also free sent packets after return of sent-out
function. It may also
causes packets in ARP queue be freed before timeout or they can be
sent out.
I made some modification in pbuf_take which is shown as follow
to resolve it.
In pbuf.c
828 struct pbuf *
829
pbuf_take(struct pbuf *p)
830 {
831
- struct pbuf *q , *prev, *head;
+ struct pbuf *q ,
*prev, *head, *ori_head;
.....
836 - head = p;
+ head = ori_head
= p;
.....
841 - pbuf_free(p);
.....
911 + p=ori_head;
912 return
head;
913 }
This modification keeps 'p' as original one and doesn't free it. All sent
packets will be freed by up layer
instead of ARP.
Regards,
Bo-Er
_______________________________________________
lwip-users mailing
list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users