Changeset 1830
- Timestamp:
- 01/07/11 21:33:04 (2 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 6 modified
-
dbdnsseckeeper.cc (modified) (1 diff)
-
dnspacket.cc (modified) (2 diffs)
-
dnspacket.hh (modified) (1 diff)
-
packetcache.cc (modified) (5 diffs)
-
packetcache.hh (modified) (5 diffs)
-
packethandler.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/dbdnsseckeeper.cc
r1810 r1830 213 213 } 214 214 else if(dk.haveActiveKSKFor(qname, &dpk)) { 215 cerr<<"Found a KSK for '"<<qname<<"'"<<endl;215 // cerr<<"Found a KSK for '"<<qname<<"'"<<endl; 216 216 *rc=dpk.d_key; 217 217 return dpk.getDNSKEY(); -
trunk/pdns/pdns/dnspacket.cc
r1797 r1830 311 311 312 312 drc->toPacket(pw); 313 314 if(!d_tcp && pw.size() + 20 > getMaxReplyLen()) { 315 cerr<<"Truncating!"<<endl; 313 if(!d_tcp && pw.size() + 20 > getMaxReplyLen()) { // XXX FIXME, 20? what does it mean? 316 314 pw.rollback(); 317 315 if(pos->d_place == DNSResourceRecord::ANSWER) { 318 cerr<<"Set TC bit"<<endl;319 316 pw.getHeader()->tc=1; 320 317 } … … 344 341 len=packet.size(); 345 342 } 346 347 348 /** Truncates a packet that has already been wrapup()-ed, possibly via a call to getData(). Do not call this function349 before having done this - it will possibly break your packet, or crash your program.350 351 This method sets the 'TC' bit in the stringbuffer, and caps the len attributed to new_length.352 */353 354 void DNSPacket::truncate(int new_length)355 {356 if(new_length>len || !d_wrapped)357 return;358 359 DLOG(L<<Logger::Warning<<"Truncating a packet to "<< remote.toString() <<endl);360 361 len=new_length;362 stringbuffer[2]|=2; // set TC363 }364 365 343 366 344 void DNSPacket::setQuestion(int op, const string &qd, int newqtype) -
trunk/pdns/pdns/dnspacket.hh
r1797 r1830 124 124 const char *getRaw(void); //!< provides access to the raw packet, possibly on a packet that has never been 'wrapped' 125 125 void spoofQuestion(const string &qd); //!< paste in the exact right case of the question. Useful for PacketCache 126 void truncate(int new_length); // has documentation in source127 126 128 127 vector<DNSResourceRecord*> getAPRecords(); //!< get a vector with DNSResourceRecords that need additional processing -
trunk/pdns/pdns/packetcache.cc
r1709 r1830 86 86 } 87 87 88 haveSomething=getEntryLocked(p->qdomain, p->qtype, PacketCache::PACKETCACHE, value, -1, packetMeritsRecursion );88 haveSomething=getEntryLocked(p->qdomain, p->qtype, PacketCache::PACKETCACHE, value, -1, packetMeritsRecursion, p->getMaxReplyLen()); 89 89 } 90 90 if(haveSomething) { … … 125 125 bool packetMeritsRecursion=d_doRecursion && q->d.rd; 126 126 127 insert(q->qdomain, q->qtype, PacketCache::PACKETCACHE, r->getString(), packetMeritsRecursion ? d_recursivettl : d_ttl, -1, packetMeritsRecursion); 127 insert(q->qdomain, q->qtype, PacketCache::PACKETCACHE, r->getString(), packetMeritsRecursion ? d_recursivettl : d_ttl, -1, packetMeritsRecursion, 128 q->getMaxReplyLen()); 128 129 } 129 130 130 131 // universal key appears to be: qname, qtype, kind (packet, query cache), optionally zoneid, meritsRecursion 131 void PacketCache::insert(const string &qname, const QType& qtype, CacheEntryType cet, const string& value, unsigned int ttl, int zoneID, bool meritsRecursion) 132 void PacketCache::insert(const string &qname, const QType& qtype, CacheEntryType cet, const string& value, unsigned int ttl, int zoneID, 133 bool meritsRecursion, unsigned int maxReplyLen) 132 134 { 133 135 if(!((d_ops++) % 300000)) { … … 146 148 val.ctype=cet; 147 149 val.meritsRecursion=meritsRecursion; 150 val.maxReplyLen = maxReplyLen; 148 151 149 152 TryWriteLock l(&d_mut); … … 249 252 } 250 253 251 bool PacketCache::getEntry(const string &qname, const QType& qtype, CacheEntryType cet, string& value, int zoneID, bool meritsRecursion) 254 bool PacketCache::getEntry(const string &qname, const QType& qtype, CacheEntryType cet, string& value, int zoneID, bool meritsRecursion, 255 unsigned int maxReplyLen) 252 256 { 253 257 if(d_ttl<0) … … 263 267 return false; 264 268 } 265 return getEntryLocked(qname, qtype, cet, value, zoneID, meritsRecursion); 266 } 267 268 bool PacketCache::getEntryLocked(const string &qname, const QType& qtype, CacheEntryType cet, string& value, int zoneID, bool meritsRecursion) 269 return getEntryLocked(qname, qtype, cet, value, zoneID, meritsRecursion, maxReplyLen); 270 } 271 272 bool PacketCache::getEntryLocked(const string &qname, const QType& qtype, CacheEntryType cet, string& value, int zoneID, bool meritsRecursion, 273 unsigned int maxReplyLen) 269 274 { 270 275 271 276 uint16_t qt = qtype.getCode(); 272 cmap_t::const_iterator i=d_map.find(tie(qname, qt, cet, zoneID, meritsRecursion)); 277 278 cmap_t::const_iterator i=d_map.find(tie(qname, qt, cet, zoneID, meritsRecursion, maxReplyLen)); 273 279 time_t now=time(0); 274 280 bool ret=(i!=d_map.end() && i->ttd > now); -
trunk/pdns/pdns/packetcache.hh
r1472 r1830 1 1 /* 2 2 PowerDNS Versatile Database Driven Nameserver 3 Copyright (C) 2002 - 20 08PowerDNS.COM BV3 Copyright (C) 2002 - 2011 PowerDNS.COM BV 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 72 72 void insert(DNSPacket *q, DNSPacket *r); //!< We copy the contents of *p into our cache. Do not needlessly call this to insert questions already in the cache as it wastes resources 73 73 74 void insert(const string &qname, const QType& qtype, CacheEntryType cet, const string& value, unsigned int ttl, int zoneID=-1, bool meritsRecursion=false); 74 void insert(const string &qname, const QType& qtype, CacheEntryType cet, const string& value, unsigned int ttl, int zoneID=-1, bool meritsRecursion=false, 75 unsigned int maxReplyLen=512); 75 76 76 77 int get(DNSPacket *p, DNSPacket *q); //!< We return a dynamically allocated copy out of our cache. You need to delete it. You also need to spoof in the right ID with the DNSPacket.spoofID() method. 77 bool getEntry(const string &content, const QType& qtype, CacheEntryType cet, string& entry, int zoneID=-1, bool meritsRecursion=false); 78 bool getEntry(const string &content, const QType& qtype, CacheEntryType cet, string& entry, int zoneID=-1, 79 bool meritsRecursion=false, unsigned int maxReplyLen=512); 78 80 79 81 int size(); //!< number of entries in the cache … … 83 85 map<char,int> getCounts(); 84 86 private: 85 bool getEntryLocked(const string &content, const QType& qtype, CacheEntryType cet, string& entry, int zoneID=-1, bool meritsRecursion=false); 87 bool getEntryLocked(const string &content, const QType& qtype, CacheEntryType cet, string& entry, int zoneID=-1, 88 bool meritsRecursion=false, unsigned int maxReplyLen=512); 86 89 struct CacheEntry 87 90 { … … 94 97 time_t ttd; 95 98 bool meritsRecursion; 99 unsigned int maxReplyLen; 96 100 string value; 97 101 }; … … 107 111 member<CacheEntry,string,&CacheEntry::qname>, 108 112 member<CacheEntry,uint16_t,&CacheEntry::qtype>, 109 member<CacheEntry,uint16_t, &CacheEntry::ctype>, 110 member<CacheEntry,int, &CacheEntry::zoneID>, 111 member<CacheEntry,bool, &CacheEntry::meritsRecursion> 112 >, 113 composite_key_compare<CIBackwardsStringCompare, std::less<uint16_t>, std::less<uint16_t>, std::less<int>, std::less<bool> > 114 >, 115 sequenced<> 116 > 113 member<CacheEntry,uint16_t, &CacheEntry::ctype>, 114 member<CacheEntry,int, &CacheEntry::zoneID>, 115 member<CacheEntry,bool, &CacheEntry::meritsRecursion>, 116 member<CacheEntry,unsigned int, &CacheEntry::maxReplyLen> 117 >, 118 composite_key_compare<CIBackwardsStringCompare, std::less<uint16_t>, std::less<uint16_t>, std::less<int>, std::less<bool>, 119 std::less<unsigned int> > 120 >, 121 sequenced<> 122 > 117 123 > cmap_t; 118 124 -
trunk/pdns/pdns/packethandler.cc
r1829 r1830 601 601 return; 602 602 } 603 cerr<<"salt in ph: '"<<makeHexDump(ns3rc.d_salt)<<"', narrow="<<narrow<<endl;603 // cerr<<"salt in ph: '"<<makeHexDump(ns3rc.d_salt)<<"', narrow="<<narrow<<endl; 604 604 string unhashed, before,after; 605 605 … … 611 611 cerr<<"Done calling for closest encloser, before='"<<before<<"', after='"<<after<<"'"<<endl; 612 612 emitNSEC3(ns3rc, auth, unhashed, fromBase32Hex(before), fromBase32Hex(after), target, r, mode); 613 614 613 615 614 // now add the main nsec3 … … 620 619 emitNSEC3( ns3rc, auth, unhashed, fromBase32Hex(before), fromBase32Hex(after), target, r, mode); 621 620 622 623 621 // now add the * 624 622 unhashed=dotConcat("*", auth); … … 1346 1344 1347 1345 r->wrapup(&d_dk); // needed for inserting in cache 1348 if(! noCache) {1349 PC.insert(p, r); // in the packet cache1346 if(!p->d_tcp) { 1347 PC.insert(p, r); // in the packet cache 1350 1348 } 1351 1349 }