lib/dns/zone.c refactoring
While reviewing a MR that touches lib/dns/zone.c
, I have notice several things:
-
zone_postload()
needs to be refactored, the functions spans from line 4696 to to line 5290 (e.g. 400 lines) -
zone_rekey()
also need to be refactored as it spans from line 19317 to line 19734 -
keyfetch_done()
spans from line 9993 to line 10647 (600 lines) -
zone_nsec3chain()
~900 lines -
The locked parameter in zone_locked()
should be removed in favor of just locking the zone prior to the call -
There's probably a missing lock in dns_zone_catz_enable_db()
-
There's probably a missing lock around dns_zone_rpz_disable_db()
anddns_zone_catz_disable_db()
call -
There's lot of unlocked access to dns_zone_t members in zone_nsec3chain()
andzone_sign()
at the top of the function -
There's unlocked access to dns_zone_t members in zone_maintenance()
(zone->view
,zone->type
,zone->masters
, ...) -
There's unlocked access to zone->maxrecords
indns_zone_getmaxrecords()
anddns_zone_setmaxrecords()
-
There's unlocked access to zone->origin
,zone->flags
,zone->dblock
, and other members of dns_zone_t inzone_notify()
-
zone_rekey()
contains unlocked access tozone->mctx
,zone->origin
,zone->rdclass
and other members
The list here is neither complete or necessarily correct. Some of the struct members might be read-only (e.g. protected by reference counting), but the struct comment is saying "/* Locked */", so if they are truly read-only, perhaps casting them to const
would be a right thing to do. Also I mostly checked only static functions and looked only at dns_zone_t *
accesses.