diff --git a/bin/tests/system/checkconf/bad-prefetch1.conf b/bin/tests/system/checkconf/bad-prefetch1.conf new file mode 100644 index 0000000000..8051c63167 --- /dev/null +++ b/bin/tests/system/checkconf/bad-prefetch1.conf @@ -0,0 +1,16 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + prefetch 11; +}; diff --git a/bin/tests/system/checkconf/bad-prefetch2.conf b/bin/tests/system/checkconf/bad-prefetch2.conf new file mode 100644 index 0000000000..a2419a1d1a --- /dev/null +++ b/bin/tests/system/checkconf/bad-prefetch2.conf @@ -0,0 +1,16 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + prefetch 2 7; +}; diff --git a/bin/tests/system/checkconf/bad-prefetch3.conf b/bin/tests/system/checkconf/bad-prefetch3.conf new file mode 100644 index 0000000000..adee152be7 --- /dev/null +++ b/bin/tests/system/checkconf/bad-prefetch3.conf @@ -0,0 +1,16 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +view foo { + prefetch 11; +}; diff --git a/bin/tests/system/checkconf/bad-prefetch4.conf b/bin/tests/system/checkconf/bad-prefetch4.conf new file mode 100644 index 0000000000..5fc48c077e --- /dev/null +++ b/bin/tests/system/checkconf/bad-prefetch4.conf @@ -0,0 +1,16 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +view foo { + prefetch 9 13; +}; diff --git a/lib/isccfg/check.c b/lib/isccfg/check.c index fb1e1d92b9..f8c1697457 100644 --- a/lib/isccfg/check.c +++ b/lib/isccfg/check.c @@ -1999,6 +1999,37 @@ check_options(const cfg_obj_t *options, const cfg_obj_t *config, } } + obj = NULL; + (void)cfg_map_get(options, "prefetch", &obj); + if (obj != NULL) { + const cfg_obj_t *trigger = cfg_tuple_get(obj, "trigger"); + const cfg_obj_t *eligible = cfg_tuple_get(obj, "eligible"); + uint32_t tvalue = cfg_obj_asuint32(trigger); + + if (tvalue > 10) { + cfg_obj_log(obj, ISC_LOG_ERROR, + "prefetch '%u' out of range (0..10)", + tvalue); + if (result == ISC_R_SUCCESS) { + result = ISC_R_RANGE; + } + } + + if (!cfg_obj_isvoid(eligible)) { + uint32_t evalue = cfg_obj_asuint32(eligible); + if (evalue < tvalue + 6) { + cfg_obj_log(obj, ISC_LOG_ERROR, + "prefetch eligibility '%u' must be " + "at least six seconds longer than " + "the trigger value '%u'", + evalue, tvalue); + if (result == ISC_R_SUCCESS) { + result = ISC_R_RANGE; + } + } + } + } + if (aclctx != NULL) { cfg_aclconfctx_detach(&aclctx); } diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index 0145f2b484..e2d5796ed9 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -2237,9 +2237,6 @@ prefetch_merge(cfg_obj_t *effectiveobj, const cfg_obj_t *defaultobj) { trigger = (cfg_obj_t *)cfg_tuple_get(effectiveobj, "trigger"); INSIST(cfg_obj_isuint32(trigger)); - if (cfg_obj_asuint32(trigger) > 10) { - trigger->value.uint32 = 10; - } eligible = (cfg_obj_t *)cfg_tuple_get(effectiveobj, "eligible"); if (cfg_obj_isvoid(eligible)) { @@ -2253,9 +2250,6 @@ prefetch_merge(cfg_obj_t *effectiveobj, const cfg_obj_t *defaultobj) { } INSIST(cfg_obj_isuint32(eligible)); - if (cfg_obj_asuint32(eligible) < cfg_obj_asuint32(trigger) + 6) { - eligible->value.uint32 = cfg_obj_asuint32(trigger) + 6; - } } static void