summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2023-05-25 01:38:11 +0200
committerFrancis Dupont <fdupont@isc.org>2023-07-06 22:11:32 +0200
commit5415988d923e33502ab5016a1ad6776916e0ed02 (patch)
tree5acdff514d11ba18a7e3d74d154935909c18f063 /src
parent[#2869] Added count statements (diff)
downloadkea-5415988d923e33502ab5016a1ad6776916e0ed02.tar.xz
kea-5415988d923e33502ab5016a1ad6776916e0ed02.zip
[#2869] Implemented wipeExtendedInfoTables6
Diffstat (limited to 'src')
-rw-r--r--src/lib/dhcpsrv/lease_mgr.h3
-rw-r--r--src/lib/dhcpsrv/memfile_lease_mgr.cc12
-rw-r--r--src/lib/dhcpsrv/memfile_lease_mgr.h3
-rw-r--r--src/lib/dhcpsrv/mysql_lease_mgr.cc19
-rw-r--r--src/lib/dhcpsrv/mysql_lease_mgr.h3
-rw-r--r--src/lib/dhcpsrv/pgsql_lease_mgr.cc19
-rw-r--r--src/lib/dhcpsrv/pgsql_lease_mgr.h3
-rw-r--r--src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc5
-rw-r--r--src/lib/dhcpsrv/testutils/concrete_lease_mgr.h4
9 files changed, 71 insertions, 0 deletions
diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h
index 4b5ea99007..e372d04b7b 100644
--- a/src/lib/dhcpsrv/lease_mgr.h
+++ b/src/lib/dhcpsrv/lease_mgr.h
@@ -1040,6 +1040,9 @@ public:
/// @return The number of updates in the database or 0.
virtual size_t buildExtendedInfoTables6(bool update, bool current) = 0;
+ /// @brief Wipe extended info table (v6).
+ virtual void wipeExtendedInfoTables6() = 0;
+
protected:
/// Extended information / Bulk Lease Query shared interface.
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc
index 1914cf3e77..dbb39dfcf6 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.cc
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc
@@ -3039,6 +3039,18 @@ Memfile_LeaseMgr::getLeases4ByRemoteIdInternal(const OptionBuffer& remote_id,
return (collection);
}
+void
+Memfile_LeaseMgr::wipeExtendedInfoTables6() {
+ if (MultiThreadingMgr::instance().getMode()) {
+ std::lock_guard<std::mutex> lock(*mutex_);
+ relay_id6_.clear();
+ remote_id6_.clear();
+ } else {
+ relay_id6_.clear();
+ remote_id6_.clear();
+ }
+}
+
Lease6Collection
Memfile_LeaseMgr::getLeases6ByRelayId(const DUID& relay_id,
const IOAddress& link_addr,
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.h b/src/lib/dhcpsrv/memfile_lease_mgr.h
index d7ae5e2093..21805cb515 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.h
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.h
@@ -1424,6 +1424,9 @@ public:
/// @return The number of updates in the database or 0.
virtual size_t buildExtendedInfoTables6(bool update, bool current) override;
+ /// @brief Wipe extended info table (v6).
+ virtual void wipeExtendedInfoTables6() override;
+
private:
/// @brief Returns existing IPv4 leases with a given relay-id.
diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc
index e3fff0cffd..48e7f6d273 100644
--- a/src/lib/dhcpsrv/mysql_lease_mgr.cc
+++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc
@@ -4270,5 +4270,24 @@ MySqlLeaseMgr::buildExtendedInfoTables6(bool /* update */, bool /* current */) {
"MySqlLeaseMgr::buildExtendedInfoTables6 not implemented");
}
+void
+MySqlLeaseMgr::wipeExtendedInfoTables6() {
+ // Get a context
+ MySqlLeaseContextAlloc get_context(*this);
+ MySqlLeaseContextPtr ctx = get_context.ctx_;
+
+ StatementIndex stindex = WIPE_RELAY_ID6;
+ int status = MysqlExecuteStatement(ctx->conn_.statements_[stindex]);
+ if (status != 0) {
+ checkError(ctx, status, stindex, "unable to execute");
+ }
+
+ stindex = WIPE_REMOTE_ID6;
+ status = MysqlExecuteStatement(ctx->conn_.statements_[stindex]);
+ if (status != 0) {
+ checkError(ctx, status, stindex, "unable to execute");
+ }
+}
+
} // namespace dhcp
} // namespace isc
diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h
index 3f1aedd0e3..5472db03c4 100644
--- a/src/lib/dhcpsrv/mysql_lease_mgr.h
+++ b/src/lib/dhcpsrv/mysql_lease_mgr.h
@@ -1183,6 +1183,9 @@ private:
/// @return The number of updates in the database or 0.
virtual size_t buildExtendedInfoTables6(bool update, bool current) override;
+ /// @brief Wipe by-relay-id table (v6).
+ virtual void wipeExtendedInfoTables6() override;
+
/// @brief Context RAII allocator.
class MySqlLeaseContextAlloc {
public:
diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc
index 994a39dbea..a0c2f67167 100644
--- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc
+++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc
@@ -3372,5 +3372,24 @@ PgSqlLeaseMgr::buildExtendedInfoTables6(bool /* update */, bool /* current */) {
"PgSqlLeaseMgr::buildExtendedInfoTables6 not implemented");
}
+void
+PgSqlLeaseMgr::wipeExtendedInfoTables6() {
+ // Get a context.
+ PgSqlLeaseContextAlloc get_context(*this);
+ PgSqlLeaseContextPtr ctx(get_context.ctx_);
+
+ // Execute WIPE_RELAY_ID6.
+ StatementIndex const stindex1 = WIPE_RELAY_ID6;
+ PgSqlResult r1(PQexecPrepared(ctx->conn_, tagged_statements[stindex1].name,
+ 0, 0, 0, 0, 0));
+ ctx->conn_.checkStatementError(r1, tagged_statements[stindex1]);
+
+ // Execute WIPE_REMOTE_ID6.
+ StatementIndex const stindex2 = WIPE_REMOTE_ID6;
+ PgSqlResult r2(PQexecPrepared(ctx->conn_, tagged_statements[stindex2].name,
+ 0, 0, 0, 0, 0));
+ ctx->conn_.checkStatementError(r2, tagged_statements[stindex2]);
+}
+
} // namespace dhcp
} // namespace isc
diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.h b/src/lib/dhcpsrv/pgsql_lease_mgr.h
index 7903af75aa..b94de61494 100644
--- a/src/lib/dhcpsrv/pgsql_lease_mgr.h
+++ b/src/lib/dhcpsrv/pgsql_lease_mgr.h
@@ -1137,6 +1137,9 @@ private:
/// @return The number of updates in the database or 0.
virtual size_t buildExtendedInfoTables6(bool update, bool current) override;
+ /// @brief Wipe extended info table (v6).
+ virtual void wipeExtendedInfoTables6() override;
+
/// @brief Write V4 leases to a file.
virtual void writeLeases4(const std::string& /*filename*/) override;
diff --git a/src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc b/src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc
index b24b404bb7..7731e7ffd0 100644
--- a/src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc
+++ b/src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc
@@ -303,6 +303,11 @@ ConcreteLeaseMgr::buildExtendedInfoTables6(bool /* update */,
}
void
+ConcreteLeaseMgr::wipeExtendedInfoTables6() {
+ isc_throw(NotImplemented, "ConcreteLeaseMgr::wipeExtendedInfoTables6() not implemented");
+}
+
+void
ConcreteLeaseMgr::writeLeases4(const std::string&) {
isc_throw(NotImplemented, "ConcreteLeaseMgr::writeLeases4() not implemented");
}
diff --git a/src/lib/dhcpsrv/testutils/concrete_lease_mgr.h b/src/lib/dhcpsrv/testutils/concrete_lease_mgr.h
index 53956dc20a..9b5c76ecae 100644
--- a/src/lib/dhcpsrv/testutils/concrete_lease_mgr.h
+++ b/src/lib/dhcpsrv/testutils/concrete_lease_mgr.h
@@ -385,6 +385,10 @@ public:
virtual size_t buildExtendedInfoTables6(bool /* update */,
bool /* current */) override;
+ /// @brief Stub implementation.
+ virtual void
+ wipeExtendedInfoTables6() override;
+
/// @brief Pretends to write V4 leases to a file.
virtual void writeLeases4(const std::string&) override;