]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #8565 from criteo-forks/stop_weighted
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Mon, 17 Aug 2020 11:09:10 +0000 (13:09 +0200)
committerGitHub <noreply@github.com>
Mon, 17 Aug 2020 11:09:10 +0000 (13:09 +0200)
geoipbackend: stop looking after first weighted match

1  2 
modules/geoipbackend/geoipbackend.cc

index 7b66211810155fde8349ce54a22cf4000a1e58a6,de4fc00286c32ce1a38dcbc137f95b581b8fe232..21ddd990f589a61aa01b5b8a245e044a6f18dede
@@@ -318,10 -319,11 +319,11 @@@ bool GeoIPBackend::lookup_static(const 
  
    if (i != dom.records.end()) { // return static value
      for(const auto& rr : i->second) {
-       if (qtype != QType::ANY && rr.qtype != qtype) continue;
+       if ((qtype != QType::ANY && rr.qtype != qtype) || weighted_match[rr.qtype.getCode()])
+         continue;
  
        if (rr.has_weight) {
 -        gl.netmask = (addr.isIpv6()?128:32);
 +        gl.netmask = (addr.isIPv6()?128:32);
          int comp = cumul_probabilities[rr.qtype.getCode()];
          cumul_probabilities[rr.qtype.getCode()] += rr.weight;
          if (rr.weight == 0 || probability_rnd < comp || probability_rnd > (comp + rr.weight))