From: Tomek Mrugalski Date: Wed, 14 Mar 2018 00:46:45 +0000 (+0000) Subject: [5484] Changes after review: X-Git-Tag: kea5574_base~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb2d80801901b1bcc6c92819961409503db00996;p=thirdparty%2Fkea.git [5484] Changes after review: - unit-test improvements - examples changes to tcp-keepalive 1200 seconds --- diff --git a/doc/examples/kea4/cassandra.json b/doc/examples/kea4/cassandra.json index a827c9f63e..e26c79a352 100644 --- a/doc/examples/kea4/cassandra.json +++ b/doc/examples/kea4/cassandra.json @@ -40,8 +40,9 @@ "request-timeout": 12000, // This parameter governs the TCP keep-alive mechanism. Expressed - // in seconds of delay. The default is disabled. - "tcp-keepalive": 1, + // in seconds of delay. The default is disabled. In this example + // it is set to 20 minutes. + "tcp-keepalive": 1200, // This parameter enables/disables Nagle's algorithm on connections. // The default is true. diff --git a/doc/examples/kea6/cassandra.json b/doc/examples/kea6/cassandra.json index 617c713b89..2733105913 100644 --- a/doc/examples/kea6/cassandra.json +++ b/doc/examples/kea6/cassandra.json @@ -39,8 +39,9 @@ "request-timeout": 12000, // This parameter governs the TCP keep-alive mechanism. Expressed - // in seconds of delay. The default is disabled. - "tcp-keepalive": 1, + // in seconds of delay. The default is disabled. In this example it is + // set to 20 minutes. + "tcp-keepalive": 1200, // This parameter enables/disables Nagle's algorithm on connections. // The default is true. diff --git a/doc/guide/dhcp4-srv.xml b/doc/guide/dhcp4-srv.xml index ce3dc318a7..63147ff7ad 100644 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@ -503,6 +503,7 @@ If a timeout is given though, it should be an integer greater than zero. "Dhcp4": { "lease-database": { + "type": "cql", "contact-points": "ip-address1, ip-address2 [,...]", ... }, diff --git a/doc/guide/install.xml b/doc/guide/install.xml index 2eebb3cb94..ff384fdf76 100644 --- a/doc/guide/install.xml +++ b/doc/guide/install.xml @@ -612,9 +612,7 @@ $ make cql_config_define.sh.sample available, you may copy it over to cql_config_defines.sh and edit path specified in it) and change the environment variable CPP_DRIVER_PATH to point to the directory, where - cpp-driver sources are located. (If the cpp-driver sources already - provide cql_config script please use that rather than the version from - Kea sources.) + cpp-driver sources are located. Build and install Kea as described in , with diff --git a/src/lib/dhcpsrv/parsers/dbaccess_parser.cc b/src/lib/dhcpsrv/parsers/dbaccess_parser.cc index cb4b0f3b75..b1dcfc8d46 100644 --- a/src/lib/dhcpsrv/parsers/dbaccess_parser.cc +++ b/src/lib/dhcpsrv/parsers/dbaccess_parser.cc @@ -58,7 +58,9 @@ DbAccessParser::parse(CfgDbAccessPtr& cfg_db, int64_t port = 0; int64_t max_reconnect_tries = 0; int64_t reconnect_wait_time = 0; - + int64_t request_timeout = 0; + int64_t tcp_keepalive = 0; + // 2. Update the copy with the passed keywords. BOOST_FOREACH(ConfigPair param, database_config->mapValue()) { try { @@ -88,14 +90,14 @@ DbAccessParser::parse(CfgDbAccessPtr& cfg_db, boost::lexical_cast(reconnect_wait_time); } else if (param.first == "request-timeout") { - timeout = param.second->intValue(); + request_timeout = param.second->intValue(); values_copy[param.first] = - boost::lexical_cast(timeout); + boost::lexical_cast(request_timeout); } else if (param.first == "tcp-keepalive") { - timeout = param.second->intValue(); + tcp_keepalive = param.second->intValue(); values_copy[param.first] = - boost::lexical_cast(timeout); + boost::lexical_cast(tcp_keepalive); } else if (param.first == "port") { port = param.second->intValue(); @@ -171,15 +173,33 @@ DbAccessParser::parse(CfgDbAccessPtr& cfg_db, // Check that the max-reconnect-retries reasonable. if (max_reconnect_tries < 0) { ConstElementPtr value = database_config->get("max-reconnect-tries"); - isc_throw(DhcpConfigError, "max-reconnect-tries cannot be less than zero: " + isc_throw(DhcpConfigError, "max-reconnect-tries cannot be less than zero: " << " (" << value->getPosition() << ")"); } // Check that the reconnect-wait-time reasonable. if ((reconnect_wait_time < 0) || - (port > std::numeric_limits::max())) { + (reconnect_wait_time > std::numeric_limits::max())) { + ConstElementPtr value = database_config->get("reconnect-wait-time"); + isc_throw(DhcpConfigError, "reconnect-wait-time " << reconnect_wait_time + << " must be in range 0...MAX_UINT32 (4294967295) " + << " (" << value->getPosition() << ")"); + } + + // Check that request_timeout value makes sense. + if ((reconnect_wait_time < 0) || + (reconnect_wait_time > std::numeric_limits::max())) { + ConstElementPtr value = database_config->get("reconnect-wait-time"); + isc_throw(DhcpConfigError, "reconnect-wait-time " << reconnect_wait_time + << " must be in range 0...MAX_UINT32 (4294967295) " + << " (" << value->getPosition() << ")"); + } + // Check that tcp_keepalive value makes sense. + if ((tcp_keepalive < 0) || + (tcp_keepalive > std::numeric_limits::max())) { ConstElementPtr value = database_config->get("reconnect-wait-time"); - isc_throw(DhcpConfigError, "reconnect-wait-time cannot be less than zero: " + isc_throw(DhcpConfigError, "tcp-keepalive " << tcp_keepalive + << " must be in range 0...MAX_UINT32 (4294967295) " << " (" << value->getPosition() << ")"); } diff --git a/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc b/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc index a3c1c0cd4c..17bac48b8c 100644 --- a/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc @@ -202,8 +202,10 @@ TEST(CqlHostDataSource, OpenDatabase) { // Check that lease manager open the database opens correctly with a longer // timeout. If it fails, print the error message. try { + // CQL specifies the timeout values in ms, not seconds. Therefore + // we need to add extra 000 to the "connect-timeout=10" string. string connection_string = validCqlConnectionString() + string(" ") + - string(VALID_TIMEOUT); + string(VALID_TIMEOUT) + string("000"); HostDataSourceFactory::create(connection_string); EXPECT_NO_THROW((void) HostDataSourceFactory::getHostDataSourcePtr()); HostDataSourceFactory::destroy(); diff --git a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc index 3d6bf79fb8..58be7a15ad 100644 --- a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc @@ -358,8 +358,10 @@ TEST(CqlOpenTest, OpenDatabase) { // Check that lease manager open the database opens correctly with a longer // timeout. If it fails, print the error message. try { + // CQL specifies the timeout values in ms, not seconds. Therefore + // we need to add extra 000 to the "connect-timeout=10" string. string connection_string = validCqlConnectionString() + string(" ") + - string(VALID_TIMEOUT); + string(VALID_TIMEOUT) + "000"; LeaseMgrFactory::create(connection_string); EXPECT_NO_THROW((void) LeaseMgrFactory::instance()); LeaseMgrFactory::destroy();