Coverage Report

Created: 2026-09-01 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bind9/lib/dns/db_p.h
Line
Count
Source
1
/*
2
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3
 *
4
 * SPDX-License-Identifier: MPL-2.0
5
 *
6
 * This Source Code Form is subject to the terms of the Mozilla Public
7
 * License, v. 2.0. If a copy of the MPL was not distributed with this
8
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9
 *
10
 * See the COPYRIGHT file distributed with this work for additional
11
 * information regarding copyright ownership.
12
 */
13
14
#pragma once
15
16
#include <isc/heap.h>
17
#include <isc/urcu.h>
18
19
#include <dns/nsec3.h>
20
#include <dns/types.h>
21
22
#ifdef STRONG_RWLOCK_CHECK
23
#define STRONG_RWLOCK_CHECK(cond) REQUIRE(cond)
24
#else
25
#define STRONG_RWLOCK_CHECK(cond)
26
#endif
27
28
22.5k
#define NODE_INITLOCK(l)    isc_rwlock_init((l))
29
0
#define NODE_DESTROYLOCK(l) isc_rwlock_destroy(l)
30
#define NODE_LOCK(l, t, tp)                                      \
31
10.1M
  {                                                        \
32
10.1M
    STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \
33
10.1M
    RWLOCK((l), (t));                                \
34
10.1M
    *tp = t;                                         \
35
10.1M
  }
36
#define NODE_UNLOCK(l, tp)                                       \
37
10.1M
  {                                                        \
38
10.1M
    STRONG_RWLOCK_CHECK(*tp != isc_rwlocktype_none); \
39
10.1M
    RWUNLOCK(l, *tp);                                \
40
10.1M
    *tp = isc_rwlocktype_none;                       \
41
10.1M
  }
42
18.3k
#define NODE_RDLOCK(l, tp) NODE_LOCK(l, isc_rwlocktype_read, tp);
43
10.1M
#define NODE_WRLOCK(l, tp) NODE_LOCK(l, isc_rwlocktype_write, tp);
44
#define NODE_FORCEUPGRADE(l, tp)                                 \
45
0
  ({                                                       \
46
0
    STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_read); \
47
0
    isc_result_t _result = isc_rwlock_tryupgrade(l); \
48
0
    if (_result == ISC_R_SUCCESS) {                  \
49
0
      *tp = isc_rwlocktype_write;              \
50
0
    } else {                                         \
51
0
      NODE_UNLOCK(l, tp);                      \
52
0
      NODE_WRLOCK(l, tp);                      \
53
0
    };                                               \
54
0
  })
55
56
0
#define TREE_INITLOCK(l)    isc_rwlock_init(l)
57
0
#define TREE_DESTROYLOCK(l) isc_rwlock_destroy(l)
58
#define TREE_LOCK(l, t, tp)                                      \
59
0
  {                                                        \
60
0
    STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \
61
0
    RWLOCK(l, t);                                    \
62
0
    *tp = t;                                         \
63
0
  }
64
#define TREE_UNLOCK(l, tp)                                       \
65
0
  {                                                        \
66
0
    STRONG_RWLOCK_CHECK(*tp != isc_rwlocktype_none); \
67
0
    RWUNLOCK(l, *tp);                                \
68
0
    *tp = isc_rwlocktype_none;                       \
69
0
  }
70
0
#define TREE_RDLOCK(l, tp) TREE_LOCK(l, isc_rwlocktype_read, tp);
71
0
#define TREE_WRLOCK(l, tp) TREE_LOCK(l, isc_rwlocktype_write, tp);
72
#define TREE_FORCEUPGRADE(l, tp)                                 \
73
0
  ({                                                       \
74
0
    STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_read); \
75
0
    isc_result_t _result = isc_rwlock_tryupgrade(l); \
76
0
    if (_result == ISC_R_SUCCESS) {                  \
77
0
      *tp = isc_rwlocktype_write;              \
78
0
    } else {                                         \
79
0
      TREE_UNLOCK(l, tp);                      \
80
0
      TREE_WRLOCK(l, tp);                      \
81
0
    };                                               \
82
0
  })
83
84
7.32k
#define IS_STUB(db)  (((db)->common.attributes & DNS_DBATTR_STUB) != 0)
85
#define IS_CACHE(db) (((db)->common.attributes & DNS_DBATTR_CACHE) != 0)
86
87
static inline bool
88
18.9M
prio_type(dns_typepair_t type) {
89
18.9M
  switch (type) {
90
2.14k
  case dns_rdatatype_soa:
91
10.1k
  case DNS_SIGTYPEPAIR(dns_rdatatype_soa):
92
29.9k
  case dns_rdatatype_a:
93
33.7k
  case DNS_SIGTYPEPAIR(dns_rdatatype_a):
94
42.1k
  case dns_rdatatype_mx:
95
52.4k
  case DNS_SIGTYPEPAIR(dns_rdatatype_mx):
96
62.7k
  case dns_rdatatype_aaaa:
97
76.1k
  case DNS_SIGTYPEPAIR(dns_rdatatype_aaaa):
98
285k
  case dns_rdatatype_nsec:
99
285k
  case DNS_SIGTYPEPAIR(dns_rdatatype_nsec):
100
289k
  case dns_rdatatype_nsec3:
101
289k
  case DNS_SIGTYPEPAIR(dns_rdatatype_nsec3):
102
13.0M
  case dns_rdatatype_ns:
103
13.4M
  case DNS_SIGTYPEPAIR(dns_rdatatype_ns):
104
13.4M
  case dns_rdatatype_ds:
105
13.4M
  case DNS_SIGTYPEPAIR(dns_rdatatype_ds):
106
13.4M
  case dns_rdatatype_cname:
107
13.4M
  case DNS_SIGTYPEPAIR(dns_rdatatype_cname):
108
13.4M
  case dns_rdatatype_dname:
109
13.4M
  case DNS_SIGTYPEPAIR(dns_rdatatype_dname):
110
13.4M
  case dns_rdatatype_svcb:
111
13.4M
  case DNS_SIGTYPEPAIR(dns_rdatatype_svcb):
112
13.5M
  case dns_rdatatype_https:
113
13.5M
  case DNS_SIGTYPEPAIR(dns_rdatatype_https):
114
13.5M
  case dns_rdatatype_dnskey:
115
13.6M
  case DNS_SIGTYPEPAIR(dns_rdatatype_dnskey):
116
13.7M
  case dns_rdatatype_srv:
117
13.7M
  case DNS_SIGTYPEPAIR(dns_rdatatype_srv):
118
13.7M
  case dns_rdatatype_txt:
119
13.7M
  case DNS_SIGTYPEPAIR(dns_rdatatype_txt):
120
13.8M
  case dns_rdatatype_ptr:
121
13.8M
  case DNS_SIGTYPEPAIR(dns_rdatatype_ptr):
122
13.8M
  case dns_rdatatype_naptr:
123
13.8M
  case DNS_SIGTYPEPAIR(dns_rdatatype_naptr):
124
13.8M
    return true;
125
18.9M
  }
126
5.18M
  return false;
127
18.9M
}
Unexecuted instantiation: lib.c:prio_type
qpzone.c:prio_type
Line
Count
Source
88
18.9M
prio_type(dns_typepair_t type) {
89
18.9M
  switch (type) {
90
2.14k
  case dns_rdatatype_soa:
91
10.1k
  case DNS_SIGTYPEPAIR(dns_rdatatype_soa):
92
29.9k
  case dns_rdatatype_a:
93
33.7k
  case DNS_SIGTYPEPAIR(dns_rdatatype_a):
94
42.1k
  case dns_rdatatype_mx:
95
52.4k
  case DNS_SIGTYPEPAIR(dns_rdatatype_mx):
96
62.7k
  case dns_rdatatype_aaaa:
97
76.1k
  case DNS_SIGTYPEPAIR(dns_rdatatype_aaaa):
98
285k
  case dns_rdatatype_nsec:
99
285k
  case DNS_SIGTYPEPAIR(dns_rdatatype_nsec):
100
289k
  case dns_rdatatype_nsec3:
101
289k
  case DNS_SIGTYPEPAIR(dns_rdatatype_nsec3):
102
13.0M
  case dns_rdatatype_ns:
103
13.4M
  case DNS_SIGTYPEPAIR(dns_rdatatype_ns):
104
13.4M
  case dns_rdatatype_ds:
105
13.4M
  case DNS_SIGTYPEPAIR(dns_rdatatype_ds):
106
13.4M
  case dns_rdatatype_cname:
107
13.4M
  case DNS_SIGTYPEPAIR(dns_rdatatype_cname):
108
13.4M
  case dns_rdatatype_dname:
109
13.4M
  case DNS_SIGTYPEPAIR(dns_rdatatype_dname):
110
13.4M
  case dns_rdatatype_svcb:
111
13.4M
  case DNS_SIGTYPEPAIR(dns_rdatatype_svcb):
112
13.5M
  case dns_rdatatype_https:
113
13.5M
  case DNS_SIGTYPEPAIR(dns_rdatatype_https):
114
13.5M
  case dns_rdatatype_dnskey:
115
13.6M
  case DNS_SIGTYPEPAIR(dns_rdatatype_dnskey):
116
13.7M
  case dns_rdatatype_srv:
117
13.7M
  case DNS_SIGTYPEPAIR(dns_rdatatype_srv):
118
13.7M
  case dns_rdatatype_txt:
119
13.7M
  case DNS_SIGTYPEPAIR(dns_rdatatype_txt):
120
13.8M
  case dns_rdatatype_ptr:
121
13.8M
  case DNS_SIGTYPEPAIR(dns_rdatatype_ptr):
122
13.8M
  case dns_rdatatype_naptr:
123
13.8M
  case DNS_SIGTYPEPAIR(dns_rdatatype_naptr):
124
13.8M
    return true;
125
18.9M
  }
126
5.18M
  return false;
127
18.9M
}
Unexecuted instantiation: db.c:prio_type
Unexecuted instantiation: qpcache.c:prio_type
128
129
void
130
dns__db_logtoomanyrecords(dns_db_t *db, const dns_name_t *name,
131
        dns_rdatatype_t type, const char *op, uint32_t limit);
132
/*
133
 * Emit a log message when adding an rdataset of name/type would exceed the
134
 * 'maxrrperset' limit. 'op' is 'adding' or 'updating' depending on whether
135
 * the addition is to create a new rdataset or to merge to an existing one.
136
 */
137
138
/*%
139
 * Internal dns_db constructor and destructor.
140
 */
141
void
142
dns__db_initialize(void);
143
void
144
dns__db_shutdown(void);