lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #21107] LwIP doesn't reset the TTL in ICMP Echo Replie


From: Tom Evans
Subject: [lwip-devel] [bug #21107] LwIP doesn't reset the TTL in ICMP Echo Replies
Date: Tue, 18 Sep 2007 23:48:15 +0000
User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; MathPlayer 2.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)

Follow-up Comment #8, bug #21107 (project lwip):

Clarity over "Premature optimisation" every time.

I've been involved in another IP stack that
"adjusted the IP Header Checksum" when acting as a router
instead of recalculating it. When using Telnet through it,
after a few HOURS it would stop working for a while. It
stopped for 256 packets out of every 65536, which is a
dead giveaway.

The IP Sequence number sequential increase made the checksum
roll through the zone where the buggy adjustment got it wrong
and didn't handle the end-around-carries quite properly.

I "fixed" my LwIP code and then it didn't work as I didn't
realise that the code in icmp_input() adjusts the *ICMP*
Checksum, and not the *IP* checksum. The former has to be
adjusted as the Request has changed to a Reply. The latter
only has to be recalculated if the TTL is changed.

I've put the following extra code in icmp.c and the tracert
and ping now works:

>     /* adjust the checksum */
>     if (iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {
>       iecho->chksum += htons(ICMP_ECHO << 8) + 1;
>     } else {
>       iecho->chksum += htons(ICMP_ECHO << 8);
>     }
>
>>     /* Set the correct TTL and recalculate
>>        the header checksum. */
>>     IPH_TTL_SET(iphdr, ICMP_TTL);
>>     IPH_CHKSUM_SET(iphdr, 0); 
>> #if CHECKSUM_GEN_IP 
>>     IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); 
>> #endif  /* CHECKSUM_GEN_IP */
> 
>     ICMP_STATS_INC(icmp.xmit);
>     /* increase number of messages attempted to send */




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?21107>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

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