lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] DNS TTL 0


From: Simon Goldschmidt
Subject: Re: [lwip-users] DNS TTL 0
Date: Fri, 20 Jul 2012 12:36:35 +0200

Would you mind adding this to the bug tracker on savannah to ensure this 
doesn't get forgotten?

Thanks,
Simon


"Måns Andersson" <address@hidden> wrote:
> 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 mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lwip-users



reply via email to

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