]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
When creating a domain as part of autosecondary, schedule a fetch immediately. 16636/head
authorMiod Vallat <miod.vallat@powerdns.com>
Fri, 12 Dec 2025 09:46:16 +0000 (10:46 +0100)
committerMiod Vallat <miod.vallat@powerdns.com>
Fri, 12 Dec 2025 09:46:16 +0000 (10:46 +0100)
Fixes #16418

Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/packethandler.cc
pdns/packethandler.hh

index 983a32096a974f224e9efeee0e811359cffb5d36..76694830de1c7e219708f969799a08b4f82445f9 100644 (file)
@@ -1047,19 +1047,17 @@ How SQL backends implement this:
 
 */
 
-int PacketHandler::tryAutoPrimary(const DNSPacket& p, const DNSName& tsigkeyname)
+int PacketHandler::tryAutoPrimary(const DNSPacket& p)
 {
-  if(p.d_tcp)
-  {
-    // do it right now if the client is TCP
-    // rarely happens
-    return tryAutoPrimarySynchronous(p, tsigkeyname);
+  if(p.d_tcp) {
+    // Do it right now if the client is TCP (rarely happens)
+    return tryAutoPrimarySynchronous(p, p.getTSIGKeyname());
   }
-  else
-  {
-    // queue it if the client is on UDP
+  else {
+    // Queue it if the client is on UDP; the communicator will invoke
+    // tryAutoPrimarySynchronous later.
     Communicator.addTryAutoPrimaryRequest(p);
-    return 0;
+    return RCode::NoError;
   }
 }
 
@@ -1128,6 +1126,9 @@ int PacketHandler::tryAutoPrimarySynchronous(const DNSPacket& p, const DNSName&
       meta.push_back(tsigkeyname.toStringNoDot());
       db->setDomainMetadata(zonename, "AXFR-MASTER-TSIG", meta);
     }
+    // Now that we have created the secondary, fetch its contents.
+    di.receivedNotify = true;
+    Communicator.addSecondaryCheckRequest(di, p.getInnerRemote());
   }
   catch(PDNSException& ae) {
     g_log << Logger::Error << "Database error trying to create " << zonename << " for potential autoprimary " << remote << ": " << ae.reason << endl;
@@ -1187,7 +1188,7 @@ int PacketHandler::processNotify(const DNSPacket& p)
   if(!B.getDomainInfo(zonename, di, false) || di.backend == nullptr) {
     if(::arg().mustDo("autosecondary")) {
       g_log << Logger::Warning << "Received NOTIFY for " << zonename << " from " << p.getRemoteString() << " for which we are not authoritative, trying autoprimary" << endl;
-      return tryAutoPrimary(p, p.getTSIGKeyname());
+      return tryAutoPrimary(p);
     }
     g_log<<Logger::Notice<<"Received NOTIFY for "<<zonename<<" from "<<p.getRemoteString()<<" for which we are not authoritative (Refused)"<<endl;
     return RCode::Refused;
@@ -1222,7 +1223,7 @@ int PacketHandler::processNotify(const DNSPacket& p)
     di.receivedNotify = true;
     Communicator.addSecondaryCheckRequest(di, p.getInnerRemote());
   }
-  return 0;
+  return RCode::NoError;
 }
 
 static bool validDNSName(const DNSName& name)
index 162e48c513227b87d7230cb834d59263cdda6f33..4ba29d115513c7aad401ddfa80b70448fb0e674d 100644 (file)
@@ -69,7 +69,7 @@ public:
   static const std::shared_ptr<CDSRecordContent> s_deleteCDSContent;
 
 private:
-  int tryAutoPrimary(const DNSPacket& p, const DNSName& tsigkeyname);
+  int tryAutoPrimary(const DNSPacket& p);
   int processNotify(const DNSPacket& );
   void addRootReferral(DNSPacket& r);
   int doChaosRequest(const DNSPacket& p, std::unique_ptr<DNSPacket>& r, DNSName &target) const;