- :isccmd:`lease6-update` - updates (replaces) an existing IPv6 lease.
- :isccmd:`lease4-wipe` - removes all leases from a specific IPv4 subnet or
- from all subnets. This command is deprecated and it will be removed
- in the future.
+ from all subnets.
- :isccmd:`lease6-wipe` - removes all leases from a specific IPv6 subnet or
- from all subnets. This command is deprecated and it will be removed
- in the future.
+ from all subnets.
- :isccmd:`lease4-resend-ddns` - resends a request to update DNS entries for
an existing lease.
The ``lease4-wipe``, ``lease6-wipe`` Commands
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. warning::
-
- The :isccmd:`lease4-wipe` and :isccmd:`lease6-wipe` commands are deprecated
- and they will be removed in the future.
-
:isccmd:`lease4-wipe` and :isccmd:`lease6-wipe` are designed to remove all leases
associated with a given subnet. This administrative task is expected to
be used when an existing subnet is being retired. The leases
The ``subnet4-list`` Command
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-This command is used to list all currently configured subnets. Each
-subnet is returned with a subnet identifier and
-subnet prefix. To retrieve
-detailed information about the subnet, use the :isccmd:`subnet4-get` command.
+This command is used to list all currently configured subnets. Each subnet
+is returned with a subnet identifier, subnet prefix and shared network name,
+if available. To retrieve detailed information about the subnet, use the
+:isccmd:`subnet4-get` command.
This command has a simple structure:
The ``subnet6-list`` Command
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-This command is used to list all currently configured subnets. Each
-subnet is returned with a subnet identifier and
-subnet prefix. To retrieve
-detailed information about the subnet, use the :isccmd:`subnet6-get` command.
+This command is used to list all currently configured subnets. Each subnet
+is returned with a subnet identifier, subnet prefix and shared network name,
+if available. To retrieve detailed information about the subnet, use the
+:isccmd:`subnet6-get` command.
This command has a simple structure:
}
stringstream tmp;
- tmp << "Deleted " << num << " IPv4 lease(s) from subnet(s)" << ids.str()
- << " WARNING: lease4-wipe is deprecated!";
+ tmp << "Deleted " << num << " IPv4 lease(s) from subnet(s)" << ids.str();
ConstElementPtr response = createAnswer(num ? CONTROL_RESULT_SUCCESS
: CONTROL_RESULT_EMPTY, tmp.str());
setResponse(handle, response);
LOG_ERROR(lease_cmds_logger, LEASE_CMDS_WIPE4_FAILED)
.arg(cmd_args_ ? cmd_args_->str() : "<no args>")
.arg(ex.what());
- LOG_WARN(lease_cmds_logger, LEASE_CMDS_WIPE4_DEPRECATED);
setErrorResponse(handle, ex.what());
return (1);
}
LOG_INFO(lease_cmds_logger, LEASE_CMDS_WIPE4)
.arg(cmd_args_ ? cmd_args_->str() : "<no args>");
- LOG_WARN(lease_cmds_logger, LEASE_CMDS_WIPE4_DEPRECATED);
return (0);
}
}
stringstream tmp;
- tmp << "Deleted " << num << " IPv6 lease(s) from subnet(s)" << ids.str()
- << " WARNING: lease6-wipe is deprecated!";
+ tmp << "Deleted " << num << " IPv6 lease(s) from subnet(s)" << ids.str();
ConstElementPtr response = createAnswer(num ? CONTROL_RESULT_SUCCESS
: CONTROL_RESULT_EMPTY, tmp.str());
setResponse(handle, response);
LOG_ERROR(lease_cmds_logger, LEASE_CMDS_WIPE6_FAILED)
.arg(cmd_args_ ? cmd_args_->str() : "<no args>")
.arg(ex.what());
- LOG_WARN(lease_cmds_logger, LEASE_CMDS_WIPE6_DEPRECATED);
setErrorResponse(handle, ex.what());
return (1);
}
LOG_INFO(lease_cmds_logger, LEASE_CMDS_WIPE6)
.arg(cmd_args_ ? cmd_args_->str() : "<no args>");
- LOG_WARN(lease_cmds_logger, LEASE_CMDS_WIPE6_DEPRECATED);
return (0);
}
extern const isc::log::MessageID LEASE_CMDS_UPDATE6_CONFLICT = "LEASE_CMDS_UPDATE6_CONFLICT";
extern const isc::log::MessageID LEASE_CMDS_UPDATE6_FAILED = "LEASE_CMDS_UPDATE6_FAILED";
extern const isc::log::MessageID LEASE_CMDS_WIPE4 = "LEASE_CMDS_WIPE4";
-extern const isc::log::MessageID LEASE_CMDS_WIPE4_DEPRECATED = "LEASE_CMDS_WIPE4_DEPRECATED";
extern const isc::log::MessageID LEASE_CMDS_WIPE4_FAILED = "LEASE_CMDS_WIPE4_FAILED";
extern const isc::log::MessageID LEASE_CMDS_WIPE6 = "LEASE_CMDS_WIPE6";
-extern const isc::log::MessageID LEASE_CMDS_WIPE6_DEPRECATED = "LEASE_CMDS_WIPE6_DEPRECATED";
extern const isc::log::MessageID LEASE_CMDS_WIPE6_FAILED = "LEASE_CMDS_WIPE6_FAILED";
namespace {
"LEASE_CMDS_UPDATE6_CONFLICT", "lease6-update command failed due to conflict (parameters: %1, reason: %2)",
"LEASE_CMDS_UPDATE6_FAILED", "lease6-add command failed (parameters: %1, reason: %2)",
"LEASE_CMDS_WIPE4", "lease4-wipe command successful (parameters: %1)",
- "LEASE_CMDS_WIPE4_DEPRECATED", "lease4-wipe command is deprecated and it will be removed in the future.",
"LEASE_CMDS_WIPE4_FAILED", "lease4-wipe command failed (parameters: %1, reason: %2)",
"LEASE_CMDS_WIPE6", "lease6-wipe command successful (parameters: %1)",
- "LEASE_CMDS_WIPE6_DEPRECATED", "lease6-wipe command is deprecated and it will be removed in the future.",
"LEASE_CMDS_WIPE6_FAILED", "lease6-wipe command failed (parameters: %1, reason: %2)",
NULL
};
extern const isc::log::MessageID LEASE_CMDS_UPDATE6_CONFLICT;
extern const isc::log::MessageID LEASE_CMDS_UPDATE6_FAILED;
extern const isc::log::MessageID LEASE_CMDS_WIPE4;
-extern const isc::log::MessageID LEASE_CMDS_WIPE4_DEPRECATED;
extern const isc::log::MessageID LEASE_CMDS_WIPE4_FAILED;
extern const isc::log::MessageID LEASE_CMDS_WIPE6;
-extern const isc::log::MessageID LEASE_CMDS_WIPE6_DEPRECATED;
extern const isc::log::MessageID LEASE_CMDS_WIPE6_FAILED;
#endif // LEASE_CMDS_MESSAGES_H
The lease4-wipe command has been successful. Parameters of the command
are logged.
-% LEASE_CMDS_WIPE4_DEPRECATED lease4-wipe command is deprecated and it will be removed in the future.
-The lease4-wipe command is deprecated and it will be removed in the future.
-
% LEASE_CMDS_WIPE4_FAILED lease4-wipe command failed (parameters: %1, reason: %2)
The lease4-wipe command has failed. Both the reason as well as the
parameters passed are logged.
The lease6-wipe command has been successful. Parameters of the command
are logged.
-% LEASE_CMDS_WIPE6_DEPRECATED lease6-wipe command is deprecated and it will be removed in the future.
-The lease6-wipe command is deprecated and it will be removed in the future.
-
% LEASE_CMDS_WIPE6_FAILED lease6-wipe command failed (parameters: %1, reason: %2)
The lease6-wipe command has failed. Both the reason as well as the
parameters passed are logged.
" \"subnet-id\": 44"
" }\n"
"}";
- string exp_rsp = "Deleted 2 IPv4 lease(s) from subnet(s) 44"
- " WARNING: lease4-wipe is deprecated!";
+ string exp_rsp = "Deleted 2 IPv4 lease(s) from subnet(s) 44";
// The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
" \"subnet-id\": 0"
" }\n"
"}";
- string exp_rsp = "Deleted 4 IPv4 lease(s) from subnet(s) 44 88"
- " WARNING: lease4-wipe is deprecated!";
+ string exp_rsp = "Deleted 4 IPv4 lease(s) from subnet(s) 44 88";
// The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
"{\n"
" \"command\": \"lease4-wipe\"\n"
"}";
- string exp_rsp = "Deleted 4 IPv4 lease(s) from subnet(s) 44 88"
- " WARNING: lease4-wipe is deprecated!";
+ string exp_rsp = "Deleted 4 IPv4 lease(s) from subnet(s) 44 88";
// The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
" \"subnet-id\": 44"
" }\n"
"}";
- string exp_rsp = "Deleted 0 IPv4 lease(s) from subnet(s) 44"
- " WARNING: lease4-wipe is deprecated!";
+ string exp_rsp = "Deleted 0 IPv4 lease(s) from subnet(s) 44";
testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
checkLease4Stats(44, 0, 0);
" \"subnet-id\": 0"
" }\n"
"}";
- string exp_rsp = "Deleted 0 IPv4 lease(s) from subnet(s) 44 88"
- " WARNING: lease4-wipe is deprecated!";
+ string exp_rsp = "Deleted 0 IPv4 lease(s) from subnet(s) 44 88";
testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
checkLease4Stats(44, 0, 0);
" \"subnet-id\": 66\n"
" }\n"
"}";
- string exp_rsp = "Deleted 2 IPv6 lease(s) from subnet(s) 66"
- " WARNING: lease6-wipe is deprecated!";
+ string exp_rsp = "Deleted 2 IPv6 lease(s) from subnet(s) 66";
// The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
" \"subnet-id\": 0\n"
" }\n"
"}";
- string exp_rsp = "Deleted 4 IPv6 lease(s) from subnet(s) 66 99"
- " WARNING: lease6-wipe is deprecated!";
+ string exp_rsp = "Deleted 4 IPv6 lease(s) from subnet(s) 66 99";
// The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
"{\n"
" \"command\": \"lease6-wipe\"\n"
"}";
- string exp_rsp = "Deleted 4 IPv6 lease(s) from subnet(s) 66 99"
- " WARNING: lease6-wipe is deprecated!";
+ string exp_rsp = "Deleted 4 IPv6 lease(s) from subnet(s) 66 99";
// The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
" \"subnet-id\": 66"
" }\n"
"}";
- string exp_rsp = "Deleted 0 IPv6 lease(s) from subnet(s) 66"
- " WARNING: lease6-wipe is deprecated!";
+ string exp_rsp = "Deleted 0 IPv6 lease(s) from subnet(s) 66";
testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
checkLease6Stats(66, 0, 0, 0, 0);
" \"subnet-id\": 0"
" }\n"
"}";
- string exp_rsp = "Deleted 0 IPv6 lease(s) from subnet(s) 66 99"
- " WARNING: lease6-wipe is deprecated!";
+ string exp_rsp = "Deleted 0 IPv6 lease(s) from subnet(s) 66 99";
testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
checkLease6Stats(66, 0, 0, 0, 0);
-// File created from src/hooks/dhcp/mysql/mysql_lb_messages.mes
+// File created from ../src/hooks/dhcp/mysql/mysql_lb_messages.mes
#include <cstddef>
#include <log/message_types.h>
extern const isc::log::MessageID MYSQL_LB_DB_RECONNECT_ATTEMPT_SCHEDULE = "MYSQL_LB_DB_RECONNECT_ATTEMPT_SCHEDULE";
extern const isc::log::MessageID MYSQL_LB_DB_RECONNECT_FAILED = "MYSQL_LB_DB_RECONNECT_FAILED";
extern const isc::log::MessageID MYSQL_LB_DELETED_EXPIRED_RECLAIMED = "MYSQL_LB_DELETED_EXPIRED_RECLAIMED";
+extern const isc::log::MessageID MYSQL_LB_DELETED_SUBNET4_ID = "MYSQL_LB_DELETED_SUBNET4_ID";
+extern const isc::log::MessageID MYSQL_LB_DELETED_SUBNET6_ID = "MYSQL_LB_DELETED_SUBNET6_ID";
extern const isc::log::MessageID MYSQL_LB_DELETE_ADDR4 = "MYSQL_LB_DELETE_ADDR4";
extern const isc::log::MessageID MYSQL_LB_DELETE_ADDR6 = "MYSQL_LB_DELETE_ADDR6";
extern const isc::log::MessageID MYSQL_LB_DELETE_EXPIRED_RECLAIMED4 = "MYSQL_LB_DELETE_EXPIRED_RECLAIMED4";
"MYSQL_LB_DB_RECONNECT_ATTEMPT_SCHEDULE", "scheduling attempt %1 of %2 in %3 milliseconds",
"MYSQL_LB_DB_RECONNECT_FAILED", "maximum number of database reconnect attempts: %1, has been exhausted without success",
"MYSQL_LB_DELETED_EXPIRED_RECLAIMED", "deleted %1 reclaimed leases from the database",
+ "MYSQL_LB_DELETED_SUBNET4_ID", "deleted %1 leases that match Subnet ID %2.",
+ "MYSQL_LB_DELETED_SUBNET6_ID", "deleted %1 leases that match Subnet ID %2.",
"MYSQL_LB_DELETE_ADDR4", "deleting lease for address %1",
"MYSQL_LB_DELETE_ADDR6", "deleting lease for address %1",
"MYSQL_LB_DELETE_EXPIRED_RECLAIMED4", "deleting reclaimed IPv4 leases that expired more than %1 seconds ago",
-// File created from src/hooks/dhcp/mysql/mysql_lb_messages.mes
+// File created from ../src/hooks/dhcp/mysql/mysql_lb_messages.mes
#ifndef MYSQL_LB_MESSAGES_H
#define MYSQL_LB_MESSAGES_H
extern const isc::log::MessageID MYSQL_LB_DB_RECONNECT_ATTEMPT_SCHEDULE;
extern const isc::log::MessageID MYSQL_LB_DB_RECONNECT_FAILED;
extern const isc::log::MessageID MYSQL_LB_DELETED_EXPIRED_RECLAIMED;
+extern const isc::log::MessageID MYSQL_LB_DELETED_SUBNET4_ID;
+extern const isc::log::MessageID MYSQL_LB_DELETED_SUBNET6_ID;
extern const isc::log::MessageID MYSQL_LB_DELETE_ADDR4;
extern const isc::log::MessageID MYSQL_LB_DELETE_ADDR6;
extern const isc::log::MessageID MYSQL_LB_DELETE_EXPIRED_RECLAIMED4;
The argument is the amount of time Kea waits after a reclaimed
lease expires before considering its removal.
+% MYSQL_LB_DELETED_SUBNET4_ID deleted %1 leases that match Subnet ID %2.
+Logged at debug log level 50.
+A debug message issued when the server is removing leases which match
+respective Subnet ID.
+
+% MYSQL_LB_DELETED_SUBNET6_ID deleted %1 leases that match Subnet ID %2.
+Logged at debug log level 50.
+A debug message issued when the server is removing leases which match
+respective Subnet ID.
+
% MYSQL_LB_GET4 obtaining all IPv4 leases
Logged at debug log level 50.
A debug message issued when the server is attempting to obtain all IPv4
tagged_statements = { {
{MySqlLeaseMgr::DELETE_LEASE4,
"DELETE FROM lease4 WHERE address = ? AND expire = ?"},
+ {MySqlLeaseMgr::DELETE_LEASE4_SUBID,
+ "DELETE FROM lease4 WHERE subnet_id = ?"},
{MySqlLeaseMgr::DELETE_LEASE4_STATE_EXPIRED,
"DELETE FROM lease4 "
"WHERE state = ? AND expire < ?"},
{MySqlLeaseMgr::DELETE_LEASE6,
"DELETE FROM lease6 WHERE address = ? AND expire = ?"},
+ {MySqlLeaseMgr::DELETE_LEASE6_SUBID,
+ "DELETE FROM lease6 WHERE subnet_id = ?"},
{MySqlLeaseMgr::DELETE_LEASE6_STATE_EXPIRED,
"DELETE FROM lease6 "
"WHERE state = ? AND expire < ?"},
}
size_t
-MySqlLeaseMgr::wipeLeases4(const SubnetID& /*subnet_id*/) {
- isc_throw(NotImplemented, "wipeLeases4 is not implemented for MySQL backend");
+MySqlLeaseMgr::wipeLeasesCommon(const SubnetID& subnet_id, StatementIndex statement_index) {
+ // Set up the WHERE clause value
+ MYSQL_BIND inbind[1];
+ memset(inbind, 0, sizeof(inbind));
+
+ // Subnet ID.
+ uint32_t subnet = static_cast<uint32_t>(subnet_id);
+ inbind[0].buffer_type = MYSQL_TYPE_LONG;
+ inbind[0].buffer = reinterpret_cast<char*>(&subnet);
+ inbind[0].is_unsigned = MLM_TRUE;
+
+ // Get a context
+ MySqlLeaseContextAlloc get_context(*this);
+ MySqlLeaseContextPtr ctx = get_context.ctx_;
+
+ // Get the number of deleted leases and log it.
+ return (deleteLeaseCommon(ctx, statement_index, inbind));
+}
+
+size_t
+MySqlLeaseMgr::wipeLeases4(const SubnetID& subnet_id) {
+ uint64_t deleted_leases = wipeLeasesCommon(subnet_id, DELETE_LEASE4_SUBID);
+ LOG_DEBUG(mysql_lb_logger, MYSQL_LB_DBG_TRACE_DETAIL, MYSQL_LB_DELETED_SUBNET4_ID)
+ .arg(deleted_leases).arg(subnet_id);
+ return (deleted_leases);
}
size_t
-MySqlLeaseMgr::wipeLeases6(const SubnetID& /*subnet_id*/) {
- isc_throw(NotImplemented, "wipeLeases6 is not implemented for MySQL backend");
+MySqlLeaseMgr::wipeLeases6(const SubnetID& subnet_id) {
+ uint64_t deleted_leases = wipeLeasesCommon(subnet_id, DELETE_LEASE6_SUBID);
+ LOG_DEBUG(mysql_lb_logger, MYSQL_LB_DBG_TRACE_DETAIL, MYSQL_LB_DELETED_SUBNET6_ID)
+ .arg(deleted_leases).arg(subnet_id);;
+ return (deleted_leases);
}
// Miscellaneous database methods.
/// statements
enum StatementIndex {
DELETE_LEASE4, // Delete from lease4 by address
+ DELETE_LEASE4_SUBID, // Delete from lease4 by subnet ID
DELETE_LEASE4_STATE_EXPIRED, // Delete expired lease4 in a given state
DELETE_LEASE6, // Delete from lease6 by address
+ DELETE_LEASE6_SUBID, // Delete from lease6 by subnet ID
DELETE_LEASE6_STATE_EXPIRED, // Delete expired lease6 in a given state
GET_LEASE4, // Get all IPv4 leases
GET_LEASE4_ADDR, // Get lease4 by address
StatementIndex stindex,
MYSQL_BIND* bind);
+ /// @brief Removes all leases matching subnet ID.
+ ///
+ /// This rather dangerous method is able to remove all leases from specified
+ /// subnet.
+ ///
+ /// @param subnet_id identifier of the subnet
+ /// @param statement_index One of the @c DELETE_LEASE4_SUBID or
+ /// @c DELETE_LEASE6_SUBID.
+ /// @return number of leases removed.
+ virtual size_t wipeLeasesCommon(const SubnetID& subnet_id, StatementIndex statement_index);
+
/// @brief Delete expired-reclaimed leases.
///
/// @param secs Number of seconds since expiration of leases before
}
/// @brief Tests that leases from specific subnet can be removed.
-TEST_F(MySqlLeaseMgrTest, DISABLED_wipeLeases4) {
+TEST_F(MySqlLeaseMgrTest, wipeLeases4) {
testWipeLeases4();
}
/// @brief Tests that leases from specific subnet can be removed.
-TEST_F(MySqlLeaseMgrTest, DISABLED_wipeLeases4MultiThreading) {
+TEST_F(MySqlLeaseMgrTest, wipeLeases4MultiThreading) {
MultiThreadingTest mt(true);
testWipeLeases4();
}
/// @brief Tests that leases from specific subnet can be removed.
-TEST_F(MySqlLeaseMgrTest, DISABLED_wipeLeases6) {
+TEST_F(MySqlLeaseMgrTest, wipeLeases6) {
testWipeLeases6();
}
/// @brief Tests that leases from specific subnet can be removed.
-TEST_F(MySqlLeaseMgrTest, DISABLED_wipeLeases6MultiThreading) {
+TEST_F(MySqlLeaseMgrTest, wipeLeases6MultiThreading) {
MultiThreadingTest mt(true);
testWipeLeases6();
}
-// File created from src/hooks/dhcp/pgsql/pgsql_lb_messages.mes
+// File created from ../src/hooks/dhcp/pgsql/pgsql_lb_messages.mes
#include <cstddef>
#include <log/message_types.h>
extern const isc::log::MessageID PGSQL_LB_DB_RECONNECT_ATTEMPT_FAILED = "PGSQL_LB_DB_RECONNECT_ATTEMPT_FAILED";
extern const isc::log::MessageID PGSQL_LB_DB_RECONNECT_ATTEMPT_SCHEDULE = "PGSQL_LB_DB_RECONNECT_ATTEMPT_SCHEDULE";
extern const isc::log::MessageID PGSQL_LB_DB_RECONNECT_FAILED = "PGSQL_LB_DB_RECONNECT_FAILED";
+extern const isc::log::MessageID PGSQL_LB_DELETED_SUBNET4_ID = "PGSQL_LB_DELETED_SUBNET4_ID";
+extern const isc::log::MessageID PGSQL_LB_DELETED_SUBNET6_ID = "PGSQL_LB_DELETED_SUBNET6_ID";
extern const isc::log::MessageID PGSQL_LB_DELETE_ADDR4 = "PGSQL_LB_DELETE_ADDR4";
extern const isc::log::MessageID PGSQL_LB_DELETE_ADDR6 = "PGSQL_LB_DELETE_ADDR6";
extern const isc::log::MessageID PGSQL_LB_DELETE_EXPIRED_RECLAIMED4 = "PGSQL_LB_DELETE_EXPIRED_RECLAIMED4";
"PGSQL_LB_DB_RECONNECT_ATTEMPT_FAILED", "database reconnect failed: %1",
"PGSQL_LB_DB_RECONNECT_ATTEMPT_SCHEDULE", "scheduling attempt %1 of %2 in %3 milliseconds",
"PGSQL_LB_DB_RECONNECT_FAILED", "maximum number of database reconnect attempts: %1, has been exhausted without success",
+ "PGSQL_LB_DELETED_SUBNET4_ID", "deleted %1 leases that match Subnet ID %2.",
+ "PGSQL_LB_DELETED_SUBNET6_ID", "deleted %1 leases that match Subnet ID %2.",
"PGSQL_LB_DELETE_ADDR4", "deleting lease for address %1",
"PGSQL_LB_DELETE_ADDR6", "deleting lease for address %1",
"PGSQL_LB_DELETE_EXPIRED_RECLAIMED4", "deleting reclaimed IPv4 leases that expired more than %1 seconds ago",
-// File created from src/hooks/dhcp/pgsql/pgsql_lb_messages.mes
+// File created from ../src/hooks/dhcp/pgsql/pgsql_lb_messages.mes
#ifndef PGSQL_LB_MESSAGES_H
#define PGSQL_LB_MESSAGES_H
extern const isc::log::MessageID PGSQL_LB_DB_RECONNECT_ATTEMPT_FAILED;
extern const isc::log::MessageID PGSQL_LB_DB_RECONNECT_ATTEMPT_SCHEDULE;
extern const isc::log::MessageID PGSQL_LB_DB_RECONNECT_FAILED;
+extern const isc::log::MessageID PGSQL_LB_DELETED_SUBNET4_ID;
+extern const isc::log::MessageID PGSQL_LB_DELETED_SUBNET6_ID;
extern const isc::log::MessageID PGSQL_LB_DELETE_ADDR4;
extern const isc::log::MessageID PGSQL_LB_DELETE_ADDR6;
extern const isc::log::MessageID PGSQL_LB_DELETE_EXPIRED_RECLAIMED4;
The argument is the amount of time Kea waits after a reclaimed
lease expires before considering its removal.
+% PGSQL_LB_DELETED_SUBNET4_ID deleted %1 leases that match Subnet ID %2.
+Logged at debug log level 50.
+A debug message issued when the server is removing leases which match
+respective Subnet ID.
+
+% PGSQL_LB_DELETED_SUBNET6_ID deleted %1 leases that match Subnet ID %2.
+Logged at debug log level 50.
+A debug message issued when the server is removing leases which match
+respective Subnet ID.
+
% PGSQL_LB_GET4 obtaining all IPv4 leases
Logged at debug log level 50.
A debug message issued when the server is attempting to obtain all IPv4
"delete_lease4",
"DELETE FROM lease4 WHERE address = $1 AND expire = $2" },
+ // DELETE_LEASE4_SUBID
+ { 1, { OID_INT8 },
+ "delete_lease4_subid",
+ "DELETE FROM lease4 WHERE subnet_id = $1" },
+
// DELETE_LEASE4_STATE_EXPIRED
{ 2, { OID_INT8, OID_TIMESTAMP },
"delete_lease4_state_expired",
// DELETE_LEASE6
{ 2, { OID_VARCHAR, OID_TIMESTAMP },
"delete_lease6",
- "DELETE FROM lease6 WHERE address = cast($1 as inet) AND expire = $2"},
+ "DELETE FROM lease6 WHERE address = cast($1 as inet) AND expire = $2" },
+
+ // DELETE_LEASE6_SUBID
+ { 1, { OID_INT8 },
+ "delete_lease6_subid",
+ "DELETE FROM lease6 WHERE subnet_id = $1" },
// DELETE_LEASE6_STATE_EXPIRED
{ 2, { OID_INT8, OID_TIMESTAMP },
"hwaddr, hwtype, hwaddr_source, "
"state, user_context, pool_id "
"FROM lease6 "
- "ORDER BY address "},
+ "ORDER BY address" },
// GET_LEASE6_ADDR
{ 2, { OID_VARCHAR, OID_INT2 },
"hwaddr, hwtype, hwaddr_source, "
"state, user_context, pool_id "
"FROM lease6 "
- "WHERE address = cast($1 as inet) AND lease_type = $2"},
+ "WHERE address = cast($1 as inet) AND lease_type = $2" },
// GET_LEASE6_DUID_IAID
{ 3, { OID_BYTEA, OID_INT8, OID_INT2 },
"FROM lease6 "
"WHERE address > cast($1 as inet) "
"ORDER BY address "
- "LIMIT $2"},
+ "LIMIT $2" },
// GET_LEASE6_UCTX_PAGE
{ 2, { OID_VARCHAR, OID_INT8 },
}
size_t
-PgSqlLeaseMgr::wipeLeases4(const SubnetID& /*subnet_id*/) {
- isc_throw(NotImplemented, "wipeLeases4 is not implemented for PostgreSQL backend");
+PgSqlLeaseMgr::wipeLeasesCommon(const SubnetID& subnet_id, StatementIndex statement_index) {
+ PsqlBindArray bind_array;
+
+ // Subnet ID.
+ std::string subnet_str = boost::lexical_cast<std::string>(subnet_id);
+ bind_array.add(subnet_str);
+
+ // Get a context
+ PgSqlLeaseContextAlloc get_context(*this);
+ PgSqlLeaseContextPtr ctx = get_context.ctx_;
+
+ // Delete leases.
+ return (deleteLeaseCommon(ctx, statement_index, bind_array));
+}
+
+size_t
+PgSqlLeaseMgr::wipeLeases4(const SubnetID& subnet_id) {
+ uint64_t deleted_leases = wipeLeasesCommon(subnet_id, DELETE_LEASE4_SUBID);
+ LOG_DEBUG(pgsql_lb_logger, PGSQL_LB_DBG_TRACE_DETAIL, PGSQL_LB_DELETED_SUBNET4_ID)
+ .arg(deleted_leases).arg(subnet_id);
+ return (deleted_leases);
}
size_t
-PgSqlLeaseMgr::wipeLeases6(const SubnetID& /*subnet_id*/) {
- isc_throw(NotImplemented, "wipeLeases6 is not implemented for PostgreSQL backend");
+PgSqlLeaseMgr::wipeLeases6(const SubnetID& subnet_id) {
+ uint64_t deleted_leases = wipeLeasesCommon(subnet_id, DELETE_LEASE6_SUBID);
+ LOG_DEBUG(pgsql_lb_logger, PGSQL_LB_DBG_TRACE_DETAIL, PGSQL_LB_DELETED_SUBNET6_ID)
+ .arg(deleted_leases).arg(subnet_id);
+ return (deleted_leases);
}
std::string
/// statements
enum StatementIndex {
DELETE_LEASE4, // Delete from lease4 by address
+ DELETE_LEASE4_SUBID, // Delete from lease4 by subnet ID
DELETE_LEASE4_STATE_EXPIRED, // Delete expired lease4 in a given state
DELETE_LEASE6, // Delete from lease6 by address
+ DELETE_LEASE6_SUBID, // Delete from lease6 by subnet ID
DELETE_LEASE6_STATE_EXPIRED, // Delete expired lease6 in a given state
GET_LEASE4, // Get all IPv4 leases
GET_LEASE4_ADDR, // Get lease4 by address
StatementIndex stindex,
db::PsqlBindArray& bind_array);
+ /// @brief Removes all leases matching subnet ID.
+ ///
+ /// This rather dangerous method is able to remove all leases from specified
+ /// subnet.
+ ///
+ /// @param subnet_id identifier of the subnet
+ /// @param statement_index One of the @c DELETE_LEASE4_SUBID or
+ /// @c DELETE_LEASE6_SUBID.
+ /// @return number of leases removed.
+ virtual size_t wipeLeasesCommon(const SubnetID& subnet_id, StatementIndex statement_index);
+
/// @brief Delete expired-reclaimed leases.
///
/// @param secs Number of seconds since expiration of leases before
}
/// @brief Tests that leases from specific subnet can be removed.
-TEST_F(PgSqlLeaseMgrTest, DISABLED_wipeLeases4) {
+TEST_F(PgSqlLeaseMgrTest, wipeLeases4) {
testWipeLeases4();
}
/// @brief Tests that leases from specific subnet can be removed.
-TEST_F(PgSqlLeaseMgrTest, DISABLED_wipeLeases4MultiThreading) {
+TEST_F(PgSqlLeaseMgrTest, wipeLeases4MultiThreading) {
MultiThreadingTest mt(true);
testWipeLeases4();
}
/// @brief Tests that leases from specific subnet can be removed.
-TEST_F(PgSqlLeaseMgrTest, DISABLED_wipeLeases6) {
+TEST_F(PgSqlLeaseMgrTest, wipeLeases6) {
testWipeLeases6();
}
/// @brief Tests that leases from specific subnet can be removed.
-TEST_F(PgSqlLeaseMgrTest, DISABLED_wipeLeases6MultiThreading) {
+TEST_F(PgSqlLeaseMgrTest, wipeLeases6MultiThreading) {
MultiThreadingTest mt(true);
testWipeLeases6();
}
% SUBNET_CMDS_SUBNET6_LIST_FAILED failed to return a list of IPv6 subnets: %1
This error message is issued when the Subnet Commands hooks library fails
-to return a list of IPv4 subnets requested with 'subnet6-list' command. The
+to return a list of IPv6 subnets requested with 'subnet6-list' command. The
reason for failure is provided within the error message. The error message
will be returned to the controlling client with the error status code.
"access": "write",
"avail": "1.3.0",
"brief": [
- "This command removes all leases associated with a given subnet.",
- "This command is deprecated and it will be removed in the future."
+ "This command removes all leases associated with a given subnet."
],
"cmd-syntax": [
"{",
"access": "write",
"avail": "1.3.0",
"brief": [
- "This command removes all leases associated with a given subnet.",
- "This command is deprecated and it will be removed in the future."
+ "This command removes all leases associated with a given subnet."
],
"cmd-comment": [
"Note: not all backends support this command."