2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-02 23:15:20 +00:00

[#3149] Rewrote getLeases6ByLink

This commit is contained in:
Francis Dupont
2023-12-14 15:21:15 +01:00
parent d73fc1466d
commit 032a8ad465
14 changed files with 104 additions and 188 deletions

View File

@@ -400,7 +400,7 @@ const char* values[] = {
"DHCPSRV_MEMFILE_GET_HWADDR", "obtaining IPv4 leases for hardware address %1",
"DHCPSRV_MEMFILE_GET_IAID_DUID", "obtaining IPv6 leases for IAID %1 and DUID %2 and lease type %3",
"DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID", "obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3 and lease type %4",
"DHCPSRV_MEMFILE_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3/%4",
"DHCPSRV_MEMFILE_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3",
"DHCPSRV_MEMFILE_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
"DHCPSRV_MEMFILE_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
"DHCPSRV_MEMFILE_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
@@ -458,7 +458,7 @@ const char* values[] = {
"DHCPSRV_MYSQL_GET_HWADDR", "obtaining IPv4 leases for hardware address %1",
"DHCPSRV_MYSQL_GET_IAID_DUID", "obtaining IPv6 leases for IAID %1, DUID %2, lease type %3",
"DHCPSRV_MYSQL_GET_IAID_SUBID_DUID", "obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3, lease type %4",
"DHCPSRV_MYSQL_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3/%4",
"DHCPSRV_MYSQL_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3",
"DHCPSRV_MYSQL_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
"DHCPSRV_MYSQL_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
"DHCPSRV_MYSQL_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
@@ -518,7 +518,7 @@ const char* values[] = {
"DHCPSRV_PGSQL_GET_HWADDR", "obtaining IPv4 leases for hardware address %1",
"DHCPSRV_PGSQL_GET_IAID_DUID", "obtaining IPv4 leases for IAID %1 and DUID %2, lease type %3",
"DHCPSRV_PGSQL_GET_IAID_SUBID_DUID", "obtaining IPv4 leases for IAID %1, Subnet ID %2, DUID %3, and lease type %4",
"DHCPSRV_PGSQL_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3/%4",
"DHCPSRV_PGSQL_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3",
"DHCPSRV_PGSQL_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
"DHCPSRV_PGSQL_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
"DHCPSRV_PGSQL_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",

View File

@@ -599,7 +599,7 @@ A debug message issued when the server is attempting to obtain an IPv6
lease from the memory file database for a client with the specified IAID
(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
% DHCPSRV_MEMFILE_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3/%4
% DHCPSRV_MEMFILE_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3
A debug message issued when the server is attempting to obtain a page of
IPv6 leases beginning with the specified address within a link.
@@ -887,7 +887,7 @@ A debug message issued when the server is attempting to obtain an IPv6
lease from the MySQL database for a client with the specified IAID
(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
% DHCPSRV_MYSQL_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3/%4
% DHCPSRV_MYSQL_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3
A debug message issued when the server is attempting to obtain a page of
IPv6 leases beginning with the specified address within a link.
@@ -1167,7 +1167,7 @@ A debug message issued when the server is attempting to obtain an IPv6
lease from the PostgreSQL database for a client with the specified IAID
(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
% DHCPSRV_PGSQL_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3/%4
% DHCPSRV_PGSQL_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3
A debug message issued when the server is attempting to obtain a page of
IPv6 leases beginning with the specified address within a link.

View File

@@ -967,16 +967,14 @@ public:
/// @brief Returns existing IPv6 leases with on a given link.
///
/// @param link_addr limit results to leases on this link (prefix).
/// @param link_len limit results to leases on this link (length).
/// @param subnet_id subnet identifier.
/// @param lower_bound_address IPv6 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
///
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByLink(const asiolink::IOAddress& link_addr,
uint8_t link_len,
getLeases6ByLink(SubnetID subnet_id,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) = 0;

View File

@@ -3172,27 +3172,16 @@ Memfile_LeaseMgr::getLeases6ByRemoteIdInternal(const OptionBuffer& remote_id,
}
Lease6Collection
Memfile_LeaseMgr::getLeases6ByLink(const IOAddress& link_addr,
uint8_t link_len,
Memfile_LeaseMgr::getLeases6ByLink(SubnetID subnet_id,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_MEMFILE_GET_LINKADDR6)
.arg(page_size.page_size_)
.arg(lower_bound_address.toText())
.arg(link_addr.toText())
.arg(static_cast<unsigned>(link_len));
.arg(subnet_id);
// Expecting IPv6 valid prefix and address.
if (!link_addr.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 address while "
"retrieving leases from the lease database, got "
<< link_addr);
}
if ((link_len == 0) || (link_len > 128)) {
isc_throw(OutOfRange, "invalid IPv6 prefix length "
<< static_cast<unsigned>(link_len));
}
// Expecting IPv6 valid address.
if (!lower_bound_address.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 address while "
"retrieving leases from the lease database, got "
@@ -3201,46 +3190,40 @@ Memfile_LeaseMgr::getLeases6ByLink(const IOAddress& link_addr,
if (MultiThreadingMgr::instance().getMode()) {
std::lock_guard<std::mutex> lock(*mutex_);
return (getLeases6ByLinkInternal(link_addr,
link_len,
return (getLeases6ByLinkInternal(subnet_id,
lower_bound_address,
page_size));
} else {
return (getLeases6ByLinkInternal(link_addr,
link_len,
return (getLeases6ByLinkInternal(subnet_id,
lower_bound_address,
page_size));
}
}
Lease6Collection
Memfile_LeaseMgr::getLeases6ByLinkInternal(const IOAddress& link_addr,
uint8_t link_len,
Memfile_LeaseMgr::getLeases6ByLinkInternal(SubnetID subnet_id,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
const IOAddress& first_addr = firstAddrInPrefix(link_addr, link_len);
const IOAddress& last_addr = lastAddrInPrefix(link_addr, link_len);
const IOAddress& start_addr =
(lower_bound_address < first_addr ? first_addr : lower_bound_address);
Lease6Collection collection;
const Lease6StorageAddressIndex& idx = storage6_.get<AddressIndexTag>();
Lease6StorageAddressIndex::const_iterator lb = idx.lower_bound(start_addr);
Lease6StorageAddressIndex::const_iterator eb = idx.upper_bound(last_addr);
const Lease6StorageSubnetIdIndex& idx = storage6_.get<SubnetIdIndexTag>();
Lease6StorageSubnetIdIndex::const_iterator lb =
idx.lower_bound(boost::make_tuple(subnet_id, lower_bound_address));
// Return all leases being within the page size.
IOAddress last_seen_addr = lower_bound_address;
for (auto it = lb; it != eb; ++it) {
if ((*it)->addr_ == last_seen_addr) {
IOAddress last_addr = lower_bound_address;
for (auto it = lb; it != idx.end(); ++it) {
if ((*it)->addr_ == last_addr) {
// Already seen: skip it.
continue;
}
last_seen_addr = (*it)->addr_;
Lease6Ptr lease = getAnyLease6Internal(last_seen_addr);
if (lease) {
collection.push_back(lease);
if (collection.size() >= page_size.page_size_) {
break;
}
if ((*it)->subnet_id_ != subnet_id) {
// Gone after the subnet id index.
break;
}
last_addr = (*it)->addr_;
collection.push_back(Lease6Ptr(new Lease6(**it)));
if (collection.size() >= page_size.page_size_) {
break;
}
}
return (collection);

View File

@@ -1385,16 +1385,14 @@ public:
/// @brief Returns existing IPv6 leases with on a given link.
///
/// @param link_addr limit results to leases on this link (prefix).
/// @param link_len limit results to leases on this link (length).
/// @param subnet_id subnet identifier.
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
///
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByLink(const asiolink::IOAddress& link_addr,
uint8_t link_len,
getLeases6ByLink(SubnetID subnet_id,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;
@@ -1496,16 +1494,14 @@ private:
/// @brief Returns existing IPv6 leases with on a given link.
///
/// @param link_addr limit results to leases on this link (prefix).
/// @param link_len limit results to leases on this link (length).
/// @param subnet_id subnet identifier.
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
///
/// @return collection of IPv6 leases
Lease6Collection
getLeases6ByLinkInternal(const asiolink::IOAddress& link_addr,
uint8_t link_len,
getLeases6ByLinkInternal(SubnetID subnet_id,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size);
public:

View File

@@ -40,7 +40,7 @@ struct HWAddressSubnetIdIndexTag { };
/// @brief Tag for indexes by client-id, subnet-id tuple.
struct ClientIdSubnetIdIndexTag { };
/// @brief Tag for indexes by subnet-id.
/// @brief Tag for indexes by subnet-id (and address for v6).
struct SubnetIdIndexTag { };
/// @brief Tag for indexes by subnet-id and pool-id.
@@ -124,11 +124,20 @@ typedef boost::multi_index_container<
>,
// Specification of the fourth index starts here.
// This index sorts leases by SubnetID.
// This index sorts leases by SubnetID and address.
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<SubnetIdIndexTag>,
boost::multi_index::member<Lease, isc::dhcp::SubnetID,
&Lease::subnet_id_>
boost::multi_index::composite_key<
Lease6,
// Subnet id.
boost::multi_index::member<Lease,
isc::dhcp::SubnetID,
&Lease::subnet_id_>,
// Address.
boost::multi_index::member<Lease,
isc::asiolink::IOAddress,
&Lease::addr_>
>
>,
// Specification of the fifth index starts here

View File

@@ -398,7 +398,7 @@ tagged_statements = { {
"hwaddr, hwtype, hwaddr_source, "
"state, user_context, pool_id "
"FROM lease6 "
"WHERE address BETWEEN ? AND ? "
"WHERE subnet_id = ? AND address > ? "
"ORDER BY address "
"LIMIT ?"},
{MySqlLeaseMgr::INSERT_LEASE4,
@@ -4468,27 +4468,16 @@ MySqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& remote_id,
}
Lease6Collection
MySqlLeaseMgr::getLeases6ByLink(const IOAddress& link_addr,
uint8_t link_len,
MySqlLeaseMgr::getLeases6ByLink(SubnetID subnet_id,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_MYSQL_GET_LINKADDR6)
.arg(page_size.page_size_)
.arg(lower_bound_address.toText())
.arg(link_addr.toText())
.arg(static_cast<unsigned>(link_len));
.arg(subnet_id);
// Expecting IPv6 valid prefix and address.
if (!link_addr.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 link address while "
"retrieving leases from the lease database, got "
<< link_addr);
}
if ((link_len == 0) || (link_len > 128)) {
isc_throw(OutOfRange, "invalid IPv6 prefix length "
<< static_cast<unsigned>(link_len));
}
// Expecting IPv6 valid address.
if (!lower_bound_address.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
"retrieving leases from the lease database, got "
@@ -4496,44 +4485,25 @@ MySqlLeaseMgr::getLeases6ByLink(const IOAddress& link_addr,
}
Lease6Collection result;
const IOAddress& first_addr = firstAddrInPrefix(link_addr, link_len);
const IOAddress& last_addr = lastAddrInPrefix(link_addr, link_len);
IOAddress start_addr = lower_bound_address;
if (lower_bound_address < first_addr) {
start_addr = first_addr;
} else if (last_addr <= lower_bound_address) {
// Range was already done.
return (result);
} else {
// The lower bound address is from the last call so skip it.
start_addr = IOAddress::increase(lower_bound_address);
}
// Prepare WHERE clause
MYSQL_BIND inbind[3];
memset(inbind, 0, sizeof(inbind));
// Bind start address
std::vector<uint8_t> start_addr_data = start_addr.toBytes();
if (start_addr_data.size() != 16) {
isc_throw(DbOperationError, "start address is not 16 bytes long");
}
unsigned long start_addr_size = 16;
inbind[0].buffer_type = MYSQL_TYPE_BLOB;
inbind[0].buffer = reinterpret_cast<char*>(&start_addr_data[0]);
inbind[0].buffer_length = 16;
inbind[0].length = &start_addr_size;
// Bind the subnet id.
inbind[0].buffer_type = MYSQL_TYPE_LONG;
inbind[0].buffer = reinterpret_cast<char*>(&subnet_id);
inbind[0].is_unsigned = MLM_TRUE;
// Bind last address
std::vector<uint8_t> last_addr_data = last_addr.toBytes();
if (last_addr_data.size() != 16) {
isc_throw(DbOperationError, "last address is not 16 bytes long");
// Bind the lower bound address.
std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
unsigned long lb_addr_size = lb_addr_data.size();
if (lb_addr_size != 16) {
isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
}
unsigned long last_addr_size = 16;
inbind[1].buffer_type = MYSQL_TYPE_BLOB;
inbind[1].buffer = reinterpret_cast<char*>(&last_addr_data[0]);
inbind[1].buffer_length = 16;
inbind[1].length = &last_addr_size;
inbind[1].buffer = reinterpret_cast<char*>(&lb_addr_data[0]);
inbind[1].buffer_length = lb_addr_size;
inbind[1].length = &lb_addr_size;
// Bind page size value
uint32_t ps = static_cast<uint32_t>(page_size.page_size_);

View File

@@ -1141,16 +1141,14 @@ public:
/// @brief Returns existing IPv6 leases with on a given link.
///
/// @param link_addr limit results to leases on this link (prefix).
/// @param link_len limit results to leases on this link (length).
/// @param subnet_id subnet identifier.
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
///
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByLink(const asiolink::IOAddress& link_addr,
uint8_t link_len,
getLeases6ByLink(SubnetID subnet_id,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;

View File

@@ -409,7 +409,7 @@ PgSqlTaggedStatement tagged_statements[] = {
"LIMIT $3" },
// GET_LEASE6_LINK
{ 3, { OID_VARCHAR, OID_VARCHAR, OID_INT8 },
{ 3, { OID_INT8, OID_VARCHAR, OID_INT8 },
"get_lease6_link",
"SELECT host(address), duid, valid_lifetime, "
"extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
@@ -417,7 +417,7 @@ PgSqlTaggedStatement tagged_statements[] = {
"hwaddr, hwtype, hwaddr_source, "
"state, user_context, pool_id "
"FROM lease6 "
"WHERE address BETWEEN cast($1 as inet) and cast($2 as inet) "
"WHERE subnet_id = $1 AND address > cast($2 as inet) "
"ORDER BY address "
"LIMIT $3" },
@@ -3530,29 +3530,16 @@ PgSqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& remote_id,
}
Lease6Collection
PgSqlLeaseMgr::getLeases6ByLink(const IOAddress& link_addr,
uint8_t link_len,
PgSqlLeaseMgr::getLeases6ByLink(SubnetID subnet_id,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_PGSQL_GET_LINKADDR6)
.arg(page_size.page_size_)
.arg(lower_bound_address.toText())
.arg(link_addr.toText())
.arg(static_cast<unsigned>(link_len));
// Expecting IPv6 valid prefix and address.
if (!link_addr.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 link address while "
"retrieving leases from the lease database, got "
<< link_addr);
}
if ((link_len == 0) || (link_len > 128)) {
isc_throw(OutOfRange, "invalid IPv6 prefix length "
<< static_cast<unsigned>(link_len));
}
.arg(subnet_id);
// Expecting IPv6 valid address.
if (!lower_bound_address.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
"retrieving leases from the lease database, got "
@@ -3560,29 +3547,16 @@ PgSqlLeaseMgr::getLeases6ByLink(const IOAddress& link_addr,
}
Lease6Collection result;
const IOAddress& first_addr = firstAddrInPrefix(link_addr, link_len);
const IOAddress& last_addr = lastAddrInPrefix(link_addr, link_len);
IOAddress start_addr = lower_bound_address;
if (lower_bound_address < first_addr) {
start_addr = first_addr;
} else if (last_addr <= lower_bound_address) {
// Range was already done.
return (result);
} else {
// The lower bound address is from the last call so skip it.
start_addr = IOAddress::increase(lower_bound_address);
}
// Prepare WHERE clause
PsqlBindArray bind_array;
// Bind start address
std::string start_addr_str = start_addr.toText();
bind_array.add(start_addr_str);
// Bind subnet id.
std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
bind_array.add(subnet_id_str);
// Bind last address
std::string last_addr_str = last_addr.toText();
bind_array.add(last_addr_str);
// Bind lower bound address
std::string lb_address_str = lower_bound_address.toText();
bind_array.add(lb_address_str);
// Bind page size value
std::string page_size_data =

View File

@@ -1095,16 +1095,14 @@ public:
/// @brief Returns existing IPv6 leases with on a given link.
///
/// @param link_addr limit results to leases on this link (prefix).
/// @param link_len limit results to leases on this link (length).
/// @param subnet_id subnet identifier.
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
///
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByLink(const asiolink::IOAddress& link_addr,
uint8_t link_len,
getLeases6ByLink(SubnetID subnet_id,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;

View File

@@ -994,23 +994,25 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
start(Memfile_LeaseMgr::V6);
initLease6();
// Put leases in the subnet 1.
for (size_t i = 0; i < leases6.size(); ++i) {
Lease6Ptr lease(new Lease6(*leases6[i]));
leases6[i] = lease;
lease->subnet_id_ = 1;
EXPECT_NO_THROW(lease_mgr_->updateLease6(leases6[i]));
}
// Create parameter values.
IOAddress link_addr(ADDRESS6[4]);
IOAddress other_link_addr("2001:db8:1::4");
IOAddress zero = IOAddress::IPV6_ZERO_ADDRESS();
Lease6Collection got;
// Other link: nothing.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(other_link_addr,
64,
zero,
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(10, zero,
LeasePageSize(10)));
EXPECT_EQ(0, got.size());
// Link: 8 entries.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(link_addr,
64,
zero,
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
LeasePageSize(10)));
ASSERT_EQ(8, got.size());
@@ -1022,9 +1024,7 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
}
// Link: initial partial: 4 entries.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(link_addr,
64,
zero,
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
LeasePageSize(4)));
ASSERT_EQ(4, got.size());
for (size_t i = 0; i < 4; ++i) {
@@ -1034,9 +1034,7 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
}
// Link: next partial: 4 entries.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(link_addr,
64,
lease->addr_,
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
LeasePageSize(4)));
ASSERT_EQ(4, got.size());
for (size_t i = 0; i < 4; ++i) {
@@ -1046,9 +1044,7 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
}
// Link: further partial: nothing.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(link_addr,
64,
lease->addr_,
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
LeasePageSize(4)));
EXPECT_EQ(0, got.size());
}

View File

@@ -280,8 +280,7 @@ ConcreteLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& /* remote_id */,
}
Lease6Collection
ConcreteLeaseMgr::getLeases6ByLink(const IOAddress& /* link_addr */,
uint8_t /* link_len */,
ConcreteLeaseMgr::getLeases6ByLink(SubnetID /* subnet_id */,
const IOAddress& /* lower_bound_address */,
const LeasePageSize& /* page_size */) {
isc_throw(NotImplemented, "ConcreteLeaseMgr::getLeases6ByLink not implemented");

View File

@@ -368,8 +368,7 @@ public:
/// @brief Stub implementation.
Lease6Collection
getLeases6ByLink(const asiolink::IOAddress& /* link_addr */,
uint8_t /* link_len */,
getLeases6ByLink(SubnetID /* subnet_id */,
const asiolink::IOAddress& /* lower_bound_address */,
const LeasePageSize& /* page_size */) override;

View File

@@ -1215,23 +1215,25 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
start(false);
initLease6();
// Put leases in the subnet 1.
for (size_t i = 0; i < leases6.size(); ++i) {
Lease6Ptr lease(new Lease6(*leases6[i]));
leases6[i] = lease;
lease->subnet_id_ = 1;
EXPECT_NO_THROW(lease_mgr_->updateLease6(leases6[i]));
}
// Create parameter values.
asiolink::IOAddress link_addr(ADDRESS6[4]);
asiolink::IOAddress other_link_addr("2001:db8:1::4");
asiolink::IOAddress zero = asiolink::IOAddress::IPV6_ZERO_ADDRESS();
Lease6Collection got;
// Other link: nothing.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(other_link_addr,
64,
zero,
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(100, zero,
LeasePageSize(10)));
EXPECT_EQ(0, got.size());
// Link: 8 entries.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(link_addr,
64,
zero,
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
LeasePageSize(10)));
ASSERT_EQ(8, got.size());
@@ -1243,9 +1245,7 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
}
// Link: initial partial: 4 entries.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(link_addr,
64,
zero,
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
LeasePageSize(4)));
ASSERT_EQ(4, got.size());
for (size_t i = 0; i < 4; ++i) {
@@ -1255,9 +1255,7 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
}
// Link: next partial: 4 entries.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(link_addr,
64,
lease->addr_,
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
LeasePageSize(4)));
ASSERT_EQ(4, got.size());
for (size_t i = 0; i < 4; ++i) {
@@ -1267,9 +1265,7 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
}
// Link: further partial: nothing.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(link_addr,
64,
lease->addr_,
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
LeasePageSize(4)));
EXPECT_EQ(0, got.size());
}