]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
apply ALIAS scopemask after chasing 6976/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 26 Jul 2018 12:28:16 +0000 (14:28 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Fri, 14 Sep 2018 12:29:54 +0000 (14:29 +0200)
(cherry picked from commit 0abea1ca19249f9028e85dec3cf7535d0598fede)

pdns/dnsproxy.cc
pdns/dnsproxy.hh
pdns/packethandler.cc

index 515aed1275fc59e08f5d058005a90db2e19f26cd..2fd513a8784e43f08aeb279c591787945c6e82db 100644 (file)
@@ -84,7 +84,7 @@ void DNSProxy::go()
 }
 
 //! look up qname target with r->qtype, plonk it in the answer section of 'r' with name aname
-bool DNSProxy::completePacket(DNSPacket *r, const DNSName& target,const DNSName& aname)
+bool DNSProxy::completePacket(DNSPacket *r, const DNSName& target,const DNSName& aname, const uint8_t scopeMask)
 {
   if(r->d_tcp) {
     vector<DNSZoneRecord> ips;
@@ -102,6 +102,7 @@ bool DNSProxy::completePacket(DNSPacket *r, const DNSName& target,const DNSName&
     for (auto &ip : ips)
     {
       ip.dr.d_name = aname;
+      ip.scopeMask = scopeMask;
       r->addRecord(ip);
     }
 
@@ -128,6 +129,7 @@ bool DNSProxy::completePacket(DNSPacket *r, const DNSName& target,const DNSName&
     ce.anyLocal = r->d_anyLocal;
     ce.complete = r;
     ce.aname=aname;
+    ce.anameScopeMask = scopeMask;
     d_conntrack[id]=ce;
   }
 
@@ -237,6 +239,7 @@ void DNSProxy::mainloop(void)
              if(j->first.d_type == i->second.qtype || (i->second.qtype == QType::ANY && (j->first.d_type == QType::A || j->first.d_type == QType::AAAA))) {
                 DNSZoneRecord dzr;
                dzr.dr.d_name=i->second.aname;
+               dzr.scopeMask=i->second.anameScopeMask;
                dzr.dr.d_type = j->first.d_type;
                dzr.dr.d_ttl=j->first.d_ttl;
                dzr.dr.d_place= j->first.d_place;
index 040fe1dca11dc73d831e47fb4afb4b0b8c4ad98b..3db94baf0f59c18867570e782fc7a8e09672f5b1 100644 (file)
@@ -54,7 +54,7 @@ public:
   DNSProxy(const string &ip); //!< creates socket
   ~DNSProxy(); //<! dtor for DNSProxy
   void go(); //!< launches the actual thread
-  bool completePacket(DNSPacket *r, const DNSName& target,const DNSName& aname);
+  bool completePacket(DNSPacket *r, const DNSName& target,const DNSName& aname, const uint8_t scopeMask);
 
   void mainloop();                  //!< this is the main loop that receives reply packets and sends them out again
   static void *launchhelper(void *p)
@@ -71,6 +71,7 @@ private:
     DNSName qname;
     DNSPacket* complete;
     DNSName aname;
+    uint8_t anameScopeMask;
     ComboAddress remote;
     uint16_t id;
     uint16_t qtype;
index f55838dd307a366c134b4614860a1ac6b02200a8..ce8ea39f5395f0e112aab9d7cfdd580817ce49a8 100644 (file)
@@ -1068,6 +1068,7 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
   vector<DNSZoneRecord> rrset;
   bool weDone=0, weRedirected=0, weHaveUnauth=0;
   DNSName haveAlias;
+  uint8_t aliasScopeMask;
 
   DNSPacket *r=0;
   bool noCache=false;
@@ -1288,6 +1289,7 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
     B.lookup(QType(QType::ANY), target, p, sd.domain_id);
     rrset.clear();
     haveAlias.trimToLabels(0);
+    aliasScopeMask = 0;
     weDone = weRedirected = weHaveUnauth =  false;
     
     while(B.get(rr)) {
@@ -1313,6 +1315,7 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
           continue;
         }
         haveAlias=getRR<ALIASRecordContent>(rr.dr)->d_content;
+        aliasScopeMask=rr.scopeMask;
       }
 
       // Filter out all SOA's and add them in later
@@ -1343,7 +1346,7 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
 
     if(!haveAlias.empty() && (!weDone || p->qtype.getCode() == QType::ANY)) {
       DLOG(L<<Logger::Warning<<"Found nothing that matched for '"<<target<<"', but did get alias to '"<<haveAlias<<"', referring"<<endl);
-      DP->completePacket(r, haveAlias, target);
+      DP->completePacket(r, haveAlias, target, aliasScopeMask);
       return 0;
     }