]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Backport 12407 to rec-4.8.x: do not chain ecs enabled queries
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 10 Jan 2023 13:48:39 +0000 (14:48 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 10 Jan 2023 13:48:39 +0000 (14:48 +0100)
Backport of #12407

pdns/lwres.cc
pdns/lwres.hh
pdns/pdns_recursor.cc

index 7cc80f4e5961c58379e3dea697db168fe496369c..3329c1758f77e430c761f57ec0a0111ba5a91f98 100644 (file)
@@ -469,7 +469,7 @@ static LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& doma
       g_stats.ipv6queries++;
     }
 
-    ret = asendto((const char*)&*vpacket.begin(), vpacket.size(), 0, ip, qid, domain, type, &queryfd);
+    ret = asendto((const char*)&*vpacket.begin(), vpacket.size(), 0, ip, qid, domain, type, weWantEDNSSubnet, &queryfd);
 
     if (ret != LWResult::Result::Success) {
       return ret;
index 38a8817a1e9adf0d952f29a11a6134696b5f5d94..85ea64da0e750881e84eb72439a96426921f2dea 100644 (file)
@@ -75,7 +75,7 @@ public:
 };
 
 LWResult::Result asendto(const char *data, size_t len, int flags, const ComboAddress& ip, uint16_t id,
-                         const DNSName& domain, uint16_t qtype,  int* fd);
+                         const DNSName& domain, uint16_t qtype, bool ecs, int* fd);
 LWResult::Result arecvfrom(PacketBuffer& packet, int flags, const ComboAddress& ip, size_t *d_len, uint16_t id,
                            const DNSName& domain, uint16_t qtype, int fd, const struct timeval* now);
 
index ee826d784da70d37efe5adc2a3f7d1aac880fba5..6e9a32b4a04033c15fb55c761ebda931cf32540a 100644 (file)
@@ -261,7 +261,7 @@ thread_local std::unique_ptr<UDPClientSocks> t_udpclientsocks;
 
 /* these two functions are used by LWRes */
 LWResult::Result asendto(const char* data, size_t len, int flags,
-                         const ComboAddress& toaddr, uint16_t id, const DNSName& domain, uint16_t qtype, int* fd)
+                         const ComboAddress& toaddr, uint16_t id, const DNSName& domain, uint16_t qtype, bool ecs, int* fd)
 {
 
   auto pident = std::make_shared<PacketID>();
@@ -269,18 +269,24 @@ LWResult::Result asendto(const char* data, size_t len, int flags,
   pident->remote = toaddr;
   pident->type = qtype;
 
-  // see if there is an existing outstanding request we can chain on to, using partial equivalence function looking for the same
-  // query (qname and qtype) to the same host, but with a different message ID
-  pair<MT_t::waiters_t::iterator, MT_t::waiters_t::iterator> chain = MT->d_waiters.equal_range(pident, PacketIDBirthdayCompare());
-
-  for (; chain.first != chain.second; chain.first++) {
-    // Line below detected an issue with the two ways of ordering PackeIDs (birtday and non-birthday)
-    assert(chain.first->key->domain == pident->domain);
-    if (chain.first->key->fd > -1 && !chain.first->key->closed) { // don't chain onto existing chained waiter or a chain already processed
-      // cerr << "Insert " << id << ' ' << pident << " into chain for  " << chain.first->key << endl;
-      chain.first->key->chain.insert(id); // we can chain
-      *fd = -1; // gets used in waitEvent / sendEvent later on
-      return LWResult::Result::Success;
+  // We cannot merge ECS-enabled queries based on the ECS source only, as the scope 
+  // of the response might be narrower, so instead we do not chain ECS-enabled queries
+  // at all.
+  if (!ecs) {
+    // See if there is an existing outstanding request we can chain on to, using partial equivalence
+    // function looking for the same query (qname and qtype) to the same host, but with a different
+    // message ID.
+    auto chain = MT->d_waiters.equal_range(pident, PacketIDBirthdayCompare());
+
+    for (; chain.first != chain.second; chain.first++) {
+      // Line below detected an issue with the two ways of ordering PacketIDs (birthday and non-birthday)
+      assert(chain.first->key->domain == pident->domain);
+      // don't chain onto existing chained waiter or a chain already processed
+      if (chain.first->key->fd > -1 && !chain.first->key->closed) {
+        chain.first->key->chain.insert(id); // we can chain
+        *fd = -1;                           // gets used in waitEvent / sendEvent later on
+        return LWResult::Result::Success;
+      }
     }
   }