2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[897-add-infinite-valid-lifetime-for-bootp] Reported previous changes

This commit is contained in:
Francis Dupont
2019-09-22 19:23:40 +02:00
parent b8c6f9988d
commit c2f06c48ae
16 changed files with 259 additions and 47 deletions

View File

@@ -174,7 +174,8 @@ tagged_statements = { {
"fqdn_fwd, fqdn_rev, hostname, "
"state, user_context "
"FROM lease4 "
"WHERE state != ? AND expire < ? "
"WHERE state != ? AND expire < ?"
" AND valid_lifetime != 4294967295 "
"ORDER BY expire ASC "
"LIMIT ?"},
{MySqlLeaseMgr::GET_LEASE6,
@@ -259,7 +260,8 @@ tagged_statements = { {
"hwaddr, hwtype, hwaddr_source, "
"state, user_context "
"FROM lease6 "
"WHERE state != ? AND expire < ? "
"WHERE state != ? AND expire < ?"
" AND valid_lifetime != 4294967295 "
"ORDER BY expire ASC "
"LIMIT ?"},
{MySqlLeaseMgr::INSERT_LEASE4,
@@ -557,7 +559,12 @@ public:
// expiry time (expire). The relationship is given by:
//
// expire = cltt_ + valid_lft_
MySqlConnection::convertToDatabaseTime(lease_->cltt_, lease_->valid_lft_,
// Avoid overflow
uint32_t valid_lft = lease_->valid_lft_;
if (valid_lft == Lease::INFINITY_LFT) {
valid_lft = 0;
}
MySqlConnection::convertToDatabaseTime(lease_->cltt_, valid_lft,
expire_);
bind_[4].buffer_type = MYSQL_TYPE_TIMESTAMP;
bind_[4].buffer = reinterpret_cast<char*>(&expire_);
@@ -762,7 +769,12 @@ public:
// Convert times received from the database to times for the lease
// structure
time_t cltt = 0;
MySqlConnection::convertFromDatabaseTime(expire_, valid_lifetime_, cltt);
// Recover from overflow
uint32_t valid_lft = valid_lifetime_;
if (valid_lft == Lease::INFINITY_LFT) {
valid_lft = 0;
}
MySqlConnection::convertFromDatabaseTime(expire_, valid_lft, cltt);
if (client_id_null_ == MLM_TRUE) {
// There's no client-id, so we pass client-id_length_ set to 0
@@ -989,7 +1001,12 @@ public:
/// expiry time (expire). The relationship is given by:
//
// expire = cltt_ + valid_lft_
MySqlConnection::convertToDatabaseTime(lease_->cltt_, lease_->valid_lft_,
// Avoid overflow
uint32_t valid_lft = lease_->valid_lft_;
if (valid_lft == Lease::INFINITY_LFT) {
valid_lft = 0;
}
MySqlConnection::convertToDatabaseTime(lease_->cltt_, valid_lft,
expire_);
bind_[3].buffer_type = MYSQL_TYPE_TIMESTAMP;
bind_[3].buffer = reinterpret_cast<char*>(&expire_);
@@ -1402,7 +1419,12 @@ public:
subnet_id_, fqdn_fwd_, fqdn_rev_,
hostname, hwaddr, prefixlen_));
time_t cltt = 0;
MySqlConnection::convertFromDatabaseTime(expire_, valid_lifetime_, cltt);
// Recover from overflow
uint32_t valid_lft = valid_lifetime_;
if (valid_lft == Lease::INFINITY_LFT) {
valid_lft = 0;
}
MySqlConnection::convertFromDatabaseTime(expire_, valid_lft, cltt);
result->cltt_ = cltt;
// Set state.