]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Implement deferred mode for additionals
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 23 Mar 2022 11:48:07 +0000 (12:48 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 1 Apr 2022 08:00:55 +0000 (10:00 +0200)
pdns/syncres.cc

index 3f80f1caea5287072020f83349421aa90e77879c..e5c22cdf95bd8a32607eafe9149ed88675640c39 100644 (file)
@@ -302,12 +302,40 @@ void SyncRes::resolveAdditionals(const DNSName& qname, QType qtype, AdditionalMo
     }
     break;
   }
-  case AdditionalMode::ResolveDeferred:
-    // FIXME: Not yet implemented
-    // Look in cache for authoritative answer, if available return it
-    // If not, look in nergache and submit if not there as well. The logic should be the same as
-    // #11294, which is in review atm.
+  case AdditionalMode::ResolveDeferred: {
+    const bool oldCacheOnly = setCacheOnly(true);
+    set<GetBestNSAnswer> beenthere;
+    int res = doResolve(qname, qtype, addRecords, depth, beenthere, state);
+    setCacheOnly(oldCacheOnly);
+    if (res == 0 && addRecords.size() > 0) {
+      // We're conservative here. We do not add Bogus records in any circumstance, we add Indeterminates only if no
+      // validation is required.
+      if (vStateIsBogus(state)) {
+        return;
+      }
+      if (shouldValidate() && state != vState::Secure && state != vState::Insecure) {
+        return;
+      }
+      bool found = false;
+      for (auto& rec : addRecords) {
+        if (rec.d_place == DNSResourceRecord::ANSWER) {
+          found = true;
+          additionals.push_back(std::move(rec));
+        }
+      }
+      if (found) {
+        return;
+      }
+    }
+    // Not found in cache, check negcache and push task if also not in negcache
+    NegCache::NegCacheEntry ne;
+    bool inNegCache = g_negCache->get(qname, qtype, d_now, ne, false);
+    if (!inNegCache) {
+      pushResolveTask(qname, qtype, d_now.tv_sec, d_now.tv_sec + 60);
+    } else {
+    }
     break;
+  }
   case AdditionalMode::Ignore:
     break;
   }