Commit b2aa4558 authored by Daniel Salzman's avatar Daniel Salzman

Merge branch 'dynamic_modules'

parents 4eec99df 0cfeb435
......@@ -53,8 +53,10 @@
/m4/ltversion.m4
/m4/lt~obsolete.m4
/src/dnssec/libdnssec.pc
/src/knotd.pc
/src/libknot.pc
/src/libknot/version.h
/src/knot/modules/static_modules.h
# dnstap
/src/contrib/dnstap/Makefile
......
......@@ -177,6 +177,8 @@ src/knot/conf/confio.c
src/knot/conf/confio.h
src/knot/conf/migration.c
src/knot/conf/migration.h
src/knot/conf/module.c
src/knot/conf/module.h
src/knot/conf/scheme.c
src/knot/conf/scheme.h
src/knot/conf/tools.c
......@@ -231,6 +233,7 @@ src/knot/events/log.c
src/knot/events/log.h
src/knot/events/replan.c
src/knot/events/replan.h
src/knot/include/module.h
src/knot/journal/journal.c
src/knot/journal/journal.h
src/knot/journal/old_journal.c
......@@ -238,28 +241,19 @@ src/knot/journal/old_journal.h
src/knot/journal/serialization.c
src/knot/journal/serialization.h
src/knot/modules/dnsproxy/dnsproxy.c
src/knot/modules/dnsproxy/dnsproxy.h
src/knot/modules/dnstap/dnstap.c
src/knot/modules/dnstap/dnstap.h
src/knot/modules/noudp/noudp.c
src/knot/modules/noudp/noudp.h
src/knot/modules/online_sign/nsec_next.c
src/knot/modules/online_sign/nsec_next.h
src/knot/modules/online_sign/online_sign.c
src/knot/modules/online_sign/online_sign.h
src/knot/modules/onlinesign/nsec_next.c
src/knot/modules/onlinesign/nsec_next.h
src/knot/modules/onlinesign/onlinesign.c
src/knot/modules/rosedb/rosedb.c
src/knot/modules/rosedb/rosedb.h
src/knot/modules/rosedb/rosedb_tool.c
src/knot/modules/rrl/functions.c
src/knot/modules/rrl/functions.h
src/knot/modules/rrl/rrl.c
src/knot/modules/rrl/rrl.h
src/knot/modules/stats/stats.c
src/knot/modules/stats/stats.h
src/knot/modules/synth_record/synth_record.c
src/knot/modules/synth_record/synth_record.h
src/knot/modules/synthrecord/synthrecord.c
src/knot/modules/whoami/whoami.c
src/knot/modules/whoami/whoami.h
src/knot/nameserver/axfr.c
src/knot/nameserver/axfr.h
src/knot/nameserver/chaos.c
......@@ -530,7 +524,7 @@ tests/libknot/test_tsig.c
tests/libknot/test_yparser.c
tests/libknot/test_ypscheme.c
tests/libknot/test_yptrafo.c
tests/modules/test_online_sign.c
tests/modules/test_onlinesign.c
tests/modules/test_rrl.c
tests/test_acl.c
tests/test_changeset.c
......
......@@ -59,7 +59,8 @@ LT_INIT
# Use pkg-config
PKG_PROG_PKG_CONFIG
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], [AC_SUBST([pkgconfigdir], ['${libdir}/pkgconfig'])])
AC_CONFIG_FILES([src/libknot.pc
AC_CONFIG_FILES([src/knotd.pc
src/libknot.pc
src/dnssec/libdnssec.pc
src/zscanner/libzscanner.pc
])
......@@ -196,6 +197,14 @@ AC_ARG_WITH([configdir],
[config_dir=$withval])
AC_SUBST(config_dir)
module_dir=
module_instdir="${libdir}/knot/modules-${KNOT_VERSION_MAJOR}.${KNOT_VERSION_MINOR}"
AC_ARG_WITH([moduledir],
AC_HELP_STRING([--with-moduledir=path], [Path to auto-loaded dynamic modules. [default not set]]),
[module_dir=$withval module_instdir=$module_dir])
AC_SUBST(module_instdir)
AC_SUBST(module_dir)
#########################################
# Dependencies needed for Knot DNS daemon
#########################################
......@@ -275,6 +284,31 @@ AS_IF([test "$with_urcu" != "no"], [
AC_SEARCH_LIBS([urcu_init], [urcu], [AC_MSG_ERROR([liburcu is too old (< 0.4.0), urcu_init symbol found])])
])
static_modules=""
shared_modules=""
AS_IF([test "$enable_daemon" = "yes"],[
static_modules_declars=""
static_modules_init=""
doc_modules=""
KNOT_MODULE([dnsproxy], "yes", "non-shareable")
KNOT_MODULE([dnstap], "no")
KNOT_MODULE([noudp], "yes")
KNOT_MODULE([onlinesign], "yes", "non-shareable")
KNOT_MODULE([rosedb], "no")
KNOT_MODULE([rrl], "yes")
KNOT_MODULE([stats], "yes")
KNOT_MODULE([synthrecord], "yes")
KNOT_MODULE([whoami], "yes")
AC_SUBST([STATIC_MODULES_DECLARS], [$(printf "$static_modules_declars")])
AM_SUBST_NOTMAKE([STATIC_MODULES_DECLARS])
AC_SUBST([STATIC_MODULES_INIT], [$(printf "$static_modules_init")])
AM_SUBST_NOTMAKE([STATIC_MODULES_INIT])
AC_SUBST([DOC_MODULES], [$(printf "$doc_modules")])
AM_SUBST_NOTMAKE([DOC_MODULES])
])
opt_dnstap=no
AS_IF([test "$enable_daemon" = "yes" -o "$enable_utilities" = "yes"],[
dnl Check for dnstap.
......@@ -385,17 +419,6 @@ AS_CASE([$timer_mapsize],
[AC_ERROR([timer_mapsize must be an integer number])])])
AC_DEFINE_UNQUOTED([TIMER_MAPSIZE], [$timer_mapsize], [Timer DB mapsize.])
AS_IF([test "$enable_daemon" = "yes"],[
dnl Check for rosedb module
AC_ARG_ENABLE([rosedb],
AS_HELP_STRING([--enable-rosedb], [Enable static RR query module.]),
[], [enable_rosedb=no])
]) # Knot DNS daemon dependencies
AS_IF([test "$enable_rosedb" = yes], [AC_DEFINE([HAVE_ROSEDB], [1], [Define to 1 to enable static RR query module.])])
AM_CONDITIONAL([HAVE_ROSEDB], [test "$enable_rosedb" = yes])
# libedit
AS_IF([test "$enable_daemon" = "yes" -o "$enable_utilities" = "yes"], [
PKG_CHECK_MODULES([libedit], [libedit], [with_libedit=yes], [
......@@ -534,6 +557,7 @@ result_msg_base=" $PACKAGE $VERSION
Run dir: ${run_dir}
Storage dir: ${storage_dir}
Config dir: ${config_dir}
Module dir: ${module_dir}
Configuration DB mapsize: ${conf_mapsize} MiB
Timers DB mapsize: ${timer_mapsize} MiB
......@@ -543,14 +567,17 @@ result_msg_base=" $PACKAGE $VERSION
Knot DNS utils: ${enable_utilities}
Knot DNS documentation: ${enable_documentation}
Use recvmmsg: ${enable_recvmmsg}
Use SO_REUSEPORT: ${enable_reuseport}
Fast zone parser: ${enable_fastparser}
Utilities with IDN: ${with_libidn}
Systemd integration: ${enable_systemd}
Dnstap support: ${opt_dnstap}
Code coverage: ${enable_code_coverage}
PKCS #11 support: ${enable_pkcs11}"
Static modules: ${static_modules}
Shared modules: ${shared_modules}
Use recvmmsg: ${enable_recvmmsg}
Use SO_REUSEPORT: ${enable_reuseport}
Fast zone parser: ${enable_fastparser}
Utilities with IDN: ${with_libidn}
Utilities with Dnstap: ${opt_dnstap}
Systemd integration: ${enable_systemd}
Code coverage: ${enable_code_coverage}
PKCS #11 support: ${enable_pkcs11}"
result_msg_esc=$(echo -n "$result_msg_base" | sed '$!s/$/\\n/' | tr -d '\n')
result_msg_add="
......@@ -563,6 +590,7 @@ AC_DEFINE_UNQUOTED([CONFIGURE_SUMMARY],["$result_msg_esc"],[Configure summary])
AC_CONFIG_FILES([Makefile
doc/Makefile
doc/modules.rst
libtap/Makefile
tests/Makefile
tests-fuzz/Makefile
......@@ -572,6 +600,7 @@ AC_CONFIG_FILES([Makefile
src/contrib/dnstap/Makefile
src/dnssec/Makefile
src/dnssec/tests/Makefile
src/knot/modules/static_modules.h
src/zscanner/Makefile
])
......
/_build
/modules.rst
# sphinx-build manpages
/man/knot.conf.5
......
......@@ -457,6 +457,40 @@ of the limitations will be hopefully removed in the near future.
- Legacy key export is not implemented.
- DS record export is not implemented.
.. _query-modules:
Query modules
=============
Knot DNS supports configurable query modules that can alter the way
queries are processed. Each query requires a finite number of steps to
be resolved. We call this set of steps a *query plan*, an abstraction
that groups these steps into several stages.
* Before-query processing
* Answer, Authority, Additional records packet sections processing
* After-query processing
For example, processing an Internet-class query needs to find an
answer. Then based on the previous state, it may also append an
authority SOA or provide additional records. Each of these actions
represents a 'processing step'. Now, if a query module is loaded for a
zone, it is provided with an implicit query plan which can be extended
by the module or even changed altogether.
A module is active if its name, which includes the ``mod-`` prefix, is assigned
to the zone/template :ref:`zone_module` option or to the *default* template
:ref:`template_global-module` option if activating for all queries.
If the module is configurable, a corresponding module section with
an identifier must be created and then referenced in the form of
``module_name/module_id``. See :ref:`Modules` for the list of available modules.
.. NOTE::
Query modules are processed in the order they are specified in the
zone/template configuration. In most cases, the recommended order is::
mod-synthrecord, mod-onlinesign, mod-rrl, mod-dnstap, mod-stats
Performance Tuning
==================
......
......@@ -10,10 +10,10 @@ Welcome to Knot DNS's documentation!
requirements
installation
configuration
modules
operation
troubleshooting
reference
modules
utilities
migration
appendices
This diff is collapsed.
This diff is collapsed.
.. highlight:: none
.. _Modules:
*******
Modules
*******
@DOC_MODULES@
This diff is collapsed.
......@@ -7,9 +7,12 @@ AC_DEFUN([dt_DNSTAP],
[
AC_ARG_ENABLE([dnstap],
AS_HELP_STRING([--enable-dnstap],
[Enable dnstap support (requires fstrm, protobuf-c)]),
[Enable dnstap support for kdig (requires fstrm, protobuf-c)]),
[opt_dnstap=$enableval], [opt_dnstap=no])
AS_IF([test "$STATIC_MODULE_dnstap" != "no" -o "$SHARED_MODULE_dnstap" != "no"],
[opt_dnstap=yes])
AS_IF([test "$opt_dnstap" != "no"],[
AC_PATH_PROG([PROTOC_C], [protoc-c])
AS_IF([test -z "$PROTOC_C"],[
......
# KNOT_MODULE([module-name], [default], [non-shareable])
# ------------------------------------------------------
# Set Knot DNS module building
AC_DEFUN([KNOT_MODULE],
[
AC_ARG_WITH([module-$1],
AS_HELP_STRING([--with-module-$1=yes|shared|no], [Build '$1' module [default=$2]]),
[module=$withval],
[module=$2]
)
STATIC_MODULE_$1=no
SHARED_MODULE_$1=no
AS_CASE([$module],
[yes], [STATIC_MODULE_$1=yes
static_modules="${static_modules}$1 "
static_modules_declars="${static_modules_declars}extern const knotd_mod_api_t knotd_mod_api_$1;\n"
static_modules_init="${static_modules_init}\\\\\n\t{ &knotd_mod_api_$1 },"
doc_modules="${doc_modules}.. include:: ../src/knot/modules/$1/$1.rst\n"],
[shared], [SHARED_MODULE_$1=yes
shared_modules="${shared_modules}$1 "
doc_modules="${doc_modules}.. include:: ../src/knot/modules/$1/$1.rst\n"
AS_IF([test "$3" = "non-shareable"],
[AC_MSG_ERROR([Module $1 cannot be shared])])],
[no], [],
[*], [AC_MSG_ERROR([Invalid value '$module' for --with-module-$1])]
)
AM_CONDITIONAL([STATIC_MODULE_$1], [test "$STATIC_MODULE_$1" = "yes"])
AM_CONDITIONAL([SHARED_MODULE_$1], [test "$SHARED_MODULE_$1" = "yes"])
])
......@@ -9,14 +9,15 @@ check-compile:
lib_LTLIBRARIES = \
libknot.la
noinst_LTLIBRARIES = \
libcontrib.la \
libknot-yparser.la
libcontrib.la
AM_CPPFLAGS = \
-include $(top_builddir)/src/config.h \
-DCONFIG_DIR='"${config_dir}"' \
-DSTORAGE_DIR='"${storage_dir}"' \
-DRUN_DIR='"${run_dir}"' \
-DMODULE_DIR='"${module_dir}"' \
-DMODULE_INSTDIR='"${module_instdir}"' \
-I$(srcdir)/dnssec/lib
######################
......@@ -94,17 +95,8 @@ libcontrib_la_SOURCES += \
contrib/lmdb/midl.h
endif !HAVE_LMDB
# static: libknot-yparser sources
libknot_yparser_la_SOURCES = \
libknot/yparser/yparser.c \
libknot/yparser/yparser.h \
libknot/yparser/ypbody.c \
libknot/yparser/ypformat.c \
libknot/yparser/ypformat.h \
libknot/yparser/ypscheme.c \
libknot/yparser/ypscheme.h \
libknot/yparser/yptrafo.c \
libknot/yparser/yptrafo.h
libcontrib_la_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY)
libcontrib_la_LDFLAGS = $(AM_LDFLAGS) $(LDFLAG_EXCLUDE_LIBS)
# libknot headers
libknot_ladir = $(includedir)
......@@ -151,6 +143,10 @@ nobase_libknot_la_HEADERS = \
libknot/rrtype/txt.h \
libknot/tsig-op.h \
libknot/tsig.h \
libknot/yparser/yparser.h \
libknot/yparser/ypformat.h \
libknot/yparser/ypscheme.h \
libknot/yparser/yptrafo.h \
libknot/version.h
# dynamic: libknot sources
......@@ -187,15 +183,19 @@ libknot_la_SOURCES = \
libknot/rrtype/tsig.c \
libknot/tsig-op.c \
libknot/tsig.c \
libknot/yparser/yparser.c \
libknot/yparser/ypbody.c \
libknot/yparser/ypformat.c \
libknot/yparser/ypscheme.c \
libknot/yparser/yptrafo.c \
$(nobase_libknot_la_HEADERS)
libknot_la_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY) $(lmdb_CFLAGS)
libknot_la_CFLAGS = $(AM_CFLAGS)
libknot_la_LDFLAGS = $(AM_LDFLAGS) $(libknot_VERSION_INFO) $(lmdb_LIBS) $(LDFLAG_EXCLUDE_LIBS)
libknot_la_LIBADD = dnssec/libdnssec.la libcontrib.la
# pkg-config
pkgconfig_DATA = libknot.pc
pkgconfig_DATA = knotd.pc libknot.pc
# static: utilities shared
libknotus_la_SOURCES = \
......@@ -222,8 +222,8 @@ libknotus_la_SOURCES = \
utils/common/token.c \
utils/common/token.h
libknotus_la_CPPFLAGS = $(AM_CPPFLAGS) $(libidn_CFLAGS) $(libedit_CFLAGS) $(gnutls_CFLAGS)
libknotus_la_LDFLAGS = $(AM_LDFLAGS) $(libidn_LIBS)
libknotus_la_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY) $(libidn_CFLAGS) $(libedit_CFLAGS) $(gnutls_CFLAGS)
libknotus_la_LDFLAGS = $(AM_LDFLAGS) $(libidn_LIBS) $(LDFLAG_EXCLUDE_LIBS)
libknotus_la_LIBADD = libcontrib.la libknot.la
libknotd_la_SOURCES = \
......@@ -237,6 +237,8 @@ libknotd_la_SOURCES = \
knot/conf/confio.h \
knot/conf/migration.c \
knot/conf/migration.h \
knot/conf/module.h \
knot/conf/module.c \
knot/conf/scheme.c \
knot/conf/scheme.h \
knot/conf/tools.c \
......@@ -291,24 +293,6 @@ libknotd_la_SOURCES = \
knot/events/log.h \
knot/events/replan.c \
knot/events/replan.h \
knot/modules/dnsproxy/dnsproxy.c \
knot/modules/dnsproxy/dnsproxy.h \
knot/modules/noudp/noudp.c \
knot/modules/noudp/noudp.h \
knot/modules/online_sign/online_sign.c \
knot/modules/online_sign/online_sign.h \
knot/modules/online_sign/nsec_next.c \
knot/modules/online_sign/nsec_next.h \
knot/modules/rrl/functions.c \
knot/modules/rrl/functions.h \
knot/modules/rrl/rrl.c \
knot/modules/rrl/rrl.h \
knot/modules/stats/stats.c \
knot/modules/stats/stats.h \
knot/modules/synth_record/synth_record.c\
knot/modules/synth_record/synth_record.h\
knot/modules/whoami/whoami.c \
knot/modules/whoami/whoami.h \
knot/nameserver/axfr.c \
knot/nameserver/axfr.h \
knot/nameserver/chaos.c \
......@@ -407,9 +391,9 @@ libknotd_la_SOURCES = \
knot/zone/zonefile.c \
knot/zone/zonefile.h
libknotd_la_CPPFLAGS = $(AM_CPPFLAGS) $(systemd_CFLAGS) $(liburcu_CFLAGS) $(lmdb_CFLAGS)
libknotd_la_LDFLAGS = $(AM_LDFLAGS) $(systemd_LIBS) $(liburcu_LIBS)
libknotd_la_LIBADD = libknot.la libknot-yparser.la zscanner/libzscanner.la $(liburcu_LIBS)
libknotd_la_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY) $(systemd_CFLAGS) $(liburcu_CFLAGS) $(lmdb_CFLAGS) -DKNOTD_MOD_STATIC
libknotd_la_LDFLAGS = $(AM_LDFLAGS) $(systemd_LIBS) $(liburcu_LIBS) -export-symbols-regex '^knotd_'
libknotd_la_LIBADD = libknot.la zscanner/libzscanner.la $(liburcu_LIBS)
###################
# Knot DNS Daemon #
......@@ -420,6 +404,10 @@ if HAVE_DAEMON
sbin_PROGRAMS = knotc knotd keymgr
noinst_LTLIBRARIES += libknotd.la libknotus.la
knotddir = $(includedir)/knot
knotd_HEADERS = \
knot/include/module.h
knotc_SOURCES = \
utils/knotc/commands.c \
utils/knotc/commands.h \
......@@ -441,10 +429,12 @@ keymgr_SOURCES = \
utils/keymgr/functions.h \
utils/keymgr/main.c
knotd_CPPFLAGS = $(AM_CPPFLAGS) $(liburcu_CFLAGS)
knotd_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY) $(liburcu_CFLAGS)
knotd_LDADD = libknotd.la libcontrib.la $(liburcu_LIBS)
knotc_CPPFLAGS = $(AM_CPPFLAGS) $(libedit_CFLAGS)
knotc_LDADD = libknotd.la libknotus.la $(libedit_LIBS)
knotd_LDFLAGS = $(AM_LDFLAGS) -rdynamic
knotc_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY) $(libedit_CFLAGS)
knotc_LDADD = libknotd.la libcontrib.la libknotus.la $(libedit_LIBS)
knotc_LDFLAGS = $(AM_LDFLAGS) -rdynamic
keymgr_CPPFLAGS = $(AM_CPPFLAGS) $(liburcu_CFLAGS) -I$(srcdir)/dnssec/lib/dnssec \
-I$(srcdir)/dnssec $(gnutls_CFLAGS)
keymgr_LDADD = $(libidn_LIBS) $(liburcu_LIBS) libknotd.la libcontrib.la \
......@@ -455,20 +445,6 @@ keymgr_LDADD = $(libidn_LIBS) $(liburcu_LIBS) libknotd.la libcontrib.la \
# Optional Knot DNS Daemon modules #
####################################
if HAVE_DNSTAP
libknotd_la_SOURCES += \
knot/modules/dnstap/dnstap.c \
knot/modules/dnstap/dnstap.h
libknotd_la_CPPFLAGS += $(DNSTAP_CFLAGS)
libknotd_la_LIBADD += $(DNSTAP_LIBS) contrib/dnstap/libdnstap.la
endif # HAVE_DNSTAP
if HAVE_ROSEDB
libknotd_la_SOURCES += \
knot/modules/rosedb/rosedb.c \
knot/modules/rosedb/rosedb.h
endif # HAVE_ROSEDB
# Create storage and run-time directories
install-data-hook:
$(INSTALL) -d $(DESTDIR)/@config_dir@
......@@ -546,12 +522,20 @@ kdig_CPPFLAGS += $(DNSTAP_CFLAGS)
khost_CPPFLAGS += $(DNSTAP_CFLAGS)
endif # HAVE_DNSTAP
if HAVE_ROSEDB
bin_PROGRAMS += rosedb_tool
rosedb_tool_SOURCES = knot/modules/rosedb/rosedb_tool.c
rosedb_tool_LDADD = libknotd.la libcontrib.la
rosedb_tool_CFLAGS = $(AM_CFLAGS) $(lmdb_CFLAGS) $(DNSTAP_CFLAGS)
rosedb_tool_LDFLAGS = $(AM_LDFLAGS) $(lmdb_LIBS)
endif # HAVE_ROSEDB
endif # HAVE_UTILS
KNOTD_MOD_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY)
KNOTD_MOD_LDFLAGS = $(AM_LDFLAGS) -module -shared -avoid-version
pkglibdir = $(module_instdir)
pkglib_LTLIBRARIES =
include $(srcdir)/knot/modules/dnsproxy/Makefile.inc
include $(srcdir)/knot/modules/dnstap/Makefile.inc
include $(srcdir)/knot/modules/noudp/Makefile.inc
include $(srcdir)/knot/modules/onlinesign/Makefile.inc
include $(srcdir)/knot/modules/rosedb/Makefile.inc
include $(srcdir)/knot/modules/rrl/Makefile.inc
include $(srcdir)/knot/modules/stats/Makefile.inc
include $(srcdir)/knot/modules/synthrecord/Makefile.inc
include $(srcdir)/knot/modules/whoami/Makefile.inc
......@@ -19,11 +19,16 @@ SUFFIXES = .proto .pb-c.c .pb-c.h
noinst_LTLIBRARIES = libdnstap.la
libdnstap_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(CFLAG_VISIBILITY)
libdnstap_la_CFLAGS = \
$(DNSTAP_CFLAGS)
libdnstap_la_LDFLAGS = \
$(DNSTAP_LIBS)
$(DNSTAP_LIBS) \
$(LDFLAG_EXCLUDE_LIBS)
libdnstap_la_SOURCES = \
convert.c \
......
......@@ -79,7 +79,7 @@ static void dump_counters(FILE *fd, int level, mod_ctr_t *ctr)
static void dump_modules(dump_ctx_t *ctx)
{
int level = 0;
struct query_module *mod = NULL;
knotd_mod_t *mod = NULL;
WALK_LIST(mod, *ctx->query_modules) {
// Skip modules without statistics.
if (mod->stats_count == 0) {
......
This diff is collapsed.
......@@ -29,6 +29,8 @@
#include "libknot/yparser/ypscheme.h"
#include "contrib/qp-trie/trie.h"
#include "contrib/ucw/lists.h"
#include "contrib/dynarray.h"
#include "knot/include/module.h"
/*! Default template identifier. */
#define CONF_DEFAULT_ID ((uint8_t *)"\x08""default\0")
......@@ -67,6 +69,19 @@ typedef struct {
int code;
} conf_val_t;
/*! Query module context. */
typedef struct {
/*! Module interface. */
const knotd_mod_api_t *api;
/*! Shared library dlopen handler. */
void *lib_handle;
/*! Indication of a temporary module created during confio check. */
bool temporary;
} module_t;
dynarray_declare(mod, module_t *, DYNARRAY_VISIBILITY_PUBLIC, 16)
dynarray_declare(old_schema, yp_item_t *, DYNARRAY_VISIBILITY_PUBLIC, 16)
/*! Configuration context. */
typedef struct {
/*! Cloned configuration indicator. */
......@@ -112,6 +127,10 @@ typedef struct {
conf_val_t srv_nsid;
} cache;
/*! List of dynamically loaded modules. */
mod_dynarray_t modules;
/*! List of old schemas (lazy freed). */
old_schema_dynarray_t old_schemas;
/*! List of active query modules. */
list_t query_modules;
/*! Default query modules plan. */
......@@ -122,10 +141,12 @@ typedef struct {
* Configuration access flags.
*/
typedef enum {
CONF_FNONE = 0, /*!< Empty flag. */
CONF_FREADONLY = 1 << 0, /*!< Read only access. */
CONF_FNOCHECK = 1 << 1, /*!< Disabled confdb check. */
CONF_FNOHOSTNAME = 1 << 2, /*!< Don't set the hostname. */
CONF_FNONE = 0, /*!< Empty flag. */
CONF_FREADONLY = 1 << 0, /*!< Read only access. */
CONF_FNOCHECK = 1 << 1, /*!< Disabled confdb check. */
CONF_FNOHOSTNAME = 1 << 2, /*!< Don't set the hostname. */
CONF_FREQMODULES = 1 << 3, /*!< Load module schemas (must succeed). */
CONF_FOPTMODULES = 1 << 4, /*!< Load module schemas (may fail). */
} conf_flag_t;
/*!
......@@ -133,8 +154,9 @@ typedef enum {
*/
typedef enum {
CONF_UPD_FNONE = 0, /*!< Empty flag. */
CONF_UPD_FMODULES = 1 << 0, /*!< Reuse previous global modules. */
CONF_UPD_FCONFIO = 1 << 1, /*!< Reuse previous cofio reload context. */
CONF_UPD_FNOFREE = 1 << 0, /*!< Disable auto-free of previous config. */
CONF_UPD_FMODULES = 1 << 1, /*!< Reuse previous global modules. */
CONF_UPD_FCONFIO = 1 << 2, /*!< Reuse previous cofio reload context. */
} conf_update_flag_t;
/*!
......@@ -197,8 +219,10 @@ int conf_clone(
*
* \param[in] conf New configuration.
* \param[in] flags Update flags.
*
* \return Previous config if CONF_UPD_FNOFREE, else NULL.
*/
void conf_update(
conf_t *conf_update(
conf_t *conf,
conf_update_flag_t flags
);
......@@ -212,32 +236,6 @@ void conf_free(
conf_t *conf
);
/*!
* Activates configured query modules for the specified zone or for all zones.
*
* \param[in] conf Configuration.
* \param[in] zone_name Zone name, NULL for all zones.
* \param[in] query_modules Destination query modules list.
* \param[in] query_plan Destination query plan.
*/
void conf_activate_modules(
conf_t *conf,
const knot_dname_t *zone_name,
list_t *query_modules,
struct query_plan **query_plan
);
/*!
* Deactivates query modules list.
*
* \param[in] query_modules Destination query modules list.
* \param[in] query_plan Destination query plan.
*/
void conf_deactivate_modules(
list_t *query_modules,
struct query_plan **query_plan
);
/*!
* Parses textual configuration from the string or from the file.
*
......
/* 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
......@@ -16,8 +16,10 @@
#include <assert.h>
#include "knot/common/log.h"
#include "knot/conf/confdb.h"
#include "knot/conf/confio.h"
#include "knot/conf/module.h"
#include "knot/conf/tools.h"
#define FCN(io) (io->fcn != NULL) ? io->fcn(io) : KNOT_EOK;
......@@ -167,7 +169,7 @@ int conf_io_list(
return list_section(conf()->scheme, &io->key0, io);
}
yp_check_ctx_t *ctx = yp_scheme_check_init(conf()->scheme);
yp_check_ctx_t *ctx = yp_scheme_check_init(&conf()->scheme);
if (ctx == NULL) {
return KNOT_ENOMEM;
}
......@@ -497,7 +499,7 @@ int conf_io_diff(
return KNOT_EOK;
}
yp_check_ctx_t *ctx = yp_scheme_check_init(conf()->scheme);
yp_check_ctx_t *ctx = yp_scheme_check_init(&conf()->scheme);
if (ctx == NULL) {
return KNOT_ENOMEM;
}
......@@ -696,7 +698,7 @@ int conf_io_get(
return KNOT_EOK;
}
yp_check_ctx_t *ctx = yp_scheme_check_init(conf()->scheme);
yp_check_ctx_t *ctx = yp_scheme_check_init(&conf()->scheme);
if (ctx == NULL) {
return KNOT_ENOMEM;
}
......@@ -878,20 +880,32 @@ static int set_item(
}
// Postpone group callbacks to config check.
if (io->key0->type == YP_TGRP) {
if (io->key0->type == YP_TGRP && io->id_len == 0) {
return KNOT_EOK;
}
conf_check_t args = {
knotd_conf_check_extra_t extra = {
.conf = conf(),
.txn = conf()->io.txn,
.item = (io->key1 != NULL) ? io->key1 : io->key0,
.txn = conf()->io.txn
};
knotd_conf_check_args_t args = {
.item = (io->key1 != NULL) ? io->key1 :
((io->id_len == 0) ? io->key0 : io->key0->var.g.id),
.id = io->id,
.id_len = io->id_len,
.data = io->data.bin,
.data_len = io->data.bin_len
.data_len = io->data.bin_len,
.extra = &extra
};
// Call the item callbacks (include).
return conf_exec_callbacks(&args);
// Call the item callbacks (include, item check, mod-id check).
ret = conf_exec_callbacks(&args);
if (ret != KNOT_EOK) {
CONF_LOG(LOG_DEBUG, "item '%s' (%s)", args.item->name + 1,
args.err_str != NULL ? args.err_str : knot_strerror(ret));
}
return ret;