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

Submitter:  Måns Andersson <mansandersson>
Submitted:  Fri 20 Jul 2012 10:44:53 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned 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>
Group administrator
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>

 

(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 mansandersson (Submitted the item)
  •  

    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
    2012-08-13 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
        Planned Release 1.5.0

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code