From: Andrei Pavel Date: Thu, 17 Aug 2017 18:15:48 +0000 (+0300) Subject: Merge branch 'isc-master' into cassandra-update X-Git-Tag: trac5494_base~11^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0ba37f938331546d45d60efac5f7c8e92384e8e8;p=thirdparty%2Fkea.git Merge branch 'isc-master' into cassandra-update --- 0ba37f938331546d45d60efac5f7c8e92384e8e8 diff --cc AUTHORS index f8fe3e5354,cad9cfbd9f..d38073e35c --- a/AUTHORS +++ b/AUTHORS @@@ -131,9 -152,8 +152,9 @@@ Kea uses log4cplus (http://sourceforge. Boost (http://www.boost.org/) library for almost everything, and can use Botan (http://botan.randombit.net/) or OpenSSL (https://www.openssl.org/) for cryptographic operations. It can also optionally use PostgreSQL -(http://www.postgresql.org/) and/or MySQL (http://www.mysql.com/) as a database. +(http://www.postgresql.org/) and/or MySQL (http://www.mysql.com/) and/or +Cassandra (http://cassandra.apache.org/) as a database. - Kea can use googletest for unit-tests (http://code.google.com/p/googletest/). + Kea can use googletest for unit-tests (https://github.com/google/googletest). - Kea uses ISC Forge (http://kea.isc.org/wiki/IscForge) for conformance testing. + Kea uses ISC Forge (https://github.com/isc-projects/forge/) for conformance testing. diff --cc doc/guide/dhcp4-srv.xml index 49508011be,49597a559a..b73a816799 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@@ -455,10 -459,11 +467,15 @@@ be followed by a comma and another obje the DHCPv4 server. In this case, set the value to the empty string: "Dhcp4": { "lease-database": { "host" : "", ... }, ... } + + For Cassandra: + +"Dhcp4": { "lease-database": { "contact_points": "", ... }, ... } + + Should the database use a port different than default, it may be + specified as well: + + "Dhcp4": { "lease-database": { "port" : 12345, ... }, ... } Should the database be located on a different system, you may need to specify a longer interval for the connection timeout: diff --cc doc/guide/dhcp6-srv.xml index 5492ff2229,198d3dc423..532beab22d --- a/doc/guide/dhcp6-srv.xml +++ b/doc/guide/dhcp6-srv.xml @@@ -450,10 -454,11 +462,16 @@@ be followed by a comma and another obje the DHCPv6 server. In this case, set the value to the empty string: "Dhcp6": { "lease-database": { "host" : "", ... }, ... } + + For Cassandra: + +"Dhcp6": { "lease-database": { "contact_points": "", ... }, ... } + + Should the database use a port different than default, it may be + specified as well: + + "Dhcp4": { "lease-database": { "port" : 12345, ... }, ... } ++>>>>>>> isc-master Should the database be located on a different system, you may need to specify a longer interval for the connection timeout: diff --cc src/lib/dhcpsrv/cql_connection.cc index b4e20c7856,6959d227a3..4e6a410c84 --- a/src/lib/dhcpsrv/cql_connection.cc +++ b/src/lib/dhcpsrv/cql_connection.cc @@@ -72,12 -67,12 +72,12 @@@ CqlConnection::openDatabase() CassError rc; // Set up the values of the parameters const char* contact_points = "127.0.0.1"; - string scontact_points; + std::string scontact_points; try { - scontact_points = getParameter("contact_points"); + scontact_points = getParameter("contact-points"); contact_points = scontact_points.c_str(); } catch (...) { - // No host. Fine, we'll use "localhost". + // No host. Fine, we'll use "127.0.0.1". } const char* port = NULL; diff --cc src/lib/dhcpsrv/cql_lease_mgr.cc index 7175dd23ea,c3030f1b04..35a79f90b5 --- a/src/lib/dhcpsrv/cql_lease_mgr.cc +++ b/src/lib/dhcpsrv/cql_lease_mgr.cc @@@ -1768,9 -1882,19 +1768,19 @@@ CqlLeaseMgr::deleteExpiredReclaimedLeas result++; } } - return (result); + return result; } + size_t + CqlLeaseMgr::wipeLeases4(const SubnetID& /*subnet_id*/) { + isc_throw(NotImplemented, "wipeLeases4 is not implemented for Cassandra backend"); + } + + size_t + CqlLeaseMgr::wipeLeases6(const SubnetID& /*subnet_id*/) { + isc_throw(NotImplemented, "wipeLeases6 is not implemented for Cassandra backend"); + } + std::string CqlLeaseMgr::getName() const { std::string name = ""; diff --cc src/lib/dhcpsrv/cql_lease_mgr.h index bd5c4b9743,bff24148a4..ad1f4312a3 --- a/src/lib/dhcpsrv/cql_lease_mgr.h +++ b/src/lib/dhcpsrv/cql_lease_mgr.h @@@ -322,8 -377,30 +322,30 @@@ public /// time will not be deleted. /// /// @return Number of leases deleted. - virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t ); + virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs); + /// @brief Removes specified IPv4 leases. + /// + /// This rather dangerous method is able to remove all leases from specified + /// subnet. + /// + /// @todo: Not implemented yet. + /// + /// @param subnet_id identifier of the subnet + /// @return number of leases removed. + virtual size_t wipeLeases4(const SubnetID& subnet_id); + + /// @brief Removed specified IPv6 leases. + /// + /// This rather dangerous method is able to remove all leases from specified + /// subnet. + /// + /// @todo: Not implemented yet. + /// + /// @param subnet_id identifier of the subnet + /// @return number of leases removed. + virtual size_t wipeLeases6(const SubnetID& subnet_id); + /// @brief Return backend type /// /// @return Type of the backend. diff --cc src/lib/dhcpsrv/parsers/dbaccess_parser.cc index 329d0c50e5,e4231dc1e2..6a6d0d944d --- a/src/lib/dhcpsrv/parsers/dbaccess_parser.cc +++ b/src/lib/dhcpsrv/parsers/dbaccess_parser.cc @@@ -50,11 -55,11 +55,12 @@@ DbAccessParser::parse(CfgDbAccessPtr& c int64_t lfc_interval = 0; int64_t timeout = 0; + int64_t port = 0; // 2. Update the copy with the passed keywords. - BOOST_FOREACH(ConfigPair param, config_value->mapValue()) { + BOOST_FOREACH(ConfigPair param, database_config->mapValue()) { try { - if ((param.first == "persist") || (param.first == "readonly")) { + if ((param.first == "persist") || (param.first == "readonly") || + (param.first == "tcp-nodelay")) { values_copy[param.first] = (param.second->boolValue() ? "true" : "false"); @@@ -68,20 -73,11 +74,26 @@@ values_copy[param.first] = boost::lexical_cast(timeout); + } else if (param.first == "reconnect-wait-time") { + timeout = param.second->intValue(); + values_copy[param.first] = + boost::lexical_cast(timeout); + + } else if (param.first == "request-timeout") { + timeout = param.second->intValue(); + values_copy[param.first] = + boost::lexical_cast(timeout); + + } else if (param.first == "tcp-keepalive") { + timeout = param.second->intValue(); + values_copy[param.first] = + boost::lexical_cast(timeout); ++ + } else if (param.first == "port") { + port = param.second->intValue(); + values_copy[param.first] = + boost::lexical_cast(port); + } else { values_copy[param.first] = param.second->stringValue(); } diff --cc src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc index a556b9959b,3da3658d1e..a8902cc346 --- a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc @@@ -687,4 -643,14 +687,15 @@@ TEST_F(CqlLeaseMgrTest, deleteExpiredRe testDeleteExpiredReclaimedLeases4(); } + // Tests that leases from specific subnet can be removed. + TEST_F(CqlLeaseMgrTest, DISABLED_wipeLeases4) { + testWipeLeases4(); + } + + // Tests that leases from specific subnet can be removed. + TEST_F(CqlLeaseMgrTest, DISABLED_wipeLeases6) { + testWipeLeases6(); + } + -}; // Of anonymous namespace +} // namespace ++