]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3536] addressed review comments
authorRazvan Becheriu <razvan@isc.org>
Wed, 2 Oct 2024 16:00:27 +0000 (19:00 +0300)
committerRazvan Becheriu <razvan@isc.org>
Thu, 3 Oct 2024 18:04:37 +0000 (21:04 +0300)
19 files changed:
src/hooks/dhcp/mysql/Makefile.am
src/hooks/dhcp/mysql/libloadtests/.gitignore
src/hooks/dhcp/mysql/libloadtests/Makefile.am
src/hooks/dhcp/mysql/mysql_callouts.cc
src/hooks/dhcp/mysql/mysql_hb_messages.mes
src/hooks/dhcp/mysql/mysql_lb_messages.mes
src/hooks/dhcp/mysql/tests/.gitignore
src/hooks/dhcp/mysql/tests/Makefile.am
src/hooks/dhcp/mysql/version.cc
src/hooks/dhcp/pgsql/Makefile.am
src/hooks/dhcp/pgsql/libloadtests/.gitignore
src/hooks/dhcp/pgsql/libloadtests/Makefile.am
src/hooks/dhcp/pgsql/pgsql_callouts.cc
src/hooks/dhcp/pgsql/pgsql_hb_messages.mes
src/hooks/dhcp/pgsql/pgsql_lb_messages.mes
src/hooks/dhcp/pgsql/tests/.gitignore
src/hooks/dhcp/pgsql/tests/Makefile.am
src/hooks/dhcp/pgsql/version.cc
src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc

index 868abfbc6e055e68b243a7d1ebd2c8dfc410adeb..9c77522b9cb3be6084cbb7a27be98eb883c50f69 100644 (file)
@@ -1,11 +1,11 @@
 SUBDIRS = . tests libloadtests
 
 AM_CPPFLAGS  = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
-AM_CPPFLAGS += $(BOOST_INCLUDES) $(MYSQL_CPPFLAGS)
+AM_CPPFLAGS += $(BOOST_INCLUDES) $(MYSQL_CPPFLAGS) $(CRYPTO_CFLAGS) $(CRYPTO_INCLUDES)
 AM_CXXFLAGS  = $(KEA_CXXFLAGS)
 
 # Ensure that the message file is included in the distribution
-EXTRA_DIST = mysql_cb_messages.mes
+EXTRA_DIST  = mysql_cb_messages.mes
 EXTRA_DIST += mysql_hb_messages.mes
 EXTRA_DIST += mysql_lb_messages.mes
 
@@ -60,6 +60,9 @@ libdhcp_mysql_la_LIBADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.
 libdhcp_mysql_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
 libdhcp_mysql_la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la
 libdhcp_mysql_la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+libdhcp_mysql_la_LIBADD += $(LOG4CPLUS_LIBS)
+libdhcp_mysql_la_LIBADD += $(CRYPTO_LIBS)
+libdhcp_mysql_la_LIBADD += $(BOOST_LIBS)
 
 # If we want to get rid of all generated messages files, we need to use
 # make maintainer-clean. The proper way to introduce custom commands for
index ada6ed5036109753b6fed70fa9984c8393767620..946a6d154798c91c514fe4a6498431079a4c0b5a 100644 (file)
@@ -1 +1,2 @@
 hook_load_unittests
+
index 8de28ce337afd1b7c94e9d4520b090b8736b55c3..9326ce1b686b91c8509d7580ec14f455e24449b9 100644 (file)
@@ -2,7 +2,7 @@ SUBDIRS = .
 
 AM_CPPFLAGS  = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
 AM_CPPFLAGS += -I$(top_builddir)/src/hooks/dhcp/mysql -I$(top_srcdir)/src/hooks/dhcp/mysql
-AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += $(BOOST_INCLUDES) $(MYSQL_CPPFLAGS) $(CRYPTO_CFLAGS) $(CRYPTO_INCLUDES)
 AM_CPPFLAGS += -DLIBDHCP_MYSQL_SO=\"$(abs_top_builddir)/src/hooks/dhcp/mysql/.libs/libdhcp_mysql.so\"
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
 
index 4e8cd4e48fcfbaaee5d2e59a8ac0d58e218f130a..a76ffd53ea72c3f3c5f71302ba7b95fe7fbd7128 100644 (file)
@@ -60,8 +60,8 @@ int load(LibraryHandle& /* handle */) {
     }
 
     // Register MySQL CB factories with CB Managers
-    isc::dhcp::MySqlConfigBackendDHCPv4::registerBackendType();
-    isc::dhcp::MySqlConfigBackendDHCPv6::registerBackendType();
+    MySqlConfigBackendDHCPv4::registerBackendType();
+    MySqlConfigBackendDHCPv6::registerBackendType();
     LOG_INFO(mysql_cb_logger, MYSQL_CB_INIT_OK);
 
     // Register MySQL HB factories with Host Managers
@@ -87,8 +87,8 @@ int load(LibraryHandle& /* handle */) {
 /// @param handle callout handle passed to the callout.
 /// @return 0 on success, 1 otherwise.
 int dhcp4_srv_configured(CalloutHandle& /* handle */) {
-    isc::dhcp::MySqlConfigBackendImpl::setIOService(IOServicePtr(new IOService()));
-    IOServiceMgr::instance().registerIOService(isc::dhcp::MySqlConfigBackendImpl::getIOService());
+    MySqlConfigBackendImpl::setIOService(IOServicePtr(new IOService()));
+    IOServiceMgr::instance().registerIOService(MySqlConfigBackendImpl::getIOService());
     return (0);
 }
 
@@ -99,8 +99,8 @@ int dhcp4_srv_configured(CalloutHandle& /* handle */) {
 /// @param handle callout handle passed to the callout.
 /// @return 0 on success, 1 otherwise.
 int dhcp6_srv_configured(CalloutHandle& /* handle */) {
-    isc::dhcp::MySqlConfigBackendImpl::setIOService(IOServicePtr(new IOService()));
-    IOServiceMgr::instance().registerIOService(isc::dhcp::MySqlConfigBackendImpl::getIOService());
+    MySqlConfigBackendImpl::setIOService(IOServicePtr(new IOService()));
+    IOServiceMgr::instance().registerIOService(MySqlConfigBackendImpl::getIOService());
     return (0);
 }
 
@@ -109,13 +109,13 @@ int dhcp6_srv_configured(CalloutHandle& /* handle */) {
 /// @return 0 if deregistration was successful, 1 otherwise
 int unload() {
     // Unregister the factories and remove MySQL backends
-    isc::dhcp::MySqlConfigBackendDHCPv4::unregisterBackendType();
-    isc::dhcp::MySqlConfigBackendDHCPv6::unregisterBackendType();
-    IOServicePtr io_service = isc::dhcp::MySqlConfigBackendImpl::getIOService();
+    MySqlConfigBackendDHCPv4::unregisterBackendType();
+    MySqlConfigBackendDHCPv6::unregisterBackendType();
+    IOServicePtr io_service = MySqlConfigBackendImpl::getIOService();
     if (io_service) {
         IOServiceMgr::instance().unregisterIOService(io_service);
         io_service->stopAndPoll();
-        isc::dhcp::MySqlConfigBackendImpl::setIOService(IOServicePtr());
+        MySqlConfigBackendImpl::setIOService(IOServicePtr());
     }
     LOG_INFO(mysql_cb_logger, MYSQL_CB_DEINIT_OK);
 
index 884fc31662e05840a2429be9306672cd433f728a..f9663342470770795294587bb7586aade0ac7780 100644 (file)
@@ -7,7 +7,7 @@
 $NAMESPACE isc::dhcp
 
 % MYSQL_HB_DB opening MySQL hosts database: %1
-Logged at debug log level 50.
+Logged at debug log level 40.
 This informational message is logged when a DHCP server (either V4 or
 V6) is about to open a MySQL hosts database. The parameters of the
 connection including database name and username needed to access it
index eefe6e66cec6ebb7e89514377074b4e89f7a1078..5a0bb5dfd69b72737efee62088f90a9729a54b2a 100644 (file)
@@ -7,7 +7,7 @@
 $NAMESPACE isc::dhcp
 
 % MYSQL_LB_DB opening MySQL lease database: %1
-Logged at debug log level 50.
+Logged at debug log level 40.
 This informational message is logged when a DHCP server (either V4 or
 V6) is about to open a MySQL lease database. The parameters of the
 connection including database name and username needed to access it
index b72f84fe26e916528115bb6d9eaffa72346e92c4..905ae0fd1e266d7bbeda7cb594b91f8ed72f5488 100644 (file)
@@ -1 +1,2 @@
-/mysql_unittests
\ No newline at end of file
+/mysql_unittests
+
index 132299edbde7a4e8e58f2d242bf3b4d770af7037..a1d44962541ec2942b3f2d20dd2bdcf40f12457a 100644 (file)
@@ -2,7 +2,7 @@ SUBDIRS = .
 
 AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
 AM_CPPFLAGS += -I$(top_builddir)/src/hooks/dhcp/mysql -I$(top_srcdir)/src/hooks/dhcp/mysql
-AM_CPPFLAGS += $(BOOST_INCLUDES) $(MYSQL_CPPFLAGS)
+AM_CPPFLAGS += $(BOOST_INCLUDES) $(MYSQL_CPPFLAGS) $(CRYPTO_CFLAGS) $(CRYPTO_INCLUDES)
 AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
 
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
index 8f9df4f44457c2aad95d4cca1f38cf4f590100a2..e74de12b7a45ca844e0a04463b85fb2b6202e552 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
index 78237b70d165aadd282a5ad479e227d770e49a0a..bc06050d7dc618f10e6514c4ae43882d815984d7 100644 (file)
@@ -1,11 +1,11 @@
 SUBDIRS = . tests libloadtests
 
 AM_CPPFLAGS  = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
-AM_CPPFLAGS += $(BOOST_INCLUDES) $(PGSQL_CPPFLAGS)
+AM_CPPFLAGS += $(BOOST_INCLUDES) $(PGSQL_CPPFLAGS) $(CRYPTO_CFLAGS) $(CRYPTO_INCLUDES)
 AM_CXXFLAGS  = $(KEA_CXXFLAGS)
 
 # Ensure that the message file is included in the distribution
-EXTRA_DIST = pgsql_cb_messages.mes
+EXTRA_DIST  = pgsql_cb_messages.mes
 EXTRA_DIST += pgsql_hb_messages.mes
 EXTRA_DIST += pgsql_lb_messages.mes
 
@@ -60,6 +60,9 @@ libdhcp_pgsql_la_LIBADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.
 libdhcp_pgsql_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
 libdhcp_pgsql_la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la
 libdhcp_pgsql_la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+libdhcp_pgsql_la_LIBADD += $(LOG4CPLUS_LIBS)
+libdhcp_pgsql_la_LIBADD += $(CRYPTO_LIBS)
+libdhcp_pgsql_la_LIBADD += $(BOOST_LIBS)
 
 # If we want to get rid of all generated messages files, we need to use
 # make maintainer-clean. The proper way to introduce custom commands for
index ada6ed5036109753b6fed70fa9984c8393767620..946a6d154798c91c514fe4a6498431079a4c0b5a 100644 (file)
@@ -1 +1,2 @@
 hook_load_unittests
+
index b098047ae9a5952a937b309845afcbf7a0c194d5..9a1cd520a81bdfa35a28836022a047b71fe9d0b1 100644 (file)
@@ -2,7 +2,7 @@ SUBDIRS = .
 
 AM_CPPFLAGS  = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
 AM_CPPFLAGS += -I$(top_builddir)/src/hooks/dhcp/pgsql -I$(top_srcdir)/src/hooks/dhcp/pgsql
-AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += $(BOOST_INCLUDES) $(PGSQL_CPPFLAGS) $(CRYPTO_CFLAGS) $(CRYPTO_INCLUDES)
 AM_CPPFLAGS += -DLIBDHCP_PGSQL_SO=\"$(abs_top_builddir)/src/hooks/dhcp/pgsql/.libs/libdhcp_pgsql.so\"
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
 
index e3735da1a793b16aad86b672c89cecf215f6eb01..74bb29ef725b8417ad43f23ad6153156535d069b 100644 (file)
@@ -60,8 +60,8 @@ int load(LibraryHandle& /* handle */) {
     }
 
     // Register PostgreSQL CB factories with CB Managers
-    isc::dhcp::PgSqlConfigBackendDHCPv4::registerBackendType();
-    isc::dhcp::PgSqlConfigBackendDHCPv6::registerBackendType();
+    PgSqlConfigBackendDHCPv4::registerBackendType();
+    PgSqlConfigBackendDHCPv6::registerBackendType();
     LOG_INFO(pgsql_cb_logger, PGSQL_CB_INIT_OK);
 
     // Register PostgreSQL HB factories with Host Managers
@@ -87,8 +87,8 @@ int load(LibraryHandle& /* handle */) {
 /// @param handle callout handle passed to the callout.
 /// @return 0 on success, 1 otherwise.
 int dhcp4_srv_configured(CalloutHandle& /* handle */) {
-    isc::dhcp::PgSqlConfigBackendImpl::setIOService(IOServicePtr(new IOService()));
-    IOServiceMgr::instance().registerIOService(isc::dhcp::PgSqlConfigBackendImpl::getIOService());
+    PgSqlConfigBackendImpl::setIOService(IOServicePtr(new IOService()));
+    IOServiceMgr::instance().registerIOService(PgSqlConfigBackendImpl::getIOService());
     return (0);
 }
 
@@ -99,8 +99,8 @@ int dhcp4_srv_configured(CalloutHandle& /* handle */) {
 /// @param handle callout handle passed to the callout.
 /// @return 0 on success, 1 otherwise.
 int dhcp6_srv_configured(CalloutHandle& /* handle */) {
-    isc::dhcp::PgSqlConfigBackendImpl::setIOService(IOServicePtr(new IOService()));
-    IOServiceMgr::instance().registerIOService(isc::dhcp::PgSqlConfigBackendImpl::getIOService());
+    PgSqlConfigBackendImpl::setIOService(IOServicePtr(new IOService()));
+    IOServiceMgr::instance().registerIOService(PgSqlConfigBackendImpl::getIOService());
     return (0);
 }
 
@@ -109,13 +109,13 @@ int dhcp6_srv_configured(CalloutHandle& /* handle */) {
 /// @return 0 if deregistration was successful, 1 otherwise
 int unload() {
     // Unregister the factories and remove PostgreSQL backends
-    isc::dhcp::PgSqlConfigBackendDHCPv4::unregisterBackendType();
-    isc::dhcp::PgSqlConfigBackendDHCPv6::unregisterBackendType();
-    IOServicePtr io_service = isc::dhcp::PgSqlConfigBackendImpl::getIOService();
+    PgSqlConfigBackendDHCPv4::unregisterBackendType();
+    PgSqlConfigBackendDHCPv6::unregisterBackendType();
+    IOServicePtr io_service = PgSqlConfigBackendImpl::getIOService();
     if (io_service) {
         IOServiceMgr::instance().unregisterIOService(io_service);
         io_service->stopAndPoll();
-        isc::dhcp::PgSqlConfigBackendImpl::setIOService(IOServicePtr());
+        PgSqlConfigBackendImpl::setIOService(IOServicePtr());
     }
     LOG_INFO(pgsql_cb_logger, PGSQL_CB_DEINIT_OK);
 
index ccc16a8eff3ca3e587ff0744a5cb1d0097242101..55776b3e0a870308de0290ecad1c77a9708986e9 100644 (file)
@@ -7,7 +7,7 @@
 $NAMESPACE isc::dhcp
 
 % PGSQL_HB_DB opening PostgreSQL hosts database: %1
-Logged at debug log level 50.
+Logged at debug log level 40.
 This informational message is logged when a DHCP server (either V4 or
 V6) is about to open a PostgreSQL hosts database. The parameters of the
 connection including database name and username needed to access it
index e526212aaa8c5481d84e77475abbdaf1f03db446..a870ddb2a7e60e95557d02e472374bd25d383c56 100644 (file)
@@ -7,7 +7,7 @@
 $NAMESPACE isc::dhcp
 
 % PGSQL_LB_DB opening PostgreSQL lease database: %1
-Logged at debug log level 50.
+Logged at debug log level 40.
 This informational message is logged when a DHCP server (either V4 or
 V6) is about to open a PostgreSQL lease database. The parameters of the
 connection including database name and username needed to access it
index a876b60e13d149a2704822a010ffc6b92ae4674e..51c3d1cb85278651ec8966efd14a0d7f9c368fda 100644 (file)
@@ -1 +1,2 @@
-/pgsql_unittests
\ No newline at end of file
+/pgsql_unittests
+
index 593570716396ac84a59e590dafa5d73ba310b51a..7d15c41a676a781d7f04d45c6401af35c7ab8c43 100644 (file)
@@ -2,7 +2,7 @@ SUBDIRS = .
 
 AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
 AM_CPPFLAGS += -I$(top_builddir)/src/hooks/dhcp/pgsql -I$(top_srcdir)/src/hooks/dhcp/pgsql
-AM_CPPFLAGS += $(BOOST_INCLUDES) $(PGSQL_CPPFLAGS)
+AM_CPPFLAGS += $(BOOST_INCLUDES) $(PGSQL_CPPFLAGS) $(CRYPTO_CFLAGS) $(CRYPTO_INCLUDES)
 AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
 
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
index f2327097289db795465f997036bc0e935a969f5f..7c331647cb41a5a0108242bebe48f85f8449680d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021-2022 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2021-2024 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
index 475af5fd0ec37a6104e8a0daef76cee9fdf00d60..1165404e7193f28a6d89cad05641dbd58573c846 100644 (file)
@@ -3647,12 +3647,19 @@ LeaseMgrDbLostCallbackTest::testDbLostAndRecoveredCallback() {
     std::string access = validConnectString();
     CfgMgr::instance().getCurrentCfg()->getCfgDbAccess()->setLeaseDbAccessString(access);
 
+    // Find the most recently opened socket. Our SQL client's socket should
+    // be the next one.
+    int last_open_socket = findLastSocketFd();
+
+    // Fill holes.
+    FillFdHoles holes(last_open_socket);
+
     // Connect to the lease backend.
     ASSERT_NO_THROW(LeaseMgrFactory::create(access));
 
-    // The most recently opened socket should be for our SQL client.
-    int sql_socket = test::findLastSocketFd();
-    ASSERT_TRUE(sql_socket > -1);
+    // Find the SQL client socket.
+    int sql_socket = findLastSocketFd();
+    ASSERT_TRUE(sql_socket > last_open_socket);
 
     // Verify we can execute a query.  We do not care if
     // we find a lease or not.
@@ -3693,12 +3700,19 @@ LeaseMgrDbLostCallbackTest::testDbLostAndFailedCallback() {
     std::string access = validConnectString();
     CfgMgr::instance().getCurrentCfg()->getCfgDbAccess()->setLeaseDbAccessString(access);
 
+    // Find the most recently opened socket. Our SQL client's socket should
+    // be the next one.
+    int last_open_socket = findLastSocketFd();
+
+    // Fill holes.
+    FillFdHoles holes(last_open_socket);
+
     // Connect to the lease backend.
     ASSERT_NO_THROW(LeaseMgrFactory::create(access));
 
-    // The most recently opened socket should be for our SQL client.
-    int sql_socket = test::findLastSocketFd();
-    ASSERT_TRUE(sql_socket > -1);
+    // Find the SQL client socket.
+    int sql_socket = findLastSocketFd();
+    ASSERT_TRUE(sql_socket > last_open_socket);
 
     // Verify we can execute a query.  We do not care if
     // we find a lease or not.
@@ -3746,12 +3760,19 @@ LeaseMgrDbLostCallbackTest::testDbLostAndRecoveredAfterTimeoutCallback() {
     access += extra;
     CfgMgr::instance().getCurrentCfg()->getCfgDbAccess()->setLeaseDbAccessString(access);
 
+    // Find the most recently opened socket. Our SQL client's socket should
+    // be the next one.
+    int last_open_socket = findLastSocketFd();
+
+    // Fill holes.
+    FillFdHoles holes(last_open_socket);
+
     // Connect to the lease backend.
     ASSERT_NO_THROW(LeaseMgrFactory::create(access));
 
-    // The most recently opened socket should be for our SQL client.
-    int sql_socket = test::findLastSocketFd();
-    ASSERT_TRUE(sql_socket > -1);
+    // Find the SQL client socket.
+    int sql_socket = findLastSocketFd();
+    ASSERT_TRUE(sql_socket > last_open_socket);
 
     // Verify we can execute a query.  We do not care if
     // we find a lease or not.
@@ -3822,12 +3843,19 @@ LeaseMgrDbLostCallbackTest::testDbLostAndFailedAfterTimeoutCallback() {
     access += extra;
     CfgMgr::instance().getCurrentCfg()->getCfgDbAccess()->setLeaseDbAccessString(access);
 
+    // Find the most recently opened socket. Our SQL client's socket should
+    // be the next one.
+    int last_open_socket = findLastSocketFd();
+
+    // Fill holes.
+    FillFdHoles holes(last_open_socket);
+
     // Connect to the lease backend.
     ASSERT_NO_THROW(LeaseMgrFactory::create(access));
 
-    // The most recently opened socket should be for our SQL client.
-    int sql_socket = test::findLastSocketFd();
-    ASSERT_TRUE(sql_socket > -1);
+    // Find the SQL client socket.
+    int sql_socket = findLastSocketFd();
+    ASSERT_TRUE(sql_socket > last_open_socket);
 
     // Verify we can execute a query.  We do not care if
     // we find a lease or not.