mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 05:57:52 +00:00
libdns refactoring: integrate zone->options and zone->options2 into one enum, removing unnecessary flags.
This commit is contained in:
parent
7dbc6768d6
commit
ef0e68bfc3
@ -99,7 +99,7 @@ isc_boolean_t docheckmx = ISC_FALSE;
|
||||
isc_boolean_t dochecksrv = ISC_FALSE;
|
||||
isc_boolean_t docheckns = ISC_FALSE;
|
||||
#endif
|
||||
unsigned int zone_options = DNS_ZONEOPT_CHECKNS |
|
||||
dns_zoneopt_t zone_options = DNS_ZONEOPT_CHECKNS |
|
||||
DNS_ZONEOPT_CHECKMX |
|
||||
DNS_ZONEOPT_MANYERRORS |
|
||||
DNS_ZONEOPT_CHECKNAMES |
|
||||
@ -110,7 +110,6 @@ unsigned int zone_options = DNS_ZONEOPT_CHECKNS |
|
||||
DNS_ZONEOPT_CHECKWILDCARD |
|
||||
DNS_ZONEOPT_WARNMXCNAME |
|
||||
DNS_ZONEOPT_WARNSRVCNAME;
|
||||
unsigned int zone_options2 = 0;
|
||||
|
||||
/*
|
||||
* This needs to match the list in bin/named/log.c.
|
||||
@ -702,7 +701,6 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
|
||||
|
||||
dns_zone_setclass(zone, rdclass);
|
||||
dns_zone_setoption(zone, zone_options, ISC_TRUE);
|
||||
dns_zone_setoption2(zone, zone_options2, ISC_TRUE);
|
||||
dns_zone_setoption(zone, DNS_ZONEOPT_NOMERGE, nomerge);
|
||||
|
||||
dns_zone_setmaxttl(zone, maxttl);
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <dns/masterdump.h>
|
||||
#include <dns/types.h>
|
||||
#include <dns/zone.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
@ -49,8 +50,7 @@ extern isc_boolean_t nomerge;
|
||||
extern isc_boolean_t docheckmx;
|
||||
extern isc_boolean_t docheckns;
|
||||
extern isc_boolean_t dochecksrv;
|
||||
extern unsigned int zone_options;
|
||||
extern unsigned int zone_options2;
|
||||
extern dns_zoneopt_t zone_options;
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
|
@ -408,7 +408,7 @@ configure_zone(const char *vclass, const char *view,
|
||||
obj = NULL;
|
||||
if (get_maps(maps, "max-zone-ttl", &obj)) {
|
||||
maxttl = cfg_obj_asuint32(obj);
|
||||
zone_options2 |= DNS_ZONEOPT2_CHECKTTL;
|
||||
zone_options |= DNS_ZONEOPT_CHECKTTL;
|
||||
}
|
||||
|
||||
result = load_zone(mctx, zname, zfile, masterformat,
|
||||
|
@ -260,7 +260,7 @@ main(int argc, char **argv) {
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
zone_options2 |= DNS_ZONEOPT2_CHECKTTL;
|
||||
zone_options |= DNS_ZONEOPT_CHECKTTL;
|
||||
endp = NULL;
|
||||
maxttl = strtol(isc_commandline_argument, &endp, 0);
|
||||
if (*endp != '\0') {
|
||||
|
@ -3350,7 +3350,7 @@ create_empty_zone(dns_zone_t *zone, dns_name_t *name, dns_view_t *view,
|
||||
dns_db_closeversion(db, &version, ISC_TRUE);
|
||||
CHECK(dns_zone_replacedb(zone, db, ISC_FALSE));
|
||||
}
|
||||
dns_zone_setoption2(zone, DNS_ZONEOPT2_AUTOEMPTY, ISC_TRUE);
|
||||
dns_zone_setoption(zone, DNS_ZONEOPT_AUTOEMPTY, ISC_TRUE);
|
||||
dns_zone_setview(zone, view);
|
||||
CHECK(dns_view_addzone(view, zone));
|
||||
|
||||
|
@ -100,7 +100,7 @@ user_zonetype( dns_zone_t *zone ) {
|
||||
};
|
||||
const struct zt *tp;
|
||||
|
||||
if ((dns_zone_getoptions2(zone) & DNS_ZONEOPT2_AUTOEMPTY) != 0)
|
||||
if ((dns_zone_getoptions(zone) & DNS_ZONEOPT_AUTOEMPTY) != 0)
|
||||
return ("builtin");
|
||||
|
||||
view = dns_zone_getview(zone);
|
||||
|
@ -49,53 +49,38 @@ typedef enum {
|
||||
dns_zonestat_full
|
||||
} dns_zonestat_level_t;
|
||||
|
||||
#define DNS_ZONEOPT_SERVERS 0x00000001U /*%< perform server checks */
|
||||
#define DNS_ZONEOPT_PARENTS 0x00000002U /*%< perform parent checks */
|
||||
#define DNS_ZONEOPT_CHILDREN 0x00000004U /*%< perform child checks */
|
||||
#define DNS_ZONEOPT_NOTIFY 0x00000008U /*%< perform NOTIFY */
|
||||
#define DNS_ZONEOPT_MANYERRORS 0x00000010U /*%< return many errors on load */
|
||||
#define DNS_ZONEOPT_IXFRFROMDIFFS 0x00000020U /*%< calculate differences */
|
||||
#define DNS_ZONEOPT_NOMERGE 0x00000040U /*%< don't merge journal */
|
||||
#define DNS_ZONEOPT_CHECKNS 0x00000080U /*%< check if NS's are addresses */
|
||||
#define DNS_ZONEOPT_FATALNS 0x00000100U /*%< DNS_ZONEOPT_CHECKNS is fatal */
|
||||
#define DNS_ZONEOPT_MULTIMASTER 0x00000200U /*%< this zone has multiple masters */
|
||||
#define DNS_ZONEOPT_USEALTXFRSRC 0x00000400U /*%< use alternate transfer sources */
|
||||
#define DNS_ZONEOPT_CHECKNAMES 0x00000800U /*%< check-names */
|
||||
#define DNS_ZONEOPT_CHECKNAMESFAIL 0x00001000U /*%< fatal check-name failures */
|
||||
#define DNS_ZONEOPT_CHECKWILDCARD 0x00002000U /*%< check for internal wildcards */
|
||||
#define DNS_ZONEOPT_CHECKMX 0x00004000U /*%< check-mx */
|
||||
#define DNS_ZONEOPT_CHECKMXFAIL 0x00008000U /*%< fatal check-mx failures */
|
||||
#define DNS_ZONEOPT_CHECKINTEGRITY 0x00010000U /*%< perform integrity checks */
|
||||
#define DNS_ZONEOPT_CHECKSIBLING 0x00020000U /*%< perform sibling glue checks */
|
||||
#define DNS_ZONEOPT_NOCHECKNS 0x00040000U /*%< disable IN NS address checks */
|
||||
#define DNS_ZONEOPT_WARNMXCNAME 0x00080000U /*%< warn on MX CNAME check */
|
||||
#define DNS_ZONEOPT_IGNOREMXCNAME 0x00100000U /*%< ignore MX CNAME check */
|
||||
#define DNS_ZONEOPT_WARNSRVCNAME 0x00200000U /*%< warn on SRV CNAME check */
|
||||
#define DNS_ZONEOPT_IGNORESRVCNAME 0x00400000U /*%< ignore SRV CNAME check */
|
||||
#define DNS_ZONEOPT_UPDATECHECKKSK 0x00800000U /*%< check dnskey KSK flag */
|
||||
#define DNS_ZONEOPT_TRYTCPREFRESH 0x01000000U /*%< try tcp refresh on udp failure */
|
||||
#define DNS_ZONEOPT_NOTIFYTOSOA 0x02000000U /*%< Notify the SOA MNAME */
|
||||
#define DNS_ZONEOPT_NSEC3TESTZONE 0x04000000U /*%< nsec3-test-zone */
|
||||
#define DNS_ZONEOPT_SECURETOINSECURE 0x08000000U /*%< dnssec-secure-to-insecure */
|
||||
#define DNS_ZONEOPT_DNSKEYKSKONLY 0x10000000U /*%< dnssec-dnskey-kskonly */
|
||||
#define DNS_ZONEOPT_CHECKDUPRR 0x20000000U /*%< check-dup-records */
|
||||
#define DNS_ZONEOPT_CHECKDUPRRFAIL 0x40000000U /*%< fatal check-dup-records failures */
|
||||
#define DNS_ZONEOPT_CHECKSPF 0x80000000U /*%< check SPF records */
|
||||
|
||||
/*
|
||||
* The following zone options are shifted left into the
|
||||
* higher-order 32 bits of the options.
|
||||
*/
|
||||
#define DNS_ZONEOPT2_CHECKTTL 0x00000001U /*%< check max-zone-ttl */
|
||||
#define DNS_ZONEOPT2_AUTOEMPTY 0x00000002U /*%< automatic empty zone */
|
||||
|
||||
#ifndef NOMINUM_PUBLIC
|
||||
/*
|
||||
* Nominum specific options build down.
|
||||
*/
|
||||
#define DNS_ZONEOPT_NOTIFYFORWARD 0x80000000U /* forward notify to master */
|
||||
#endif /* NOMINUM_PUBLIC */
|
||||
|
||||
typedef enum {
|
||||
DNS_ZONEOPT_MANYERRORS = 1<<0, /*%< return many errors on load */
|
||||
DNS_ZONEOPT_IXFRFROMDIFFS = 1<<1, /*%< calculate differences */
|
||||
DNS_ZONEOPT_NOMERGE = 1<<2, /*%< don't merge journal */
|
||||
DNS_ZONEOPT_CHECKNS = 1<<3, /*%< check if NS's are addresses */
|
||||
DNS_ZONEOPT_FATALNS = 1<<4, /*%< DNS_ZONEOPT_CHECKNS is fatal */
|
||||
DNS_ZONEOPT_MULTIMASTER = 1<<5, /*%< this zone has multiple masters */
|
||||
DNS_ZONEOPT_USEALTXFRSRC = 1<<6, /*%< use alternate transfer sources */
|
||||
DNS_ZONEOPT_CHECKNAMES = 1<<7, /*%< check-names */
|
||||
DNS_ZONEOPT_CHECKNAMESFAIL = 1<<8, /*%< fatal check-name failures */
|
||||
DNS_ZONEOPT_CHECKWILDCARD = 1<<9, /*%< check for internal wildcards */
|
||||
DNS_ZONEOPT_CHECKMX = 1<<10, /*%< check-mx */
|
||||
DNS_ZONEOPT_CHECKMXFAIL = 1<<11, /*%< fatal check-mx failures */
|
||||
DNS_ZONEOPT_CHECKINTEGRITY = 1<<12, /*%< perform integrity checks */
|
||||
DNS_ZONEOPT_CHECKSIBLING = 1<<13, /*%< perform sibling glue checks */
|
||||
DNS_ZONEOPT_NOCHECKNS = 1<<14, /*%< disable IN NS address checks */
|
||||
DNS_ZONEOPT_WARNMXCNAME = 1<<15, /*%< warn on MX CNAME check */
|
||||
DNS_ZONEOPT_IGNOREMXCNAME = 1<<16, /*%< ignore MX CNAME check */
|
||||
DNS_ZONEOPT_WARNSRVCNAME = 1<<17, /*%< warn on SRV CNAME check */
|
||||
DNS_ZONEOPT_IGNORESRVCNAME = 1<<18, /*%< ignore SRV CNAME check */
|
||||
DNS_ZONEOPT_UPDATECHECKKSK = 1<<19, /*%< check dnskey KSK flag */
|
||||
DNS_ZONEOPT_TRYTCPREFRESH = 1<<20, /*%< try tcp refresh on udp failure */
|
||||
DNS_ZONEOPT_NOTIFYTOSOA = 1<<21, /*%< Notify the SOA MNAME */
|
||||
DNS_ZONEOPT_NSEC3TESTZONE = 1<<22, /*%< nsec3-test-zone */
|
||||
DNS_ZONEOPT_SECURETOINSECURE = 1<<23, /*%< dnssec-secure-to-insecure */
|
||||
DNS_ZONEOPT_DNSKEYKSKONLY = 1<<24, /*%< dnssec-dnskey-kskonly */
|
||||
DNS_ZONEOPT_CHECKDUPRR = 1<<25, /*%< check-dup-records */
|
||||
DNS_ZONEOPT_CHECKDUPRRFAIL = 1<<26, /*%< fatal check-dup-records failures */
|
||||
DNS_ZONEOPT_CHECKSPF = 1<<27, /*%< check SPF records */
|
||||
DNS_ZONEOPT_CHECKTTL = 1<<28, /*%< check max-zone-ttl */
|
||||
DNS_ZONEOPT_AUTOEMPTY = 1<<29 /*%< automatic empty zone */
|
||||
} dns_zoneopt_t;
|
||||
/*
|
||||
* Zone key maintenance options
|
||||
*/
|
||||
@ -681,37 +666,21 @@ dns_zone_unload(dns_zone_t *zone);
|
||||
*/
|
||||
|
||||
void
|
||||
dns_zone_setoption(dns_zone_t *zone, unsigned int option,
|
||||
isc_boolean_t value);
|
||||
void
|
||||
dns_zone_setoption2(dns_zone_t *zone, unsigned int option,
|
||||
dns_zone_setoption(dns_zone_t *zone, dns_zoneopt_t option,
|
||||
isc_boolean_t value);
|
||||
/*%<
|
||||
* Set the given options on ('value' == ISC_TRUE) or off
|
||||
* ('value' == #ISC_FALSE).
|
||||
*
|
||||
* dns_zone_setoption2() has been introduced because the number
|
||||
* of options needed now exceeds the 32 bits in the zone->options
|
||||
* field; it should be used set options with names beginning
|
||||
* with DNS_ZONEOPT2_.
|
||||
*
|
||||
* Require:
|
||||
*\li 'zone' to be a valid zone.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
dns_zoneopt_t
|
||||
dns_zone_getoptions(dns_zone_t *zone);
|
||||
unsigned int
|
||||
dns_zone_getoptions2(dns_zone_t *zone);
|
||||
/*%<
|
||||
* Returns the current zone options.
|
||||
*
|
||||
* Callers should be aware there is now more than one set of zone
|
||||
* options. dns_zone_getoptions2() has been introduced because the
|
||||
* number of options needed now exceeds the 32 bits in the
|
||||
* zone->options field. It returns the options whose names begin
|
||||
* with DNS_ZONEOPT2_.
|
||||
*
|
||||
* Require:
|
||||
*\li 'zone' to be a valid zone.
|
||||
*/
|
||||
|
@ -1174,7 +1174,6 @@ dns_zone_getnotifysrc4dscp
|
||||
dns_zone_getnotifysrc6
|
||||
dns_zone_getnotifysrc6dscp
|
||||
dns_zone_getoptions
|
||||
dns_zone_getoptions2
|
||||
dns_zone_getorigin
|
||||
dns_zone_getprivatetype
|
||||
dns_zone_getqueryacl
|
||||
@ -1278,7 +1277,6 @@ dns_zone_setnotifysrc6dscp
|
||||
dns_zone_setnotifytype
|
||||
dns_zone_setnsec3param
|
||||
dns_zone_setoption
|
||||
dns_zone_setoption2
|
||||
dns_zone_setorigin
|
||||
dns_zone_setprivatetype
|
||||
dns_zone_setqueryacl
|
||||
|
@ -218,8 +218,7 @@ struct dns_zone {
|
||||
dns_rdataclass_t rdclass;
|
||||
dns_zonetype_t type;
|
||||
unsigned int flags;
|
||||
unsigned int options;
|
||||
unsigned int options2;
|
||||
dns_zoneopt_t options;
|
||||
unsigned int db_argc;
|
||||
char **db_argv;
|
||||
isc_time_t expiretime;
|
||||
@ -498,7 +497,6 @@ typedef struct {
|
||||
* first time. */
|
||||
|
||||
#define DNS_ZONE_OPTION(z,o) (((z)->options & (o)) != 0)
|
||||
#define DNS_ZONE_OPTION2(z,o) (((z)->options2 & (o)) != 0)
|
||||
#define DNS_ZONEKEY_OPTION(z,o) (((z)->keyopts & (o)) != 0)
|
||||
|
||||
/* Flags for zone_load() */
|
||||
@ -941,7 +939,6 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
|
||||
zone->type = dns_zone_none;
|
||||
zone->flags = 0;
|
||||
zone->options = 0;
|
||||
zone->options2 = 0;
|
||||
zone->keyopts = 0;
|
||||
zone->db_argc = 0;
|
||||
zone->db_argv = NULL;
|
||||
@ -1648,9 +1645,9 @@ dns_zone_setmaxttl(dns_zone_t *zone, dns_ttl_t maxttl) {
|
||||
|
||||
LOCK_ZONE(zone);
|
||||
if (maxttl != 0)
|
||||
zone->options2 |= DNS_ZONEOPT2_CHECKTTL;
|
||||
zone->options |= DNS_ZONEOPT_CHECKTTL;
|
||||
else
|
||||
zone->options2 &= ~DNS_ZONEOPT2_CHECKTTL;
|
||||
zone->options &= ~DNS_ZONEOPT_CHECKTTL;
|
||||
zone->maxttl = maxttl;
|
||||
UNLOCK_ZONE(zone);
|
||||
|
||||
@ -2269,7 +2266,7 @@ get_master_options(dns_zone_t *zone) {
|
||||
options |= DNS_MASTER_CHECKMXFAIL;
|
||||
if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKWILDCARD))
|
||||
options |= DNS_MASTER_CHECKWILDCARD;
|
||||
if (DNS_ZONE_OPTION2(zone, DNS_ZONEOPT2_CHECKTTL))
|
||||
if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKTTL))
|
||||
options |= DNS_MASTER_CHECKTTL;
|
||||
return (options);
|
||||
}
|
||||
@ -5357,7 +5354,7 @@ dns_zone_setflag(dns_zone_t *zone, unsigned int flags, isc_boolean_t value) {
|
||||
}
|
||||
|
||||
void
|
||||
dns_zone_setoption(dns_zone_t *zone, unsigned int option,
|
||||
dns_zone_setoption(dns_zone_t *zone, dns_zoneopt_t option,
|
||||
isc_boolean_t value)
|
||||
{
|
||||
REQUIRE(DNS_ZONE_VALID(zone));
|
||||
@ -5370,34 +5367,13 @@ dns_zone_setoption(dns_zone_t *zone, unsigned int option,
|
||||
UNLOCK_ZONE(zone);
|
||||
}
|
||||
|
||||
void
|
||||
dns_zone_setoption2(dns_zone_t *zone, unsigned int option,
|
||||
isc_boolean_t value)
|
||||
{
|
||||
REQUIRE(DNS_ZONE_VALID(zone));
|
||||
|
||||
LOCK_ZONE(zone);
|
||||
if (value)
|
||||
zone->options2 |= option;
|
||||
else
|
||||
zone->options2 &= ~option;
|
||||
UNLOCK_ZONE(zone);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
dns_zoneopt_t
|
||||
dns_zone_getoptions(dns_zone_t *zone) {
|
||||
REQUIRE(DNS_ZONE_VALID(zone));
|
||||
|
||||
return (zone->options);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
dns_zone_getoptions2(dns_zone_t *zone) {
|
||||
REQUIRE(DNS_ZONE_VALID(zone));
|
||||
|
||||
return (zone->options2);
|
||||
}
|
||||
|
||||
void
|
||||
dns_zone_setkeyopt(dns_zone_t *zone, unsigned int keyopt, isc_boolean_t value)
|
||||
{
|
||||
|
@ -1714,7 +1714,7 @@ check_mx(ns_client_t *client, dns_zone_t *zone,
|
||||
isc_result_t result;
|
||||
struct in6_addr addr6;
|
||||
struct in_addr addr;
|
||||
unsigned int options;
|
||||
dns_zoneopt_t options;
|
||||
|
||||
dns_fixedname_init(&fixed);
|
||||
foundname = dns_fixedname_name(&fixed);
|
||||
@ -2503,7 +2503,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
dns_ssutable_t *ssutable = NULL;
|
||||
dns_fixedname_t tmpnamefixed;
|
||||
dns_name_t *tmpname = NULL;
|
||||
unsigned int options, options2;
|
||||
dns_zoneopt_t options;
|
||||
dns_difftuple_t *tuple;
|
||||
dns_rdata_dnskey_t dnskey;
|
||||
isc_boolean_t had_dnskey;
|
||||
@ -2782,7 +2782,6 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
*/
|
||||
|
||||
options = dns_zone_getoptions(zone);
|
||||
options2 = dns_zone_getoptions2(zone);
|
||||
for (result = dns_message_firstname(request, DNS_SECTION_UPDATE);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_message_nextname(request, DNS_SECTION_UPDATE))
|
||||
@ -2911,7 +2910,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
"a non-terminal wildcard", namestr);
|
||||
}
|
||||
|
||||
if ((options2 & DNS_ZONEOPT2_CHECKTTL) != 0) {
|
||||
if ((options & DNS_ZONEOPT_CHECKTTL) != 0) {
|
||||
maxttl = dns_zone_getmaxttl(zone);
|
||||
if (ttl > maxttl) {
|
||||
ttl = maxttl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user