• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 18743945403

23 Oct 2025 09:29AM UTC coverage: 65.845% (+0.02%) from 65.829%
18743945403

Pull #16356

github

web-flow
Merge 8a2027ef1 into efa3637e8
Pull Request #16356: auth 5.0: backport "pdnsutil: fix b2b-migrate to from sql to non-sql"

42073 of 92452 branches covered (45.51%)

Branch coverage included in aggregate %.

128008 of 165855 relevant lines covered (77.18%)

6379935.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.47
/pdns/recursordist/sortlist.cc
1
#include "sortlist.hh"
2
#include "dnsrecords.hh"
3

4
void SortList::clear()
5
{
×
6
  d_sortlist.clear();
×
7
}
×
8

9
int SortList::getMaxOrder(const Netmask& formask) const
10
{
1✔
11
  int order = 0;
1✔
12

13
  const auto* place = d_sortlist.lookup(formask);
1✔
14
  if (place != nullptr && place->first == formask) {
1!
15
    for (const auto& node_order : place->second.d_orders) {
×
16
      order = std::max(order, node_order.second);
×
17
    }
×
18
  }
×
19

20
  return order;
1✔
21
}
1✔
22

23
void SortList::addEntry(const Netmask& covers, const Netmask& answermask, int order)
24
{
8✔
25
  if (order < 0) {
8!
26
    order = getMaxOrder(covers);
×
27
    ++order;
×
28
  }
×
29
  //  cout<<"Adding for netmask "<<formask.toString()<<" the order instruction that "<<valmask.toString()<<" is order "<<order<<endl;
30
  d_sortlist.insert(covers).second.d_orders.insert(answermask).second = order;
8✔
31
}
8✔
32

33
std::unique_ptr<SortListOrderCmp> SortList::getOrderCmp(const ComboAddress& who) const
34
{
3,037✔
35
  if (!d_sortlist.match(who)) {
3,037✔
36
    return {};
3,036✔
37
  }
3,036✔
38
  const auto* fnd = d_sortlist.lookup(who);
1✔
39
  //  cerr<<"Returning sort order for "<<who.toString()<<", have "<<fnd->second.d_orders.size()<<" entries"<<endl;
40
  return make_unique<SortListOrderCmp>(fnd->second);
1✔
41
}
3,037✔
42

43
// call this with **stable_sort**
44
bool SortListOrderCmp::operator()(const DNSRecord& lhs, const DNSRecord& rhs) const
45
{
10✔
46
  bool aAddr = (lhs.d_type == QType::A || lhs.d_type == QType::AAAA);
10!
47
  bool bAddr = (rhs.d_type == QType::A || rhs.d_type == QType::AAAA);
10!
48

49
  // anything address related is always 'larger', rest is equal
50
  if (aAddr && !bAddr) {
10✔
51
    return false;
3✔
52
  }
3✔
53
  if (!aAddr && bAddr) {
7✔
54
    return true;
1✔
55
  }
1✔
56
  if (!aAddr && !bAddr) {
6!
57
    return false;
2✔
58
  }
2✔
59

60
  int aOrder = std::numeric_limits<int>::max();
4✔
61
  int bOrder = aOrder;
4✔
62

63
  ComboAddress laddr = getAddr(lhs);
4✔
64
  ComboAddress raddr = getAddr(rhs);
4✔
65

66
  if (d_slo.d_orders.match(laddr)) {
4✔
67
    aOrder = d_slo.d_orders.lookup(laddr)->second;
1✔
68
  }
1✔
69
  if (d_slo.d_orders.match(raddr)) {
4!
70
    bOrder = d_slo.d_orders.lookup(raddr)->second;
4✔
71
  }
4✔
72
  return aOrder < bOrder;
4✔
73
}
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc