lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Checksum Incorrect caused by Concatenation


From: Kieran Mansley
Subject: Re: [lwip-users] Checksum Incorrect caused by Concatenation
Date: Mon, 16 Nov 2009 15:36:43 +0000

On Mon, 2009-11-16 at 16:01 +0100, herve garat wrote:
> 
> In the pbuf_cat function “p->next” must not be equal to “t”, but must
> be
> equal to “NULL”. And we must write “p->len+=t->len;”.

No, that's wrong.  p->len refers to the length of each individual pbuf.
We've added another pbuf to the chain, but not changed the length of
each pbuf.  Because the chain is longer, we increment the length of
p->tot_len, but not the length of p->len. 

> And next after the
> call of “pbuf_cat(useg->p, queue->p);” in “tcp_enqueue fuction”
> tcp_out.c  ,
> we have Add two line:

> 
>     pbuf_cat(useg->p, queue->p);
> 
>     useg->len += queue->len;
> 
>     useg->next = queue->next;
> 
>     LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
> ("tcp_enqueue: chaining segments, new len %"U16_F"\n", useg->len));
> 
>     if (seg == queue)
> 
>     {
> 
>       seg = useg;
> 
>       seglen = useg->len;
> 
>       queuelen--;               //decrementation of the SND_QUEUELEN
> due to
> concatenation
> 
>     }

Not sure about that: the header file says that snd_queuelen is a length
in TCP segs, but we're using it in the code as meaning a length in
pbufs.  As we've not changed the number of pbufs by chaining one on to
the other, we shouldn't change the queuelen.

>     memp_free(MEMP_TCP_SEG, queue);
> 
>     pbuf_free(queue->p);   /dereference a pbuf chain due to
> concatenation

That would be wrong: the pbuf is still in use, it has been chained into
the others.  If you free it something else could try and use the same
buffer and cause an error.

It is odd that these changes have fixed a problem for you, as I would
think they would make it worse.

Kieran 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]