2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-22 01:49:48 +00:00

[#1671] addressed review comments

This commit is contained in:
Razvan Becheriu 2023-03-20 19:00:21 +02:00 committed by Andrei Pavel
parent 35238f03aa
commit b47394ff5e
12 changed files with 176 additions and 169 deletions

View File

@ -179,7 +179,7 @@ password these values can be read from files. The syntax was extended by:
- The ``directory`` authentication parameter which handles the common
part of file paths. By default the value is the empty string.
- The``password-file`` client parameter which with the ``directory``
- The ``password-file`` client parameter which with the ``directory``
parameter specifies the path of a file where the password or when no
user ID is given the whole basic HTTP authentication secret before
encoding can be read.
@ -388,25 +388,22 @@ Starting and Stopping the Control Agent
is a copy of the ``config.report`` file produced by ``./configure``;
it is embedded in the executable binary.
The ``config.report`` file may also be accessed directly, via the
following command. The binary ``path`` may be found in the install
directory or in the ``.libs`` subdirectory in the source tree. For
example: ``kea/src/lib/process/.libs/``.
The contents of the ``config.report`` file may also be accessed by examining
certain libraries in the installation tree or in the source tree.
::
.. code-block:: shell
strings path/libkea-process.so | sed -n 's/;;;; //p'
# from installation using libkea-process.so
$ strings ${prefix}/lib/libkea-process.so | sed -n 's/;;;; //p'
::
# from sources using libkea-process.so
$ strings src/lib/process/.libs/libkea-process.so | sed -n 's/;;;; //p'
strings path/libkea-process.a | sed -n 's/;;;; //p'
# from sources using libkea-process.a
$ strings src/lib/process/.libs/libkea-process.a | sed -n 's/;;;; //p'
The libcfgrpt.a library can also be used from the source tree with path:
``src/lib/process/cfgrpt/.libs/``.
::
strings path/libcfgrpt.a | sed -n 's/;;;; //p'
# from sources using libcfgrpt.a
$ strings src/lib/process/cfgrpt/.libs/libcfgrpt.a | sed -n 's/;;;; //p'
The CA is started by running its binary and specifying the configuration
file it should use. For example:

View File

@ -138,25 +138,22 @@ directly. It accepts the following command-line switches:
messages to standard output and errors to standard error when testing
the configuration.
The ``config.report`` file may also be accessed directly, via the
following command. The binary ``path`` may be found in the install
directory or in the ``.libs`` subdirectory in the source tree. For
example: ``kea/src/lib/process/.libs/``.
The contents of the ``config.report`` file may also be accessed by examining
certain libraries in the installation tree or in the source tree.
::
.. code-block:: shell
strings path/libkea-process.so | sed -n 's/;;;; //p'
# from installation using libkea-process.so
$ strings ${prefix}/lib/libkea-process.so | sed -n 's/;;;; //p'
::
# from sources using libkea-process.so
$ strings src/lib/process/.libs/libkea-process.so | sed -n 's/;;;; //p'
strings path/libkea-process.a | sed -n 's/;;;; //p'
# from sources using libkea-process.a
$ strings src/lib/process/.libs/libkea-process.a | sed -n 's/;;;; //p'
The libcfgrpt.a library can also be used from the source tree with path:
``src/lib/process/cfgrpt/.libs/``.
::
strings path/libcfgrpt.a | sed -n 's/;;;; //p'
# from sources using libcfgrpt.a
$ strings src/lib/process/cfgrpt/.libs/libcfgrpt.a | sed -n 's/;;;; //p'
Upon startup, the module loads its configuration and begins listening
for NCRs based on that configuration.

View File

@ -43,9 +43,10 @@ the following command-line switches:
server.
- ``-T file`` - specifies a configuration file to be tested. ``kea-dhcp4``
loads it, checks it, and exits. It performs extra checks beside ``-t`` is
doing, like establising database connections (lease db, host db, CB db,
forensic logging db), hook libraries loading and configuration parsing, etc.
loads it, checks it, and exits. It performs extra checks beside what ``-t``
is doing, like establising database connections (lease backend,
host reservations backend, configuration backend and forensic logging
backend), hook libraries loading and configuration parsing, etc.
It does not open unix or TCP/UDP sockets, neither does it open or rotate
files, as all these actions could interfere with a running process on the
same machine.
@ -60,25 +61,22 @@ the following command-line switches:
is a copy of the ``config.report`` file produced by ``./configure``;
it is embedded in the executable binary.
The ``config.report`` file may also be accessed directly, via the
following command. The binary ``path`` may be found in the install
directory or in the ``.libs`` subdirectory in the source tree. For
example: ``kea/src/lib/process/.libs/``.
The contents of the ``config.report`` file may also be accessed by examining
certain libraries in the installation tree or in the source tree.
::
.. code-block:: shell
strings path/libkea-process.so | sed -n 's/;;;; //p'
# from installation using libkea-process.so
$ strings ${prefix}/lib/libkea-process.so | sed -n 's/;;;; //p'
::
# from sources using libkea-process.so
$ strings src/lib/process/.libs/libkea-process.so | sed -n 's/;;;; //p'
strings path/libkea-process.a | sed -n 's/;;;; //p'
# from sources using libkea-process.a
$ strings src/lib/process/.libs/libkea-process.a | sed -n 's/;;;; //p'
The libcfgrpt.a library can also be used from the source tree with path:
``src/lib/process/cfgrpt/.libs/``.
::
strings path/libcfgrpt.a | sed -n 's/;;;; //p'
# from sources using libcfgrpt.a
$ strings src/lib/process/cfgrpt/.libs/libcfgrpt.a | sed -n 's/;;;; //p'
On startup, the server detects available network interfaces and
attempts to open UDP sockets on all interfaces listed in the

View File

@ -42,10 +42,11 @@ the following command-line switches:
comprehensive; certain checks are possible only when running the
server.
- ``-T file`` - specifies a configuration file to be tested. ``kea-dhcp4``
loads it, checks it, and exits. It performs extra checks beside ``-t`` is
doing, like establising database connections (lease db, host db, CB db,
forensic logging db), hook libraries loading and configuration parsing, etc.
- ``-T file`` - specifies a configuration file to be tested. ``kea-dhcp6``
loads it, checks it, and exits. It performs extra checks beside what ``-t``
is doing, like establising database connections (lease backend,
host reservations backend, configuration backend and forensic logging
backend), hook libraries loading and configuration parsing, etc.
It does not open unix or TCP/UDP sockets, neither does it open or rotate
files, as all these actions could interfere with a running process on the
same machine.
@ -60,25 +61,22 @@ the following command-line switches:
is a copy of the ``config.report`` file produced by ``./configure``;
it is embedded in the executable binary.
The ``config.report`` file may also be accessed directly, via the
following command. The binary ``path`` may be found in the install
directory or in the ``.libs`` subdirectory in the source tree. For
example: ``kea/src/lib/process/.libs/``.
The contents of the ``config.report`` file may also be accessed by examining
certain libraries in the installation tree or in the source tree.
::
.. code-block:: shell
strings path/libkea-process.so | sed -n 's/;;;; //p'
# from installation using libkea-process.so
$ strings ${prefix}/lib/libkea-process.so | sed -n 's/;;;; //p'
::
# from sources using libkea-process.so
$ strings src/lib/process/.libs/libkea-process.so | sed -n 's/;;;; //p'
strings path/libkea-process.a | sed -n 's/;;;; //p'
# from sources using libkea-process.a
$ strings src/lib/process/.libs/libkea-process.a | sed -n 's/;;;; //p'
The libcfgrpt.a library can also be used from the source tree with path:
``src/lib/process/cfgrpt/.libs/``.
::
strings path/libcfgrpt.a | sed -n 's/;;;; //p'
# from sources using libcfgrpt.a
$ strings src/lib/process/cfgrpt/.libs/libcfgrpt.a | sed -n 's/;;;; //p'
On startup, the server detects available network interfaces and
attempts to open UDP sockets on all interfaces listed in the
@ -1100,8 +1098,8 @@ gives the range of addresses in the pool.
It is possible to define more than one pool in a subnet; continuing the
previous example, further assume that 2001:db8:1:0:5::/80 should also be
managed by the server. It could be written as 2001:db8:1:0:5:: to
2001:db8:1::5:ffff:ffff:ffff, but typing so many ``f``s is cumbersome. It
can be expressed more simply as 2001:db8:1:0:5::/80. Both formats are
2001:db8:1::5:ffff:ffff:ffff, but typing so many ``f`` characters is cumbersome.
It can be expressed more simply as 2001:db8:1:0:5::/80. Both formats are
supported by ``Dhcp6`` and can be mixed in the pool list. For example,
the following pools could be defined:

View File

@ -686,25 +686,22 @@ Starting and Stopping the NETCONF Agent
is a copy of the ``config.report`` file produced by ``./configure``;
it is embedded in the executable binary.
The ``config.report`` file may also be accessed directly, via the
following command. The binary ``path`` may be found in the install
directory or in the ``.libs`` subdirectory in the source tree. For
example: ``kea/src/lib/process/.libs/``.
The contents of the ``config.report`` file may also be accessed by examining
certain libraries in the installation tree or in the source tree.
::
.. code-block:: shell
strings path/libkea-process.so | sed -n 's/;;;; //p'
# from installation using libkea-process.so
$ strings ${prefix}/lib/libkea-process.so | sed -n 's/;;;; //p'
::
# from sources using libkea-process.so
$ strings src/lib/process/.libs/libkea-process.so | sed -n 's/;;;; //p'
strings path/libkea-process.a | sed -n 's/;;;; //p'
# from sources using libkea-process.a
$ strings src/lib/process/.libs/libkea-process.a | sed -n 's/;;;; //p'
The libcfgrpt.a library can also be used from the source tree with path:
``src/lib/process/cfgrpt/.libs/``.
::
strings path/libcfgrpt.a | sed -n 's/;;;; //p'
# from sources using libcfgrpt.a
$ strings src/lib/process/cfgrpt/.libs/libcfgrpt.a | sed -n 's/;;;; //p'
.. _operation-example:

View File

@ -783,7 +783,7 @@ The ``lease4-del``, ``lease6-del`` Commands
``lease4-del`` and ``lease6-del`` can be used to delete a lease from the lease database.
There are two types of parameters these commands support, similar to the
``lease4-get``and ``lease6-get`` commands: (``address``) for both v4 and v6, (``subnet-id``,
``lease4-get`` and ``lease6-get`` commands: (``address``) for both v4 and v6, (``subnet-id``,
``identifier-type``, ``identifier``) for v4, and (``subnet-id``, ``identifier-type``,
``identifier``, ``type``, ``IAID``) for v6. The first type of query is used when the
address (either IPv4 or IPv6) is known, but the details of the lease are

View File

@ -51,8 +51,9 @@ The arguments are as follows:
``-T config-file``
Checks the configuration file and reports the first error, if any.
It performs extra checks beside ``-t`` is doing, like establising database
connections (lease db, host db, CB db, forensic logging db), hook libraries
It performs extra checks beside what ``-t`` is doing, like establising
database connections (lease backend, host reservations backend, configuration
backend and forensic logging backend), hook libraries
loading and configuration parsing, etc. It does not open unix or TCP/UDP
sockets, neither does it open or rotate files, as all these actions could
interfere with a running process on the same machine.

View File

@ -51,8 +51,9 @@ The arguments are as follows:
``-T config-file``
Checks the configuration file and reports the first error, if any.
It performs extra checks beside ``-t`` is doing, like establising database
connections (lease db, host db, CB db, forensic logging db), hook libraries
It performs extra checks beside what ``-t`` is doing, like establising
database connections (lease backend, host reservations backend, configuration
backend and forensic logging backend), hook libraries
loading and configuration parsing, etc. It does not open unix or TCP/UDP
sockets, neither does it open or rotate files, as all these actions could
interfere with a running process on the same machine.

View File

@ -757,7 +757,45 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
SrvConfigPtr srv_config;
if (status_code == CONTROL_RESULT_SUCCESS) {
if (!check_only) {
if (check_only) {
if (extra_checks) {
// Re-open lease and host database with new parameters.
try {
// Get the staging configuration.
srv_config = CfgMgr::instance().getStagingCfg();
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
string params = "universe=4 persist=false";
if (cfg_db->getExtendedInfoTablesEnabled()) {
params += " extended-info-tables=true";
}
cfg_db->setAppendedParameters(params);
cfg_db->createManagers();
} catch (const std::exception& ex) {
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());
status_code = CONTROL_RESULT_ERROR;
}
if (status_code == CONTROL_RESULT_SUCCESS) {
std::ostringstream err;
// Configure DHCP packet queueing
try {
data::ConstElementPtr qc;
qc = CfgMgr::instance().getStagingCfg()->getDHCPQueueControl();
if (IfaceMgr::instance().configureDHCPPacketQueue(AF_INET, qc)) {
LOG_INFO(dhcp4_logger, DHCP4_CONFIG_PACKET_QUEUE)
.arg(IfaceMgr::instance().getPacketQueue4()->getInfoStr());
}
} catch (const std::exception& ex) {
err << "Error setting packet queue controls after server reconfiguration: "
<< ex.what();
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str());
status_code = CONTROL_RESULT_ERROR;
}
}
}
} else {
string parameter_name;
ElementPtr mutable_cfg;
@ -805,25 +843,6 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
" processing error");
status_code = CONTROL_RESULT_ERROR;
}
} else {
if (extra_checks) {
// Re-open lease and host database with new parameters.
try {
// Get the staging configuration.
srv_config = CfgMgr::instance().getStagingCfg();
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
string params = "universe=4 persist=false";
if (cfg_db->getExtendedInfoTablesEnabled()) {
params += " extended-info-tables=true";
}
cfg_db->setAppendedParameters(params);
cfg_db->createManagers();
} catch (const std::exception& ex) {
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());
status_code = CONTROL_RESULT_ERROR;
}
}
}
}
@ -897,13 +916,9 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
// Moved from the commit block to add the config backend indication.
if (status_code == CONTROL_RESULT_SUCCESS && (!check_only || extra_checks)) {
try {
if (extra_checks) {
server.getCBControl()->databaseConfigConnect(srv_config);
} else {
// If there are config backends, fetch and merge into staging config
server.getCBControl()->databaseConfigFetch(srv_config,
CBControlDHCPv4::FetchMode::FETCH_ALL);
}
// If there are config backends, fetch and merge into staging config
server.getCBControl()->databaseConfigFetch(srv_config,
CBControlDHCPv4::FetchMode::FETCH_ALL);
} catch (const isc::Exception& ex) {
std::ostringstream err;
err << "during update from config backend database: " << ex.what();

View File

@ -289,22 +289,16 @@ syntax_check_test() {
local test_name="${1}"
local config="${2}"
local expected_code="${3}"
local extra_check="${4}"
local check_type="${4}"
# Log the start of the test and print test name.
test_start "${test_name}"
# Create correct configuration file.
create_config "${config}"
# Check it
if [ "${extra_check}" -eq 1 ]; then
printf "Running command %s.\n" "\"${bin_path}/${bin} -T ${CFG_FILE}\""
run_command \
"${bin_path}/${bin}" -T "${CFG_FILE}"
else
printf "Running command %s.\n" "\"${bin_path}/${bin} -t ${CFG_FILE}\""
run_command \
"${bin_path}/${bin}" -t "${CFG_FILE}"
fi
printf "Running command %s.\n" "\"${bin_path}/${bin} ${check_type} ${CFG_FILE}\""
run_command \
"${bin_path}/${bin}" "${check_type}" "${CFG_FILE}"
if [ "${EXIT_CODE}" -ne "${expected_code}" ]; then
printf 'ERROR: expected exit code %s, got %s\n' "${expected_code}" "${EXIT_CODE}"
clean_exit 1
@ -583,9 +577,9 @@ shutdown_test "dhcpv4.sigint_test" 2
version_test "dhcpv4.version"
logger_vars_test "dhcpv4.variables"
lfc_timer_test
syntax_check_test "dhcpv4.syntax_check_success" "${CONFIG}" 0 0
syntax_check_test "dhcpv4.syntax_check_bad_syntax" "${CONFIG_BAD_SYNTAX}" 1 0
syntax_check_test "dhcpv4.syntax_check_bad_values" "${CONFIG_BAD_VALUES}" 1 0
syntax_check_test "dhcpv4.syntax_check_hooks_load_fail" "${INVALID_CONFIG_HOOKS_LOAD}" 1 1
syntax_check_test "dhcpv4.syntax_check_hooks_callout_fail" "${INVALID_CONFIG_HOOKS_CALLOUT_FAIL}" 1 1
syntax_check_test "dhcpv4.syntax_check_success" "${CONFIG}" 0 -t
syntax_check_test "dhcpv4.syntax_check_bad_syntax" "${CONFIG_BAD_SYNTAX}" 1 -t
syntax_check_test "dhcpv4.syntax_check_bad_values" "${CONFIG_BAD_VALUES}" 1 -t
syntax_check_test "dhcpv4.syntax_check_hooks_load_fail" "${INVALID_CONFIG_HOOKS_LOAD}" 1 -T
syntax_check_test "dhcpv4.syntax_check_hooks_callout_fail" "${INVALID_CONFIG_HOOKS_CALLOUT_FAIL}" 1 -T
password_redact_test "dhcpv4.password_redact_test" "$(kea_dhcp_config 4)" 0

View File

@ -886,7 +886,45 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
SrvConfigPtr srv_config;
if (status_code == CONTROL_RESULT_SUCCESS) {
if (!check_only) {
if (check_only) {
if (extra_checks) {
// Re-open lease and host database with new parameters.
try {
// Get the staging configuration.
srv_config = CfgMgr::instance().getStagingCfg();
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
string params = "universe=6 persist=false";
if (cfg_db->getExtendedInfoTablesEnabled()) {
params += " extended-info-tables=true";
}
cfg_db->setAppendedParameters(params);
cfg_db->createManagers();
} catch (const std::exception& ex) {
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());
status_code = CONTROL_RESULT_ERROR;
}
if (status_code == CONTROL_RESULT_SUCCESS) {
std::ostringstream err;
// Configure DHCP packet queueing
try {
data::ConstElementPtr qc;
qc = CfgMgr::instance().getStagingCfg()->getDHCPQueueControl();
if (IfaceMgr::instance().configureDHCPPacketQueue(AF_INET6, qc)) {
LOG_INFO(dhcp6_logger, DHCP6_CONFIG_PACKET_QUEUE)
.arg(IfaceMgr::instance().getPacketQueue6()->getInfoStr());
}
} catch (const std::exception& ex) {
err << "Error setting packet queue controls after server reconfiguration: "
<< ex.what();
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str());
status_code = CONTROL_RESULT_ERROR;
}
}
}
} else {
string parameter_name;
ElementPtr mutable_cfg;
@ -934,25 +972,6 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
" processing error");
status_code = CONTROL_RESULT_ERROR;
}
} else {
if (extra_checks) {
// Re-open lease and host database with new parameters.
try {
// Get the staging configuration.
srv_config = CfgMgr::instance().getStagingCfg();
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
string params = "universe=6 persist=false";
if (cfg_db->getExtendedInfoTablesEnabled()) {
params += " extended-info-tables=true";
}
cfg_db->setAppendedParameters(params);
cfg_db->createManagers();
} catch (const std::exception& ex) {
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());
status_code = CONTROL_RESULT_ERROR;
}
}
}
}
@ -1026,13 +1045,9 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
// Moved from the commit block to add the config backend indication.
if (status_code == CONTROL_RESULT_SUCCESS && (!check_only || extra_checks)) {
try {
if (extra_checks) {
server.getCBControl()->databaseConfigConnect(srv_config);
} else {
// If there are config backends, fetch and merge into staging config
server.getCBControl()->databaseConfigFetch(srv_config,
CBControlDHCPv6::FetchMode::FETCH_ALL);
}
// If there are config backends, fetch and merge into staging config
server.getCBControl()->databaseConfigFetch(srv_config,
CBControlDHCPv6::FetchMode::FETCH_ALL);
} catch (const isc::Exception& ex) {
std::ostringstream err;
err << "during update from config backend database: " << ex.what();

View File

@ -306,22 +306,16 @@ syntax_check_test() {
local test_name="${1}"
local config="${2}"
local expected_code="${3}"
local extra_check="${4}"
local check_type="${4}"
# Log the start of the test and print test name.
test_start "${test_name}"
# Create correct configuration file.
create_config "${config}"
# Check it
if [ "${extra_check}" -eq 1 ]; then
printf "Running command %s.\n" "\"${bin_path}/${bin} -T ${CFG_FILE}\""
run_command \
"${bin_path}/${bin}" -T "${CFG_FILE}"
else
printf "Running command %s.\n" "\"${bin_path}/${bin} -t ${CFG_FILE}\""
run_command \
"${bin_path}/${bin}" -t "${CFG_FILE}"
fi
printf "Running command %s.\n" "\"${bin_path}/${bin} ${check_type} ${CFG_FILE}\""
run_command \
"${bin_path}/${bin}" "${check_type}" "${CFG_FILE}"
if [ "${EXIT_CODE}" -ne "${expected_code}" ]; then
printf 'ERROR: expected exit code %s, got %s\n' "${expected_code}" "${EXIT_CODE}"
clean_exit 1
@ -603,9 +597,9 @@ shutdown_test "dhcpv6.sigint_test" 2
version_test "dhcpv6.version"
logger_vars_test "dhcpv6.variables"
lfc_timer_test
syntax_check_test "dhcpv6.syntax_check_success" "${CONFIG}" 0 0
syntax_check_test "dhcpv6.syntax_check_bad_syntax" "${CONFIG_BAD_SYNTAX}" 1 0
syntax_check_test "dhcpv6.syntax_check_bad_values" "${CONFIG_BAD_VALUES}" 1 0
syntax_check_test "dhcpv6.syntax_check_hooks_load_fail" "${INVALID_CONFIG_HOOKS_LOAD}" 1 1
syntax_check_test "dhcpv6.syntax_check_hooks_callout_fail" "${INVALID_CONFIG_HOOKS_CALLOUT_FAIL}" 1 1
syntax_check_test "dhcpv6.syntax_check_success" "${CONFIG}" 0 -t
syntax_check_test "dhcpv6.syntax_check_bad_syntax" "${CONFIG_BAD_SYNTAX}" 1 -t
syntax_check_test "dhcpv6.syntax_check_bad_values" "${CONFIG_BAD_VALUES}" 1 -t
syntax_check_test "dhcpv6.syntax_check_hooks_load_fail" "${INVALID_CONFIG_HOOKS_LOAD}" 1 -T
syntax_check_test "dhcpv6.syntax_check_hooks_callout_fail" "${INVALID_CONFIG_HOOKS_CALLOUT_FAIL}" 1 -T
password_redact_test "dhcpv6.password_redact_test" "$(kea_dhcp_config 6)" 0