Commit 31c76f59 authored by Daniel Salzman's avatar Daniel Salzman

conf: unify DB item names, add timer DB mapsize item

parent ca55e82b
......@@ -407,18 +407,6 @@ AS_CASE([$conf_mapsize],
[AC_ERROR([conf_mapsize must be an integer number])])])
AC_DEFINE_UNQUOTED([CONF_MAPSIZE], [$conf_mapsize], [Configuration DB mapsize.])
timer_mapsize_default=100
AC_ARG_WITH([timer_mapsize],
AC_HELP_STRING([--with-timer-mapsize=NUM], [Timer DB mapsize in MiB [default=$timer_mapsize_default]]),
[timer_mapsize=$withval],[timer_mapsize=$timer_mapsize_default])
AS_CASE([$timer_mapsize],
[yes],[timer_mapsize=$timer_mapsize_default],
[no], [AC_MSG_ERROR([timer_mapsize must be a number])],
[*], [AS_IF([test $timer_mapsize != $(( $timer_mapsize + 0 ))],
[AC_ERROR([timer_mapsize must be an integer number])])])
AC_DEFINE_UNQUOTED([TIMER_MAPSIZE], [$timer_mapsize], [Timer DB mapsize.])
# libedit
AS_IF([test "$enable_daemon" = "yes" -o "$enable_utilities" = "yes"], [
PKG_CHECK_MODULES([libedit], [libedit], [with_libedit=yes], [
......@@ -560,7 +548,6 @@ result_msg_base=" $PACKAGE $VERSION
Module dir: ${module_dir}
Configuration DB mapsize: ${conf_mapsize} MiB
Timers DB mapsize: ${timer_mapsize} MiB
Knot DNS libraries: yes
Knot DNS daemon: ${enable_daemon}
......
......@@ -691,9 +691,12 @@ if a zone doesn\(aqt have another template specified.
template:
\- id: STR
timer\-db: STR
max\-timer\-db\-size: SIZE
journal\-db: STR
journal\-db\-mode: robust | asynchronous
max\-journal\-db\-size: SIZE
kasp\-db: STR
max\-kasp\-db\-size: SIZE
global\-module: STR/STR ...
# All zone options (excluding \(aqtemplate\(aq item)
.ft P
......@@ -716,6 +719,18 @@ This option is only available in the \fIdefault\fP template.
.UNINDENT
.sp
\fIDefault:\fP \fI\%storage\fP/timers
.SS max\-timer\-db\-size
.sp
Hard limit for the timer database maximum size.
.sp
\fBNOTE:\fP
.INDENT 0.0
.INDENT 3.5
This option is only available in the \fIdefault\fP template.
.UNINDENT
.UNINDENT
.sp
\fIDefault:\fP 100 MiB
.SS journal\-db
.sp
Specifies a path of the persistent journal database. The path can be specified
......@@ -772,6 +787,31 @@ This option is only available in the \fIdefault\fP template.
.UNINDENT
.sp
\fIDefault:\fP 20 GiB (1 GiB for 32\-bit)
.SS kasp\-db
.sp
A KASP database path. Non\-absolute path is relative to
\fI\%storage\fP\&.
.sp
\fIDefault:\fP \fI\%storage\fP/keys
.sp
\fBNOTE:\fP
.INDENT 0.0
.INDENT 3.5
This option is only available in the \fIdefault\fP template.
.UNINDENT
.UNINDENT
.SS max\-kasp\-db\-size
.sp
Hard limit for the KASP database maximum size.
.sp
\fBNOTE:\fP
.INDENT 0.0
.INDENT 3.5
This option is only available in the \fIdefault\fP template.
.UNINDENT
.UNINDENT
.sp
\fIDefault:\fP 500 MiB
.SS global\-module
.sp
An ordered list of references to query modules in the form of \fImodule_name\fP or
......@@ -811,7 +851,6 @@ zone:
max\-zone\-size : SIZE
dnssec\-signing: BOOL
dnssec\-policy: STR
kasp\-db: STR
request\-edns\-option: INT:[HEXSTR]
serial\-policy: increment | unixtime
module: STR/STR ...
......@@ -1031,12 +1070,6 @@ A \fI\%reference\fP to DNSSEC signing policy. A special \fIdefault\fP
value can be used for the default policy settings.
.sp
\fIRequired\fP
.SS kasp\-db
.sp
A KASP database path. Non\-absolute path is relative to
\fI\%storage\fP\&.
.sp
\fIDefault:\fP \fI\%storage\fP/keys
.SS request\-edns\-option
.sp
An arbitrary EDNS0 option which is included into a server request (AXFR, IXFR,
......
......@@ -544,7 +544,7 @@ config
------
A backend specific configuration. A directory with PEM files (the path can
be specified as a relative path to :ref:`kasp-db<zone_kasp-db>`) or
be specified as a relative path to :ref:`kasp-db<template_kasp-db>`) or
a configuration string for PKCS #11 storage.
.. NOTE::
......@@ -552,7 +552,7 @@ a configuration string for PKCS #11 storage.
"pkcs11:token=knot;pin-value=1234 /usr/lib64/pkcs11/libsofthsm2.so"
*Default:* :ref:`kasp-db<zone_kasp-db>`/keys
*Default:* :ref:`kasp-db<template_kasp-db>`/keys
.. _Policy section:
......@@ -811,9 +811,12 @@ if a zone doesn't have another template specified.
template:
- id: STR
timer-db: STR
max-timer-db-size: SIZE
journal-db: STR
journal-db-mode: robust | asynchronous
max-journal-db-size: SIZE
kasp-db: STR
max-kasp-db-size: SIZE
global-module: STR/STR ...
# All zone options (excluding 'template' item)
......@@ -837,6 +840,18 @@ as a relative path to the *default* template :ref:`storage<zone_storage>`.
*Default:* :ref:`storage<zone_storage>`/timers
.. _template_max-timer-db-size:
max-timer-db-size
-----------------
Hard limit for the timer database maximum size.
.. NOTE::
This option is only available in the *default* template.
*Default:* 100 MiB
.. _template_journal-db:
journal-db
......@@ -890,6 +905,31 @@ large enough. This value also influences server's usage of virtual memory.
*Default:* 20 GiB (1 GiB for 32-bit)
.. _template_kasp-db:
kasp-db
-------
A KASP database path. Non-absolute path is relative to
:ref:`storage<zone_storage>`.
*Default:* :ref:`storage<zone_storage>`/keys
.. NOTE::
This option is only available in the *default* template.
.. _template_max-kasp-db-size:
max-kasp-db-size
----------------
Hard limit for the KASP database maximum size.
.. NOTE::
This option is only available in the *default* template.
*Default:* 500 MiB
.. _template_global-module:
global-module
......@@ -930,7 +970,6 @@ Definition of zones served by the server.
max-zone-size : SIZE
dnssec-signing: BOOL
dnssec-policy: STR
kasp-db: STR
request-edns-option: INT:[HEXSTR]
serial-policy: increment | unixtime
module: STR/STR ...
......@@ -1169,16 +1208,6 @@ value can be used for the default policy settings.
*Required*
.. _zone_kasp-db:
kasp-db
-------
A KASP database path. Non-absolute path is relative to
:ref:`storage<zone_storage>`.
*Default:* :ref:`storage<zone_storage>`/keys
.. _zone_request_edns_option:
request-edns-option
......
......@@ -260,9 +260,11 @@ static const yp_item_t desc_remote[] = {
static const yp_item_t desc_template[] = {
{ C_ID, YP_TSTR, YP_VNONE, CONF_IO_FREF },
ZONE_ITEMS(CONF_IO_FRLD_ZONES)
{ C_TIMER_DB, YP_TSTR, YP_VSTR = { "timers" }, CONF_IO_FRLD_ZONES },
{ C_GLOBAL_MODULE, YP_TDATA, YP_VDATA = { 0, NULL, mod_id_to_bin, mod_id_to_txt },
YP_FMULTI | CONF_IO_FRLD_MOD, { check_modref } },
{ C_TIMER_DB, YP_TSTR, YP_VSTR = { "timers" }, CONF_IO_FRLD_ZONES },
{ C_MAX_TIMER_DB_SIZE, YP_TINT, YP_VINT = { MEGA(1), VIRT_MEM_LIMIT(GIGA(100)),
MEGA(100), YP_SSIZE }, CONF_IO_FRLD_ZONES },
{ C_JOURNAL_DB, YP_TSTR, YP_VSTR = { "journal" }, CONF_IO_FRLD_SRV },
{ C_JOURNAL_DB_MODE, YP_TOPT, YP_VOPT = { journal_modes, JOURNAL_MODE_ROBUST },
CONF_IO_FRLD_SRV },
......@@ -270,8 +272,8 @@ static const yp_item_t desc_template[] = {
VIRT_MEM_LIMIT(GIGA(20)), YP_SSIZE },
CONF_IO_FRLD_SRV },
{ C_KASP_DB, YP_TSTR, YP_VSTR = { "keys" }, CONF_IO_FRLD_SRV },
{ C_KASP_DB_MAPSIZE, YP_TINT, YP_VINT = { MEGA(10), GIGA(2), MEGA(500), YP_SSIZE },
CONF_IO_FRLD_SRV },
{ C_MAX_KASP_DB_SIZE, YP_TINT, YP_VINT = { MEGA(5), VIRT_MEM_LIMIT(GIGA(100)),
MEGA(500), YP_SSIZE }, CONF_IO_FRLD_SRV },
{ NULL }
};
......
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -57,7 +57,6 @@
#define C_JOURNAL_DB "\x0A""journal-db"
#define C_JOURNAL_DB_MODE "\x0F""journal-db-mode"
#define C_KASP_DB "\x07""kasp-db"
#define C_KASP_DB_MAPSIZE "\x0F""kasp-db-mapsize"
#define C_KEY "\x03""key"
#define C_KEYSTORE "\x08""keystore"
#define C_KSK_SIZE "\x08""ksk-size"
......@@ -69,7 +68,9 @@
#define C_MAX_JOURNAL_DB_SIZE "\x13""max-journal-db-size"
#define C_MAX_JOURNAL_USAGE "\x11""max-journal-usage"
#define C_MAX_JOURNAL_DEPTH "\x11""max-journal-depth"
#define C_MAX_KASP_DB_SIZE "\x10""max-kasp-db-size"
#define C_MAX_TCP_CLIENTS "\x0F""max-tcp-clients"
#define C_MAX_TIMER_DB_SIZE "\x11""max-timer-db-size"
#define C_MAX_UDP_PAYLOAD "\x0F""max-udp-payload"
#define C_MAX_ZONE_SIZE "\x0D""max-zone-size"
#define C_MAX_IPV4_UDP_PAYLOAD "\x14""max-ipv4-udp-payload"
......@@ -100,13 +101,13 @@
#define C_SINGLE_TYPE_SIGNING "\x13""single-type-signing"
#define C_SRV "\x06""server"
#define C_STATS "\x0A""statistics"
#define C_TIMER "\x05""timer"
#define C_STORAGE "\x07""storage"
#define C_TARGET "\x06""target"
#define C_TCP_HSHAKE_TIMEOUT "\x15""tcp-handshake-timeout"
#define C_TCP_IDLE_TIMEOUT "\x10""tcp-idle-timeout"
#define C_TCP_REPLY_TIMEOUT "\x11""tcp-reply-timeout"
#define C_TCP_WORKERS "\x0B""tcp-workers"
#define C_TIMER "\x05""timer"
#define C_TIMEOUT "\x07""timeout"
#define C_TIMER_DB "\x08""timer-db"
#define C_TPL "\x08""template"
......
......@@ -410,13 +410,14 @@ int check_template(
return KNOT_EINVAL; \
}
CHECK_DFLT(C_TIMER_DB, "timer database");
CHECK_DFLT(C_GLOBAL_MODULE, "global module");
CHECK_DFLT(C_TIMER_DB, "timer database path");
CHECK_DFLT(C_MAX_TIMER_DB_SIZE, "timer database maximum size");
CHECK_DFLT(C_JOURNAL_DB, "journal database path");
CHECK_DFLT(C_JOURNAL_DB_MODE, "journal database mode");
CHECK_DFLT(C_MAX_JOURNAL_DB_SIZE, "journal database maximum size");
CHECK_DFLT(C_KASP_DB, "KASP database path");
CHECK_DFLT(C_KASP_DB_MAPSIZE, "KASP database mapsize");
CHECK_DFLT(C_MAX_KASP_DB_SIZE, "KASP database maximum size");
return KNOT_EOK;
}
......
......@@ -394,8 +394,8 @@ int server_init(server_t *server, int bg_workers)
}
char *kasp_dir = conf_kaspdir(conf());
conf_val_t kasp_db_mapsize = conf_default_get(conf(), C_KASP_DB_MAPSIZE);
ret = kasp_db_init(kaspdb(), kasp_dir, conf_int(&kasp_db_mapsize));
conf_val_t kasp_size = conf_default_get(conf(), C_MAX_KASP_DB_SIZE);
ret = kasp_db_init(kaspdb(), kasp_dir, conf_int(&kasp_size));
free(kasp_dir);
if (ret != KNOT_EOK) {
journal_db_close(&server->journal_db);
......@@ -753,8 +753,8 @@ static int reconfigure_journal_db(conf_t *conf, server_t *server)
static int reconfigure_kasp_db(conf_t *conf, server_t *server)
{
char *kasp_dir = conf_kaspdir(conf);
conf_val_t kasp_db_mapsize = conf_default_get(conf, C_KASP_DB_MAPSIZE);
int ret = kasp_db_reconfigure(kaspdb(), kasp_dir, conf_int(&kasp_db_mapsize));
conf_val_t kasp_size = conf_default_get(conf, C_MAX_KASP_DB_SIZE);
int ret = kasp_db_reconfigure(kaspdb(), kasp_dir, conf_int(&kasp_size));
switch (ret) {
case KNOT_EBUSY:
log_warning("kasp_db, ignored reconfiguration of KASP DB path (already open)");
......@@ -770,8 +770,8 @@ static int reconfigure_kasp_db(conf_t *conf, server_t *server)
default:
break;
}
free(kasp_dir);
return ret;
}
......@@ -822,8 +822,10 @@ static void reopen_timers_database(conf_t *conf, server_t *server)
val = conf_default_get(conf, C_TIMER_DB);
char *timer_db = conf_abs_path(&val, storage);
free(storage);
val = conf_default_get(conf, C_MAX_TIMER_DB_SIZE);
size_t mapsize = conf_int(&val);
int ret = zone_timers_open(timer_db, &server->timers_db);
int ret = zone_timers_open(timer_db, &server->timers_db, mapsize);
if (ret != KNOT_EOK) {
log_warning("cannot open persistent timers DB '%s' (%s)",
timer_db, knot_strerror(ret));
......
......@@ -151,26 +151,26 @@ static int txn_read_timers(knot_db_txn_t *txn, const knot_dname_t *zone,
return deserialize_timers(timers, val.data, val.len);
}
int zone_timers_open(const char *path, knot_db_t **timer_db)
int zone_timers_open(const char *path, knot_db_t **db, size_t mapsize)
{
if (path == NULL || timer_db == NULL) {
if (path == NULL || db == NULL) {
return KNOT_EINVAL;
}
struct knot_db_lmdb_opts opts = KNOT_DB_LMDB_OPTS_INITIALIZER;
opts.mapsize = (size_t)TIMER_MAPSIZE * 1024 * 1024;
opts.mapsize = mapsize;
opts.path = path;
return knot_db_lmdb_api()->init(timer_db, NULL, &opts);
return knot_db_lmdb_api()->init(db, NULL, &opts);
}
void zone_timers_close(knot_db_t *timer_db)
void zone_timers_close(knot_db_t *db)
{
if (timer_db == NULL) {
if (db == NULL) {
return;
}
knot_db_lmdb_api()->deinit(timer_db);
knot_db_lmdb_api()->deinit(db);
}
int zone_timers_read(knot_db_t *db, const knot_dname_t *zone,
......
......@@ -37,12 +37,13 @@ typedef struct zone_timers zone_timers_t;
/*!
* \brief Open zone timers database.
*
* \param[in] path Path to a directory with the database.
* \param[out] db Created database.
* \param[in] path Path to a directory with the database.
* \param[out] db Created database.
* \param[in] mapsize LMDB mapsize.
*
* \return KNOT_E*
*/
int zone_timers_open(const char *path, knot_db_t **db);
int zone_timers_open(const char *path, knot_db_t **db, size_t mapsize);
/*!
* \brief Closes zone timers database.
......
......@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
kdnssec_ctx_t kctx = { 0 };
conf_val_t mapsize = conf_default_get(conf(), C_KASP_DB_MAPSIZE);
conf_val_t mapsize = conf_default_get(conf(), C_MAX_KASP_DB_SIZE);
char *kasp_dir = conf_kaspdir(conf());
int ret = kasp_db_init(kaspdb(), kasp_dir, conf_int(&mapsize));
free(kasp_dir);
......
......@@ -128,6 +128,8 @@ class Server(object):
self.disable_notify = None
self.zonefile_sync = "1d"
self.journal_db_size = 20 * 1024 * 1024
self.timer_db_size = 1 * 1024 * 1024
self.kasp_db_size = 10 * 1024 * 1024
self.zone_size_limit = None
self.inquirer = None
......@@ -1108,9 +1110,11 @@ class Knot(Server):
s.begin("template")
s.id_item("id", "default")
s.item_str("storage", self.dir)
s.item_str("kasp-db", self.keydir)
s.item_str("zonefile-sync", self.zonefile_sync)
s.item_str("kasp-db", self.keydir)
s.item_str("max-kasp-db-size", self.kasp_db_size)
s.item_str("max-journal-db-size", self.journal_db_size)
s.item_str("max-timer-db-size", self.timer_db_size)
s.item_str("semantic-checks", "on")
if self.disable_any:
s.item_str("disable-any", "on")
......
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
// Create database
knot_db_t *db = NULL;
int ret = zone_timers_open(dbid, &db);
int ret = zone_timers_open(dbid, &db, 1024 * 1024);
ok(ret == KNOT_EOK && db != NULL, "zone_timers_open()");
// Lookup nonexistent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment