2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

8869 Commits

Author SHA1 Message Date
Aram Sargsyan
cf79692a66 catz: unregister the db update-notify callback before detaching from db
When detaching from the previous version of the database, make sure
that the update-notify callback is unregistered, otherwise there is
an INSIST check which can generate an assertion failure in free_rbtdb(),
which checks that there are no outstanding update listeners in the list.

There is a similar code already in place for RPZ.
2023-02-27 10:06:32 +00:00
Aram Sargsyan
0ef0c86632 Searching catzs->zones requires a read lock
Lock the catzs->lock mutex before searching in the catzs->zones
hash table.
2023-02-27 10:06:32 +00:00
Aram Sargsyan
ed268b46f1 Process db callbacks in zone_loaddone() after zone_postload()
The zone_postload() function can fail and unregister the callbacks.

Call dns_db_endload() only after calling zone_postload() to make
sure that the registered update-notify callbacks are not called
when the zone loading has failed during zone_postload().

Also, don't ignore the return value of zone_postload().
2023-02-27 10:06:32 +00:00
Aram Sargsyan
030ffbf475 Make sure catz->catzs isn't destroyed before catz
Call dns_catz_unref_catzs() only after detaching 'catz'.
2023-02-24 19:40:34 +00:00
Ondřej Surý
4e7187601f
Pause the catz dbiterator while processing the zone
The dbiterator read-locks the whole zone and it stayed locked during
whole processing time when catz is being read.  Pause the iterator, so
the updates to catz zone are not being blocked while processing the catz
update.
2023-02-24 17:06:18 +01:00
Ondřej Surý
b1cd4a066a
Unlock catzs during dns__catz_update_cb()
Instead of holding the catzs->lock the whole time we process the catz
update, only hold it for hash table lookup and then release it.  This
should unblock any other threads that might be processing updates to
catzs triggered by extra incoming transfer.
2023-02-24 17:04:33 +01:00
Aram Sargsyan
0b96c9234f
Offload catalog zone updates
Offload catalog zone processing so that the network manager threads
are not interrupted by a large catalog zone update.

Introduce a new 'updaterunning' state alongside with 'updatepending',
like it is done in the RPZ module.

Note that the dns__catz_update_cb() function currently holds the
catzs->lock during the whole process, which is far from being optimal,
but the issue is going to be addressed separately.
2023-02-24 15:18:02 +01:00
Aram Sargsyan
246b7084d6
Add shutdown signaling for catalog zones
This change should make sure that catalog zone update processing
doesn't happen when the catalog zone is being shut down. This
should help avoid races when offloading the catalog zone updates
in the follow-up commit.
2023-02-24 15:06:54 +01:00
Aram Sargsyan
53f0c5a9ac
Add reference count tracing for dns_catz_zone_t and dns_catz_zones_t
Tracing can be activated by defining DNS_RPZ_TRACE in catz.h.
2023-02-24 15:00:26 +01:00
Aram Sargsyan
8cb79fec9d
Light refactoring of catz.c
* Change 'dns_catz_new_zones()' function's prototype (the order of the
  arguments) to synchronize it with the similar function in rpz.c.
* Rename 'refs' to 'references' in preparation of ISC_REFCOUNT_*
  macros usage for reference tracking.
* Unify dns_catz_zone_t naming to catz, and dns_catz_zones_t naming to
  catzs, following the logic of similar changes in rpz.c.
* Use C compound literals for structure initialization.
* Synchronize the "new zone version came too soon" log message with the
  one in rpz.c.
* Use more of 'sizeof(*ptr)' style instead of the 'sizeof(type_t)' style
  expressions when allocating or freeing memory for 'ptr'.
2023-02-24 15:00:26 +01:00
Tony Finch
330ff06d4a Move irs_resconf into libdns and remove libirs
`libirs` used to be a reference implementation of `getaddrinfo` and
related modern resolver APIs. It was stripped down in BIND 9.18
leaving only the `irs_resconf` module, which parses
`/etc/resolv.conf`. I have kept its include path and namespace prefix,
so it remains a little fragment of libirs now embedded in libdns.
2023-02-24 09:38:59 +00:00
Evan Hunt
4e93d44c74 fix a bug in dns_dispatch_getnext()
when a message arrives over a TCP connection matching an expected
QID, the dispatch is updated so it no longer expects that QID,
but continues reading. subsequent messages with the same QID are
ignored, unless the dispatch entry has called dns_dispatch_getnext()
or dns_dispatch_resume().

however, a coding error caused those functions to have no effect
when the dispatch was reading, so streams of messages with the same
QID could not be received over a single TCP connection, breaking *XFR.

this has been corrected by changing the order of operations in
tcp_dispatch_getnext() so that disp->reading isn't checked until
after the dispatch entry has been reactivated.
2023-02-24 08:30:33 +00:00
Evan Hunt
f0c766abec refactor dns_xfrin to use dns_dispatch
the dns_xfrin module was still using the network manager directly to
manage TCP connections and send and receive messages.  this commit
changes it to use the dispatch manager instead.
2023-02-24 08:30:33 +00:00
Evan Hunt
a4c8decc6a implement refcount tracing in xfrin.c
use ISC_REFCOUNT_IMPL for dns_xfrin_ctx_t (which has been renamed
to dns_xfrin_t to keep the function names dns_xfrin_attach() and
dns_xfrin_detach() unchanged).
2023-02-24 08:30:33 +00:00
Evan Hunt
d72419d1f5 minor cleanups in dispatch.c
- simplified tcp_startrecv()
- removed a short function that was only called once
- removed an unnecessary if statement
2023-02-24 08:30:33 +00:00
Evan Hunt
1dd42a80d6 log the xfrin pointer address in xfrin_log()
to make it easier to trace xfrin events in the log, include
the address of the dns_xfrin_t object in all xfrin log messages.
2023-02-24 08:30:33 +00:00
Evan Hunt
9d37621012 remove dead code in dns_request
the 'connected' variable in 'dns_request_create()` was always false.
2023-02-24 08:30:33 +00:00
Evan Hunt
ae5ba54fbe move dispatchmgr from resolver to view
the 'dispatchmgr' member of the resolver object is used by both
the dns_resolver and dns_request modules, and may in the future
be used by others such as dns_xfrin. it doesn't make sense for it
to live in the resolver object; this commit moves it into dns_view.
2023-02-24 08:30:33 +00:00
Aram Sargsyan
18d67fa916 Remove catzs->loop
The 'loop' member of the dns_catz_zones structure is not used.
2023-02-23 08:56:37 +00:00
Evan Hunt
b058f99cb8 remove references to obsolete isc_task/timer functions
removed references in code comments, doc/dev documentation, etc, to
isc_task, isc_timer_reset(), and isc_timertype_inactive. also removed a
coccinelle patch related to isc_timer_reset() that was no longer needed.
2023-02-22 08:13:30 +00:00
Evan Hunt
603cdb6332 move the dns_sdb API
move all dns_sdb code into bin/named/builtin.c, which is the
only place from which it's called.

(note this is temporary: later we'll refactor builtin so that it's a
standalone dns_db implementation on its own instead of using SDB
as a wrapper.)
2023-02-21 10:13:10 -08:00
Evan Hunt
77e7eac54c enable detailed db tracing
move database attach/detach functions to db.c, instead of
requiring them to be implemented for every database type.
instead, they must implement a 'destroy' function that is
called when references go to zero.

this enables us to use ISC_REFCOUNT_IMPL for databases,
with detailed tracing enabled by setting DNS_DB_TRACE to 1.
2023-02-21 10:13:10 -08:00
Evan Hunt
8da43bb7f5 simplify dns_sdb API
SDB is currently (and foreseeably) only used by the named
builtin databases, so it only needs as much of its API as
those databases use.

- removed three flags defined for the SDB API that were always
  set the same by builtin databases.

- there were two different types of lookup functions defined for
  SDB, using slightly different function signatures. since backward
  compatibility is no longer a concern, we can eliminate the 'lookup'
  entry point and rename 'lookup2' to 'lookup'.

- removed the 'allnodes' entry point and all database iterator
  implementation code

- removed dns_sdb_putnamedrr() and dns_sdb_putnamedrdata() since
  they were never used.
2023-02-21 10:13:10 -08:00
Evan Hunt
ffa4757c79 use member name initialization for methods
initialize dns_dbmethods, dns_sdbmethods and dns_rdatasetmethods
using explicit struct member names, so we don't have to keep track
of NULLs for unimplemented functions any longer.
2023-02-21 10:13:10 -08:00
Evan Hunt
8036412aaa make fewer dns_db functions mandatory-to-implement
some dns_db functions would have crashed if the DB implementation failed
to implement them, requiring the implementations to add functions that
did nothing but return ISC_R_NOTIMPLEMENTED or some obvious default
value. we can just have the dns_db wrapper functions themselves return
those values, and clean up the implementations accordingly.
2023-02-21 10:13:10 -08:00
Evan Hunt
c90fafa45d remove rdatalist_p.h
make the private isc__rdatalist_* functions public dns_rdatalist
functions so that all the rdatalist primitives can be used by
callers to libdns. (this will be needed later for moving SDB and
SDLZ out of libdns.)
2023-02-21 10:13:10 -08:00
Mark Andrews
b41882cc75 Fix dns_kasp_attach / dns_kasp_detach usage
The kasp pointers in dns_zone_t should consistently be changed by
dns_kasp_attach and dns_kasp_detach so the usage is balanced.
2023-02-21 15:47:44 +01:00
Mark Andrews
9c17f4353b Cleanup left over 'fctx != NULL' test following refactoring
This was causing 'CID 436299: Null pointer dereferences (REVERSE_INULL)'
in Coverity.  Also removed an 'INSIST(fctx != NULL);' that should
no longer be needed.
2023-02-21 12:22:27 +00:00
Mark Andrews
d22257a370 In hmac_createctx free ctx on isc_hmac_init failure 2023-02-17 21:58:56 +00:00
Evan Hunt
1ee30be7ce
remove validator lock
as every validator function is loop-synchronized, it should no longer be
necessary to use a validator lock.

calling dns_validator_send(), dns_validator_cancel() or
dns_validator_destroy() from a thread other than the one on which the
validator is running will now cause an assertion failure; this should be
fine since the validator and resolver are tightly coupled, and the fetch
contexts and validators run in the same loops.
2023-02-17 07:18:25 +01:00
Ondřej Surý
7da99414c0
Implement proper reference counting in dns_validator
use reference counting in dns_validator to prevent use after free.
2023-02-17 07:18:25 +01:00
Evan Hunt
b4715a34a0
additional refactoring of dns_validator
refactor validator so that the validation status object (previously
called dns_valstatus_t, which was derived from dns_validatorevent_t), is
now part of the dns_validator object.  when calling validator callbacks,
the validator itself is now sent as the argument.

(note: this necessitates caution in the callback functions that are
internal to validator.c validators spawn other validators, and it can be
confusing at times whether we need to be looking at val, val->subvalidator,
or val->parent.)
2023-02-17 07:18:25 +01:00
Ondřej Surý
668d287d01
Don't remove ADB entry from LRU before trying to expire it
There was a code flow error that would remove the expired ADB entry from
the LRU list and then a check in the expire_entry() would cause
assertion error because it expect the ADB entry to be linked.

Additionally, the expire mechanism would loop for cases when we would
held only a read rwlock; in such case we need to upgrade the lock and
try again, not just try again.
2023-02-17 07:16:50 +01:00
Evan Hunt
a52b17d39b
remove isc_task completely
as there is no further use of isc_task in BIND, this commit removes
it, along with isc_taskmgr, isc_event, and all other related types.

functions that accepted taskmgr as a parameter have been cleaned up.
as a result of this change, some functions can no longer fail, so
they've been changed to type void, and their callers have been
updated accordingly.

the tasks table has been removed from the statistics channel and
the stats version has been updated. dns_dyndbctx has been changed
to reference the loopmgr instead of taskmgr, and DNS_DYNDB_VERSION
has been udpated as well.
2023-02-16 18:35:32 +01:00
Evan Hunt
a9f9041fe6
refactor dns_catz to use loop callbacks
catz events are now scheduled using isc_task_async() instead
of isc_task_send().
2023-02-16 17:51:55 +01:00
Evan Hunt
9bdf982ea6
refactor delzone to use loop callbacks
the rmzone() function is now posted using isc_async_run().

dns_zone_gettask() is no longer used anywhere, and has been
removed.
2023-02-16 17:51:55 +01:00
Evan Hunt
f58e7c28cd
switch to using isc_loopmgr_pause() instead of task exclusive
change functions using isc_taskmgr_beginexclusive() to use
isc_loopmgr_pause() instead.

also, removed an unnecessary use of exclusive mode in
named_server_tcptimeouts().

most functions that were implemented as task events because they needed
to be running in a task to use exclusive mode have now been changed
into loop callbacks instead. (the exception is catz, which is being
changed in a separate commit because it's a particularly complex change.)
2023-02-16 17:51:55 +01:00
Evan Hunt
0312789129
refactor dns_resolver to use loop callbacks
callback events from dns_resolver_createfetch() are now posted
using isc_async_run.

other modules which called the resolver and maintained task/taskmgr
objects for this purpose have been cleaned up.
2023-02-16 17:27:59 +01:00
Evan Hunt
bba46be63d
refactor dns_client to use loop callbacks
dns_client now uses isc_async_run() internally to post
client-resume events. (a task is still used for
dns_resolver_createfetch(), however.)
2023-02-16 17:16:42 +01:00
Evan Hunt
b061c7e27f
refactor plugin hook resumption to use loop callbacks
plugins supporting asynchronous operation now use a loop callback
to resume operation in query_hookresume() rather than a task.
2023-02-16 17:16:41 +01:00
Evan Hunt
7a78a85b35
refactor dns_validator to use loop callbacks
The validator now uses loop callbacks to post its completion
events. (A task is still used for the fetches.)
2023-02-16 14:55:06 +01:00
Evan Hunt
31aee2ef9c
refactor dns_adb to use loop callbacks
The callbacks from dns_abd_createfind() are now posted using
isc_async_run() instead of isc_task_send().  ADB event types
have been replaced with a new dns_adbstatus_t type which is
included as find->status.

(The ADB still uses a task for dns_resolver_createfetch().)
2023-02-16 14:55:06 +01:00
Evan Hunt
106da9c190
refactor dns_request to use loopmgr callbacks
dns_request_create() and _createraw() now take a 'loop' parameter
and run the callback event on the specified loop.

as the task manager is no longer used, it has been removed from
the dns_requestmgr structure.  the dns_resolver_taskmgr() function
is also no longer used and has been removed.
2023-02-16 14:55:06 +01:00
Tony Finch
eb6b31b6f2 Simplify locking in dns_view_detach()
Lock just once, and shut down the resolver, adb, and requestmgr after
unlocking, like the zone table, managed keys zone, and redirect zone.
2023-02-16 13:44:17 +00:00
Tony Finch
6927a30926 Remove do-nothing header <isc/print.h>
This one really truly did nothing. No lines added!
2023-02-15 16:44:47 +00:00
Tony Finch
c7615bc28d Remove do-nothing header <isc/offset.h>
And replace all uses of isc_offset_t with standard off_t
2023-02-15 16:44:47 +00:00
Tony Finch
bed09c1676 Remove do-nothing header <isc/netdb.h>
Not needed since we dropped Windows support
2023-02-15 16:44:47 +00:00
Tony Finch
97b64f4970 Remove deprecated dns_db_rpz_*() methods
As well as the function wrappers, their slots have been removed from
the dns_dbmethods table.
2023-02-15 15:35:50 +00:00
Ondřej Surý
c194ff5d77
Use C-RW-WP lock in the dns_adb unit
Replace the isc_mutex in the dns_adb unit with isc_rwlock for better
performance.  Both ADB names and ADB entries hashtables and LRU are now
using isc_rwlock.
2023-02-15 09:30:04 +01:00
Ondřej Surý
3d3d3b8c58
Use C-RW-WP lock in the dns_resolver unit
Replace the isc_mutex with isc_rwlock in the dns_resolver unit,
specifically, both fetch context and fetch counters now uses the C-RW-WP
locks.
2023-02-15 09:30:04 +01:00