/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/rdatavec.h> |
21 | | #include <dns/types.h> |
22 | | |
23 | | #ifdef STRONG_RWLOCK_CHECK |
24 | | #define STRONG_RWLOCK_CHECK(cond) REQUIRE(cond) |
25 | | #else |
26 | | #define STRONG_RWLOCK_CHECK(cond) |
27 | | #endif |
28 | | |
29 | 22.5k | #define NODE_INITLOCK(l) isc_rwlock_init((l)) |
30 | 0 | #define NODE_DESTROYLOCK(l) isc_rwlock_destroy(l) |
31 | | #define NODE_LOCK(l, t, tp) \ |
32 | 8.80M | { \ |
33 | 8.80M | STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \ |
34 | 8.80M | RWLOCK((l), (t)); \ |
35 | 8.80M | *tp = t; \ |
36 | 8.80M | } |
37 | | #define NODE_UNLOCK(l, tp) \ |
38 | 8.80M | { \ |
39 | 8.80M | STRONG_RWLOCK_CHECK(*tp != isc_rwlocktype_none); \ |
40 | 8.80M | RWUNLOCK(l, *tp); \ |
41 | 8.80M | *tp = isc_rwlocktype_none; \ |
42 | 8.80M | } |
43 | 19.3k | #define NODE_RDLOCK(l, tp) NODE_LOCK(l, isc_rwlocktype_read, tp); |
44 | 8.78M | #define NODE_WRLOCK(l, tp) NODE_LOCK(l, isc_rwlocktype_write, tp); |
45 | | #define NODE_FORCEUPGRADE(l, tp) \ |
46 | 0 | ({ \ |
47 | 0 | STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_read); \ |
48 | 0 | isc_result_t _result = isc_rwlock_tryupgrade(l); \ |
49 | 0 | if (_result == ISC_R_SUCCESS) { \ |
50 | 0 | *tp = isc_rwlocktype_write; \ |
51 | 0 | } else { \ |
52 | 0 | NODE_UNLOCK(l, tp); \ |
53 | 0 | NODE_WRLOCK(l, tp); \ |
54 | 0 | }; \ |
55 | 0 | }) |
56 | | |
57 | 0 | #define TREE_INITLOCK(l) isc_rwlock_init(l) |
58 | 0 | #define TREE_DESTROYLOCK(l) isc_rwlock_destroy(l) |
59 | | #define TREE_LOCK(l, t, tp) \ |
60 | 0 | { \ |
61 | 0 | STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \ |
62 | 0 | RWLOCK(l, t); \ |
63 | 0 | *tp = t; \ |
64 | 0 | } |
65 | | #define TREE_UNLOCK(l, tp) \ |
66 | 0 | { \ |
67 | 0 | STRONG_RWLOCK_CHECK(*tp != isc_rwlocktype_none); \ |
68 | 0 | RWUNLOCK(l, *tp); \ |
69 | 0 | *tp = isc_rwlocktype_none; \ |
70 | 0 | } |
71 | 0 | #define TREE_RDLOCK(l, tp) TREE_LOCK(l, isc_rwlocktype_read, tp); |
72 | 0 | #define TREE_WRLOCK(l, tp) TREE_LOCK(l, isc_rwlocktype_write, tp); |
73 | | #define TREE_FORCEUPGRADE(l, tp) \ |
74 | 0 | ({ \ |
75 | 0 | STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_read); \ |
76 | 0 | isc_result_t _result = isc_rwlock_tryupgrade(l); \ |
77 | 0 | if (_result == ISC_R_SUCCESS) { \ |
78 | 0 | *tp = isc_rwlocktype_write; \ |
79 | 0 | } else { \ |
80 | 0 | TREE_UNLOCK(l, tp); \ |
81 | 0 | TREE_WRLOCK(l, tp); \ |
82 | 0 | }; \ |
83 | 0 | }) |
84 | | |
85 | 2.04k | #define IS_STUB(db) (((db)->common.attributes & DNS_DBATTR_STUB) != 0) |
86 | | #define IS_CACHE(db) (((db)->common.attributes & DNS_DBATTR_CACHE) != 0) |
87 | | |
88 | | struct dns_glue { |
89 | | struct dns_glue *next; |
90 | | dns_name_t name; |
91 | | dns_rdataset_t rdataset_a; |
92 | | dns_rdataset_t sigrdataset_a; |
93 | | dns_rdataset_t rdataset_aaaa; |
94 | | dns_rdataset_t sigrdataset_aaaa; |
95 | | }; |
96 | | |
97 | | struct dns_gluelist { |
98 | | isc_mem_t *mctx; |
99 | | |
100 | | const dns_dbversion_t *version; |
101 | | dns_vecheader_t *header; |
102 | | |
103 | | struct dns_glue *glue; |
104 | | |
105 | | struct rcu_head rcu_head; |
106 | | struct cds_wfs_node wfs_node; |
107 | | }; |
108 | | |
109 | | typedef struct dns_glue_additionaldata_ctx { |
110 | | dns_db_t *db; |
111 | | dns_dbversion_t *version; |
112 | | dns_dbnode_t *node; |
113 | | |
114 | | dns_glue_t *glue; |
115 | | } dns_glue_additionaldata_ctx_t; |
116 | | |
117 | | static inline bool |
118 | 17.0M | prio_type(dns_typepair_t type) { |
119 | 17.0M | switch (type) { |
120 | 1.39k | case dns_rdatatype_soa: |
121 | 44.4k | case DNS_SIGTYPEPAIR(dns_rdatatype_soa): |
122 | 65.3k | case dns_rdatatype_a: |
123 | 76.5k | case DNS_SIGTYPEPAIR(dns_rdatatype_a): |
124 | 149k | case dns_rdatatype_mx: |
125 | 160k | case DNS_SIGTYPEPAIR(dns_rdatatype_mx): |
126 | 160k | case dns_rdatatype_aaaa: |
127 | 173k | case DNS_SIGTYPEPAIR(dns_rdatatype_aaaa): |
128 | 182k | case dns_rdatatype_nsec: |
129 | 182k | case DNS_SIGTYPEPAIR(dns_rdatatype_nsec): |
130 | 185k | case dns_rdatatype_nsec3: |
131 | 186k | case DNS_SIGTYPEPAIR(dns_rdatatype_nsec3): |
132 | 14.3M | case dns_rdatatype_ns: |
133 | 14.3M | case DNS_SIGTYPEPAIR(dns_rdatatype_ns): |
134 | 14.3M | case dns_rdatatype_ds: |
135 | 14.3M | case DNS_SIGTYPEPAIR(dns_rdatatype_ds): |
136 | 14.3M | case dns_rdatatype_cname: |
137 | 14.3M | case DNS_SIGTYPEPAIR(dns_rdatatype_cname): |
138 | 14.3M | case dns_rdatatype_dname: |
139 | 14.3M | case DNS_SIGTYPEPAIR(dns_rdatatype_dname): |
140 | 14.4M | case dns_rdatatype_svcb: |
141 | 14.4M | case DNS_SIGTYPEPAIR(dns_rdatatype_svcb): |
142 | 14.4M | case dns_rdatatype_https: |
143 | 14.4M | case DNS_SIGTYPEPAIR(dns_rdatatype_https): |
144 | 14.4M | case dns_rdatatype_dnskey: |
145 | 14.4M | case DNS_SIGTYPEPAIR(dns_rdatatype_dnskey): |
146 | 14.4M | case dns_rdatatype_srv: |
147 | 14.4M | case DNS_SIGTYPEPAIR(dns_rdatatype_srv): |
148 | 14.5M | case dns_rdatatype_txt: |
149 | 14.5M | case DNS_SIGTYPEPAIR(dns_rdatatype_txt): |
150 | 14.5M | case dns_rdatatype_ptr: |
151 | 14.5M | case DNS_SIGTYPEPAIR(dns_rdatatype_ptr): |
152 | 14.5M | case dns_rdatatype_naptr: |
153 | 14.5M | case DNS_SIGTYPEPAIR(dns_rdatatype_naptr): |
154 | 14.5M | return true; |
155 | 17.0M | } |
156 | 2.45M | return false; |
157 | 17.0M | } Unexecuted instantiation: lib.c:prio_type Line | Count | Source | 118 | 17.0M | prio_type(dns_typepair_t type) { | 119 | 17.0M | switch (type) { | 120 | 1.39k | case dns_rdatatype_soa: | 121 | 44.4k | case DNS_SIGTYPEPAIR(dns_rdatatype_soa): | 122 | 65.3k | case dns_rdatatype_a: | 123 | 76.5k | case DNS_SIGTYPEPAIR(dns_rdatatype_a): | 124 | 149k | case dns_rdatatype_mx: | 125 | 160k | case DNS_SIGTYPEPAIR(dns_rdatatype_mx): | 126 | 160k | case dns_rdatatype_aaaa: | 127 | 173k | case DNS_SIGTYPEPAIR(dns_rdatatype_aaaa): | 128 | 182k | case dns_rdatatype_nsec: | 129 | 182k | case DNS_SIGTYPEPAIR(dns_rdatatype_nsec): | 130 | 185k | case dns_rdatatype_nsec3: | 131 | 186k | case DNS_SIGTYPEPAIR(dns_rdatatype_nsec3): | 132 | 14.3M | case dns_rdatatype_ns: | 133 | 14.3M | case DNS_SIGTYPEPAIR(dns_rdatatype_ns): | 134 | 14.3M | case dns_rdatatype_ds: | 135 | 14.3M | case DNS_SIGTYPEPAIR(dns_rdatatype_ds): | 136 | 14.3M | case dns_rdatatype_cname: | 137 | 14.3M | case DNS_SIGTYPEPAIR(dns_rdatatype_cname): | 138 | 14.3M | case dns_rdatatype_dname: | 139 | 14.3M | case DNS_SIGTYPEPAIR(dns_rdatatype_dname): | 140 | 14.4M | case dns_rdatatype_svcb: | 141 | 14.4M | case DNS_SIGTYPEPAIR(dns_rdatatype_svcb): | 142 | 14.4M | case dns_rdatatype_https: | 143 | 14.4M | case DNS_SIGTYPEPAIR(dns_rdatatype_https): | 144 | 14.4M | case dns_rdatatype_dnskey: | 145 | 14.4M | case DNS_SIGTYPEPAIR(dns_rdatatype_dnskey): | 146 | 14.4M | case dns_rdatatype_srv: | 147 | 14.4M | case DNS_SIGTYPEPAIR(dns_rdatatype_srv): | 148 | 14.5M | case dns_rdatatype_txt: | 149 | 14.5M | case DNS_SIGTYPEPAIR(dns_rdatatype_txt): | 150 | 14.5M | case dns_rdatatype_ptr: | 151 | 14.5M | case DNS_SIGTYPEPAIR(dns_rdatatype_ptr): | 152 | 14.5M | case dns_rdatatype_naptr: | 153 | 14.5M | case DNS_SIGTYPEPAIR(dns_rdatatype_naptr): | 154 | 14.5M | return true; | 155 | 17.0M | } | 156 | 2.45M | return false; | 157 | 17.0M | } |
Unexecuted instantiation: db.c:prio_type Unexecuted instantiation: qpcache.c:prio_type |
158 | | |
159 | | void |
160 | | dns__db_logtoomanyrecords(dns_db_t *db, const dns_name_t *name, |
161 | | dns_rdatatype_t type, const char *op, uint32_t limit); |
162 | | /* |
163 | | * Emit a log message when adding an rdataset of name/type would exceed the |
164 | | * 'maxrrperset' limit. 'op' is 'adding' or 'updating' depending on whether |
165 | | * the addition is to create a new rdataset or to merge to an existing one. |
166 | | */ |
167 | | |
168 | | /*% |
169 | | * Internal dns_db constructor and destructor. |
170 | | */ |
171 | | void |
172 | | dns__db_initialize(void); |
173 | | void |
174 | | dns__db_shutdown(void); |