]> granicus.if.org Git - pdns/commitdiff
improve cache miss behaviour for LUA records
authorbert hubert <bert.hubert@netherlabs.nl>
Wed, 22 Nov 2017 07:17:38 +0000 (08:17 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 22 Nov 2017 07:17:38 +0000 (08:17 +0100)
pdns/packethandler.cc

index d0ab73c2d48e98e3967850b4e323e0931f9a3306..0998e430d4a52d7ad803cf1eb63c0d1fe0e880c7 100644 (file)
@@ -1285,21 +1285,22 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
     while(B.get(rr)) {
       if(rr.dr.d_type == QType::LUA) {
         auto rec=getRR<LUARecordContent>(rr.dr);
-        if(rec->d_type != QType::CNAME && rec->d_type != p->qtype.getCode())
-          continue;
-        
-        auto recvec=luaSynth(rec->getCode(), target, sd.qname, sd.domain_id, p->getRemote(), p->getRealRemote(), rec->d_type);
-        if(!recvec.empty()) {
-          for(const auto& r : recvec) {
-            rr.dr.d_type = rec->d_type; // might be CNAME
-            rr.dr.d_content = r;
-            rr.scopeMask = 32;
-            rrset.push_back(rr);
+        if(rec->d_type == QType::CNAME || rec->d_type == p->qtype.getCode()) {
+          noCache=true;
+          auto recvec=luaSynth(rec->getCode(), target, sd.qname, sd.domain_id, p->getRemote(), p->getRealRemote(), rec->d_type);
+          if(!recvec.empty()) {
+
+            for(const auto& r : recvec) {
+              rr.dr.d_type = rec->d_type; // might be CNAME
+              rr.dr.d_content = r;
+              rr.scopeMask = 32;
+              rrset.push_back(rr);
+            }
+            if(rec->d_type == QType::CNAME && p->qtype.getCode() != QType::CNAME)
+              weRedirected = 1;
+            else
+              weDone = 1;
           }
-          if(rec->d_type == QType::CNAME && p->qtype.getCode() != QType::CNAME)
-            weRedirected = 1;
-          else
-            weDone = 1;
         }
       }
       //cerr<<"got content: ["<<rr.content<<"]"<<endl;
@@ -1411,6 +1412,9 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
     else if(weDone) {
       bool haveRecords = false;
       for(const auto& loopRR: rrset) {
+        if(loopRR.dr.d_type == QType::LUA)
+            continue;
+
         if((p->qtype.getCode() == QType::ANY || loopRR.dr.d_type == p->qtype.getCode()) && loopRR.dr.d_type && loopRR.dr.d_type != QType::ALIAS && loopRR.auth) {
           r->addRecord(loopRR);
           haveRecords = true;