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

PowerDNS / pdns / 25506851162

07 May 2026 03:53PM UTC coverage: 66.322% (-4.7%) from 71.06%
25506851162

Pull #17307

github

web-flow
Merge fa2e9fcc0 into 8e748e818
Pull Request #17307: dnsdist: Fix invalid TCP rate limiting computation

39844 of 72852 branches covered (54.69%)

Branch coverage included in aggregate %.

87 of 91 new or added lines in 2 files covered. (95.6%)

11008 existing lines in 103 files now uncovered.

109034 of 151624 relevant lines covered (71.91%)

6712564.02 hits per line

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

46.72
/pdns/statnode.cc
1
#include "statnode.hh"
2

3
StatNode::Stat StatNode::print(unsigned int depth, Stat newstat, bool silent) const
4
{
×
5
  if(!silent) {
×
6
    cout<<string(depth, ' ');
×
7
    cout<<name<<": "<<endl;
×
8
  }
×
9
  Stat childstat;
×
10
  childstat.queries += s.queries;
×
11
  childstat.noerrors += s.noerrors;
×
12
  childstat.nxdomains += s.nxdomains;
×
13
  childstat.servfails += s.servfails;
×
14
  childstat.drops += s.drops;
×
15
  childstat.bytes += s.bytes;
×
16
  childstat.hits += s.hits;
×
17

18
  if(children.size()>1024 && !silent) {
×
19
    cout<<string(depth, ' ')<<name<<": too many to print"<<endl;
×
20
  }
×
21
  for(const children_t::value_type& child :  children) {
×
22
    childstat=child.second.print(depth+8, childstat, silent || children.size()>1024);
×
23
  }
×
24
  if(!silent || children.size()>1)
×
25
    cout<<string(depth, ' ')<<childstat.queries<<" queries, " << 
×
26
      childstat.noerrors<<" noerrors, "<< 
×
27
      childstat.nxdomains<<" nxdomains, "<< 
×
28
      childstat.servfails<<" servfails, "<< 
×
29
      childstat.drops<<" drops, "<<
×
30
      childstat.bytes<<" bytes, "<<
×
31
      childstat.hits<<" hits"<<endl;
×
32

33
  newstat+=childstat;
×
34

35
  return newstat;
×
36
}
×
37

38
void StatNode::visit(const visitor_t& visitor, Stat& newstat, unsigned int depth) const
39
{
1,040✔
40
  Stat childstat(s);
1,040✔
41

42
  for (const auto& child : children) {
1,040✔
43
    child.second.visit(visitor, childstat, depth+8);
1,036✔
44
  }
1,036✔
45

46
  visitor(this, s, childstat);
1,040✔
47

48
  newstat += childstat;
1,040✔
49
}
1,040✔
50

51
void StatNode::submit(const DNSName& domain, int rcode, unsigned int bytes, bool hit, const std::optional<ComboAddress>& remote, size_t samplingRate)
52
{
1,024✔
53
  //  cerr<<"FIRST submit called on '"<<domain<<"'"<<endl;
54
  std::vector<string> tmp = domain.getRawLabels();
1,024✔
55
  if (tmp.empty()) {
1,024!
56
    return;
×
57
  }
×
58

59
  auto last = tmp.end() - 1;
1,024✔
60
  children[*last].submit(last, tmp.begin(), g_rootdnsname, rcode, bytes, remote, 1, hit, samplingRate);
1,024✔
61
}
1,024✔
62

63
static uint64_t adjustForSampling(uint32_t count, size_t samplingRate)
64
{
3,072✔
65
  if (samplingRate > 0) {
3,072!
66
    return count * samplingRate;
×
67
  }
×
68
  return count;
3,072✔
69
}
3,072✔
70

71

72
/* www.powerdns.com. ->
73
   .                 <- fullnames
74
   com.
75
   powerdns.com
76
   www.powerdns.com. 
77
*/
78

79
void StatNode::submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const DNSName& domain, int rcode, unsigned int bytes, const std::optional<ComboAddress>& remote, unsigned int count, bool hit, size_t samplingRate)
80
{
4,096✔
81
  //  cerr<<"Submit called for domain='"<<domain<<"': ";
82
  //  for(const std::string& n :  labels) 
83
  //    cerr<<n<<".";
84
  //  cerr<<endl;
85
  if (name.empty()) {
4,096✔
86

87
    name=*end;
1,036✔
88
    //    cerr<<"Set short name to '"<<name<<"'"<<endl;
89
  }
1,036✔
90
  else {
3,060✔
91
    //    cerr<<"Short name was already set to '"<<name<<"'"<<endl;
92
  }
3,060✔
93

94
  if (end == begin) {
4,096✔
95
    if (fullname.empty()) {
1,024!
96
      fullname = domain;
1,024✔
97
      fullname.prependRawLabel(name);
1,024✔
98
      labelsCount = count;
1,024✔
99
    }
1,024✔
100
    //    cerr<<"Hit the end, set our fullname to '"<<fullname<<"'"<<endl<<endl;
101
    s.queries += adjustForSampling(1U, samplingRate);
1,024✔
102
    s.bytes += adjustForSampling(bytes, samplingRate);
1,024✔
103
    if (rcode < 0) {
1,024!
104
      s.drops += adjustForSampling(1U, samplingRate);
×
105
    }
×
106
    else if (rcode == RCode::NoError) {
1,024!
107
      s.noerrors += adjustForSampling(1U, samplingRate);
1,024✔
108
    }
1,024✔
UNCOV
109
    else if (rcode == RCode::ServFail) {
×
UNCOV
110
      s.servfails += adjustForSampling(1U, samplingRate);
×
UNCOV
111
    }
×
112
    else if (rcode == RCode::NXDomain) {
×
113
      s.nxdomains += adjustForSampling(1U, samplingRate);
×
114
    }
×
115

116
    if (remote) {
1,024!
117
      s.remotes[*remote]++;
×
118
    }
×
119

120
    if (hit) {
1,024!
UNCOV
121
      s.hits += adjustForSampling(1U, samplingRate);
×
UNCOV
122
    }
×
123
  }
1,024✔
124
  else {
3,072✔
125
    if (fullname.empty()) {
3,072✔
126
      fullname = domain;
12✔
127
      fullname.prependRawLabel(name);
12✔
128
      labelsCount = count;
12✔
129
    }
12✔
130
    //    cerr<<"Not yet end, set our fullname to '"<<fullname<<"', recursing"<<endl;
131
    --end;
3,072✔
132
    children[*end].submit(end, begin, fullname, rcode, bytes, remote, count+1, hit, samplingRate);
3,072✔
133
  }
3,072✔
134
}
4,096✔
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

© 2026 Coveralls, Inc