Changeset 1182

Show
Ignore:
Timestamp:
06/03/08 23:21:55 (4 months ago)
Author:
ahu
Message:

fix for the 'self-renewing NS record' as spotted by Darren Gamble

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pdns/pdns/recursor_cache.cc

    r1137 r1182  
    229229} 
    230230  
     231bool MemRecursorCache::attemptToRefreshNSTTL(const QType& qt, const set<DNSResourceRecord>& content, const CacheEntry& stored) 
     232{ 
     233  if(!stored.d_auth) { 
     234//    cerr<<"feel free to scribble non-auth data!"<<endl; 
     235    return false; 
     236  } 
     237 
     238  if(qt.getCode()!=QType::NS) { 
     239  //  cerr<<"Not NS record"<<endl; 
     240    return false; 
     241  } 
     242  if(content.size()!=stored.d_records.size()) { 
     243  //  cerr<<"Not equal number of records"<<endl; 
     244    return false; 
     245  } 
     246  if(stored.d_records.empty()) 
     247    return false; 
     248 
     249  if(stored.d_records.begin()->d_ttd > content.begin()->ttl) { 
     250    // cerr<<"attempt to LOWER TTL - fine by us"<<endl; 
     251    return false; 
     252  } 
     253 
     254 
     255 // cerr<<"Returning true - update attempt!\n"; 
     256  return true; 
     257} 
     258 
    231259/* the code below is rather tricky - it basically replaces the stuff cached for qname by content, but it is special 
    232260   cased for when inserting identical records with only differing ttls, in which case the entry is not 
     
    254282    ce.d_records.clear(); 
    255283 
    256   if(auth /* && !ce.d_auth */ ) { 
     284  if(auth && !attemptToRefreshNSTTL(qt, content, ce) ) { 
    257285    ce.d_records.clear(); // clear non-auth data 
    258286    ce.d_auth = true;