]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix marking of problematic cached IP addresses (#1691)
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 23 Feb 2024 04:26:38 +0000 (04:26 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 23 Feb 2024 04:26:51 +0000 (04:26 +0000)
Since inception in 2017 commit fd9c47d, Dns::CachedIps::have() always
returned position zero after finding a matching IP address (at zero or
positive position). The bug affected two callers:

* markAsBad() always marked the first stored address (as bad);
* forgetMarking() always cleared the first stored address marking.

Buggy markings led to Squid sometimes not attempting to use a working
address (e.g., IPv4) while using a known problematic one (e.g., IPv6).

src/ipcache.cc

index 41290fdaee54b1ced8a3c98e47cda47daf55c61a..0e5b5d520d347071643430b738628dc333a97e4f 100644 (file)
@@ -991,6 +991,7 @@ Dns::CachedIps::have(const Ip::Address &ip, size_t *positionOrNil) const
             debugs(14, 7, ip << " at " << pos << " in " << *this);
             return true;
         }
+        ++pos; // TODO: Replace with std::views::enumerate() after upgrading to C++23
     }
     // no such address; leave *position as is
     debugs(14, 7, " no " << ip << " in " << *this);