buglwIP - A Lightweight TCP/IP stack - Bugs: bug #36899, DNS TTL 0 is cached for a long time

 
 

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

bug #36899: DNS TTL 0 is cached for a long time

Submitted by:  Måns Andersson <mansandersson>
Submitted on:  Fri 20 Jul 2012 10:44:53 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Faulty BehaviourStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: 1.4.0

Mon 13 Aug 2012 07:34:28 PM UTC, comment #1:

Fixed, thanks for reporting.

In addition to the suggested fix, I've flushed the entry right in the receive-callback, which is what RFC 883 requires on page 29:

"Zero values are
interpreted to mean that the RR can only be used for the
transaction in progress, and should not be cached."

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Fri 20 Jul 2012 10:44:53 AM UTC, original submission:

I'm using lwip 1.4.0 with an opendns.com dns server. When OpenDNS can't resolve
a host they return an ip address pointing to one of their own servers together
with a TTL of 0. When this happens lwip caches it for DNS_MAX_TTL seconds
rather than throwing it away. I suggest we change the code the following way:

dns.c:695 (dns_check_entry() state DNS_STATE_DONE)

case DNS_STATE_DONE: {
/* if the time to live is nul */
if (--pEntry->ttl == 0) {
LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": flush\n", pEntry->name));
/* flush this entry */
pEntry->state = DNS_STATE_UNUSED;
pEntry->found = NULL;
}
break;
}

to

case DNS_STATE_DONE: {
/* if the time to live is nul */
if (pEntry->ttl == 0 || --pEntry->ttl == 0) {
LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": flush\n", pEntry->name));
/* flush this entry */
pEntry->state = DNS_STATE_UNUSED;
pEntry->found = NULL;
}
break;
}

By doing this we make sure that the u32 ttl variable does not tip over (ie. --0
== INT_MAX when we have an unsigned variable) and that we throw away any cache
that has reached 0 in some way.

Måns Andersson <mansandersson>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by mansandersson (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 13 Aug 2012 07:34:28 PM UTCgoldsimonStatusNone=>Fixed
      Assigned toNone=>goldsimon
      Open/ClosedOpen=>Closed
      Planned Release=>1.5.0

    Back to the top


    Powered by Savane 3.1-cleanup1