[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] DNS TTL 0
From: |
Måns Andersson |
Subject: |
[lwip-users] DNS TTL 0 |
Date: |
Fri, 20 Jul 2012 09:59:07 +0000 |
Hi
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
- [lwip-users] DNS TTL 0,
Måns Andersson <=