Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
95729b09
Commit
95729b09
authored
Sep 06, 2013
by
Tomek Mrugalski
🛰
Browse files
[3146] getLease6() methods now have extra param: LeaseType
parent
9b97fd86
Changes
16
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp6/dhcp6_srv.cc
View file @
95729b09
...
...
@@ -1316,7 +1316,8 @@ Dhcpv6Srv::renewIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
return
(
ia_rsp
);
}
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
*
duid
,
ia
->
getIAID
(),
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
*
duid
,
ia
->
getIAID
(),
subnet
->
getID
());
if
(
!
lease
)
{
...
...
@@ -1579,7 +1580,8 @@ Dhcpv6Srv::releaseIA_NA(const DuidPtr& duid, const Pkt6Ptr& query,
return
(
ia_rsp
);
}
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
release_addr
->
getAddress
());
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
release_addr
->
getAddress
());
if
(
!
lease
)
{
// client releasing a lease that we don't know about.
...
...
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
View file @
95729b09
...
...
@@ -1024,7 +1024,8 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) {
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
l
);
// Check that T1, T2, preferred, valid and cltt really set and not using
...
...
@@ -1116,7 +1117,8 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
OptionPtr
clientid
=
generateClientId
();
// Check that the lease is NOT in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_FALSE
(
l
);
// Let's create a RENEW
...
...
@@ -1147,7 +1149,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
checkIA_NAStatusCode
(
ia
,
STATUS_NoBinding
);
// Check that there is no lease added
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_FALSE
(
l
);
// CASE 2: Lease is known and belongs to this client, but to a different IAID
...
...
@@ -1189,7 +1191,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
ASSERT_TRUE
(
ia
);
checkIA_NAStatusCode
(
ia
,
STATUS_NoBinding
);
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
lease
);
// Verify that the lease was not updated.
EXPECT_EQ
(
123
,
lease
->
cltt_
);
...
...
@@ -1226,7 +1228,8 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
l
);
// Let's create a RELEASE
...
...
@@ -1265,11 +1268,12 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
// Check that the lease is really gone in the database
// get lease by address
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_FALSE
(
l
);
// get lease by subnetid/duid/iaid combination
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
*
duid_
,
iaid
,
subnet_
->
getID
());
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
*
duid_
,
iaid
,
subnet_
->
getID
());
ASSERT_FALSE
(
l
);
}
...
...
@@ -1301,7 +1305,8 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
OptionPtr
clientid
=
generateClientId
();
// Check that the lease is NOT in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_FALSE
(
l
);
// Let's create a RELEASE
...
...
@@ -1334,7 +1339,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
checkMsgStatusCode
(
reply
,
STATUS_NoBinding
);
// Check that the lease is not there
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_FALSE
(
l
);
// CASE 2: Lease is known and belongs to this client, but to a different IAID
...
...
@@ -1356,7 +1361,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
checkMsgStatusCode
(
reply
,
STATUS_NoBinding
);
// Check that the lease is still there
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
l
);
// CASE 3: Lease belongs to a client with different client-id
...
...
@@ -1379,7 +1384,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
checkMsgStatusCode
(
reply
,
STATUS_NoBinding
);
// Check that the lease is still there
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
l
);
// Finally, let's cleanup the database
...
...
src/bin/dhcp6/tests/dhcp6_test_utils.h
View file @
95729b09
...
...
@@ -377,7 +377,8 @@ public:
boost
::
shared_ptr
<
Option6IAAddr
>
addr
)
{
boost
::
shared_ptr
<
Option6IA
>
ia
=
boost
::
dynamic_pointer_cast
<
Option6IA
>
(
ia_na
);
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
->
getAddress
());
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
->
getAddress
());
if
(
!
lease
)
{
std
::
cout
<<
"Lease for "
<<
addr
->
getAddress
().
toText
()
<<
" not found in the database backend."
;
...
...
src/bin/dhcp6/tests/hooks_unittest.cc
View file @
95729b09
...
...
@@ -1076,7 +1076,8 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_renew) {
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
l
);
// Check that T1, T2, preferred, valid and cltt really set and not using
...
...
@@ -1172,7 +1173,8 @@ TEST_F(HooksDhcpv6SrvTest, leaseUpdate_lease6_renew) {
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
l
);
// Check that T1, T2, preferred, valid and cltt really set and not using
...
...
@@ -1262,7 +1264,8 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
l
);
// Check that T1, T2, preferred, valid and cltt really set and not using
...
...
@@ -1293,7 +1296,7 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
// Check that our callback was called
EXPECT_EQ
(
"lease6_renew"
,
callback_name_
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
// Check that the old values are still there and they were not
// updated by the renewal
...
...
@@ -1337,7 +1340,8 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
l
);
// Let's create a RELEASE
...
...
@@ -1375,11 +1379,12 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
// Check that the lease is really gone in the database
// get lease by address
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_FALSE
(
l
);
// Get lease by subnetid/duid/iaid combination
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
*
duid_
,
iaid
,
subnet_
->
getID
());
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
*
duid_
,
iaid
,
subnet_
->
getID
());
ASSERT_FALSE
(
l
);
}
...
...
@@ -1416,7 +1421,8 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
l
);
// Let's create a RELEASE
...
...
@@ -1442,11 +1448,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
// Check that the lease is still there
// get lease by address
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
l
);
// Get lease by subnetid/duid/iaid combination
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
*
duid_
,
iaid
,
subnet_
->
getID
());
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
*
duid_
,
iaid
,
subnet_
->
getID
());
ASSERT_TRUE
(
l
);
}
...
...
src/lib/dhcpsrv/alloc_engine.cc
View file @
95729b09
...
...
@@ -222,7 +222,9 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
}
// check if there's existing lease for that subnet/duid/iaid combination.
Lease6Ptr
existing
=
LeaseMgrFactory
::
instance
().
getLease6
(
*
duid
,
iaid
,
subnet
->
getID
());
/// @todo: Make this generic
Lease6Ptr
existing
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
*
duid
,
iaid
,
subnet
->
getID
());
if
(
existing
)
{
// we have a lease already. This is a returning client, probably after
// his reboot.
...
...
@@ -231,7 +233,8 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
// check if the hint is in pool and is available
if
(
subnet
->
inPool
(
hint
))
{
existing
=
LeaseMgrFactory
::
instance
().
getLease6
(
hint
);
existing
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
hint
);
if
(
!
existing
)
{
/// @todo: check if the hint is reserved once we have host support
/// implemented
...
...
@@ -284,7 +287,8 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
/// @todo: check if the address is reserved once we have host support
/// implemented
Lease6Ptr
existing
=
LeaseMgrFactory
::
instance
().
getLease6
(
candidate
);
Lease6Ptr
existing
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
candidate
);
if
(
!
existing
)
{
// there's no existing lease for selected candidate, so it is
// free. Let's allocate it.
...
...
@@ -795,7 +799,8 @@ Lease6Ptr AllocEngine::createLease6(const Subnet6Ptr& subnet,
// It is for advertise only. We should not insert the lease into LeaseMgr,
// but rather check that we could have inserted it.
Lease6Ptr
existing
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
existing
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
if
(
!
existing
)
{
return
(
lease
);
}
else
{
...
...
src/lib/dhcpsrv/lease_mgr.h
View file @
95729b09
...
...
@@ -318,9 +318,9 @@ struct Lease6 : public Lease {
/// @brief Type of lease contents
typedef
enum
{
LEASE_IA_NA
,
/// the lease contains non-temporary IPv6 address
LEASE_IA_TA
,
/// the lease contains temporary IPv6 address
LEASE_IA_PD
/// the lease contains IPv6 prefix (for prefix delegation)
LEASE_IA_NA
=
0
,
/// the lease contains non-temporary IPv6 address
LEASE_IA_TA
=
1
,
/// the lease contains temporary IPv6 address
LEASE_IA_PD
=
2
/// the lease contains IPv6 prefix (for prefix delegation)
}
LeaseType
;
/// @brief Lease type
...
...
@@ -533,10 +533,12 @@ public:
/// The assumption here is that there will not be site or link-local
/// addresses used, so there is no way of having address duplication.
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param addr address of the searched lease
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual
Lease6Ptr
getLease6
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
=
0
;
virtual
Lease6Ptr
getLease6
(
Lease6
::
LeaseType
type
,
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
=
0
;
/// @brief Returns existing IPv6 leases for a given DUID+IA combination
///
...
...
@@ -545,22 +547,24 @@ public:
/// can be more than one. Thus return type is a container, not a single
/// pointer.
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param duid client DUID
/// @param iaid IA identifier
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual
Lease6Collection
getLease6
(
const
DUID
&
duid
,
virtual
Lease6Collection
getLease6
(
Lease6
::
LeaseType
type
,
const
DUID
&
duid
,
uint32_t
iaid
)
const
=
0
;
/// @brief Returns existing IPv6 lease for a given DUID+IA combination
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param duid client DUID
/// @param iaid IA identifier
/// @param subnet_id subnet id of the subnet the lease belongs to
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual
Lease6Ptr
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
=
0
;
virtual
Lease6Ptr
getLease6
(
Lease6
::
LeaseType
type
,
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
=
0
;
/// @brief Updates IPv4 lease.
///
...
...
src/lib/dhcpsrv/memfile_lease_mgr.cc
View file @
95729b09
...
...
@@ -46,7 +46,7 @@ Memfile_LeaseMgr::addLease(const Lease6Ptr& lease) {
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_ADD_ADDR6
).
arg
(
lease
->
addr_
.
toText
());
if
(
getLease6
(
lease
->
addr_
))
{
if
(
getLease6
(
lease
->
type_
,
lease
->
addr_
))
{
// there is a lease with specified address already
return
(
false
);
}
...
...
@@ -186,7 +186,8 @@ Memfile_LeaseMgr::getLease4(const ClientId& client_id,
}
Lease6Ptr
Memfile_LeaseMgr
::
getLease6
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
Memfile_LeaseMgr
::
getLease6
(
Lease6
::
LeaseType
/* not used yet */
,
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_GET_ADDR6
).
arg
(
addr
.
toText
());
...
...
@@ -199,7 +200,8 @@ Memfile_LeaseMgr::getLease6(const isc::asiolink::IOAddress& addr) const {
}
Lease6Collection
Memfile_LeaseMgr
::
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
)
const
{
Memfile_LeaseMgr
::
getLease6
(
Lease6
::
LeaseType
/* not used yet */
,
const
DUID
&
duid
,
uint32_t
iaid
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_GET_IAID_DUID
).
arg
(
iaid
).
arg
(
duid
.
toText
());
...
...
@@ -207,7 +209,8 @@ Memfile_LeaseMgr::getLease6(const DUID& duid, uint32_t iaid) const {
}
Lease6Ptr
Memfile_LeaseMgr
::
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
,
Memfile_LeaseMgr
::
getLease6
(
Lease6
::
LeaseType
/* not used yet */
,
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID
)
...
...
src/lib/dhcpsrv/memfile_lease_mgr.h
View file @
95729b09
...
...
@@ -140,33 +140,38 @@ public:
/// This function returns a copy of the lease. The modification in the
/// return lease does not affect the instance held in the lease storage.
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param addr An address of the searched lease.
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual
Lease6Ptr
getLease6
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
;
virtual
Lease6Ptr
getLease6
(
Lease6
::
LeaseType
type
,
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
;
/// @brief Returns existing IPv6 lease for a given DUID+IA combination
///
/// @todo Not implemented yet
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param duid client DUID
/// @param iaid IA identifier
///
/// @return collection of IPv6 leases
virtual
Lease6Collection
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
)
const
;
virtual
Lease6Collection
getLease6
(
Lease6
::
LeaseType
type
,
const
DUID
&
duid
,
uint32_t
iaid
)
const
;
/// @brief Returns existing IPv6 lease for a given DUID/IA/subnet-id tuple
///
/// This function returns a copy of the lease. The modification in the
/// return lease does not affect the instance held in the lease storage.
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param duid client DUID
/// @param iaid IA identifier
/// @param subnet_id identifier of the subnet the lease must belong to
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual
Lease6Ptr
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
;
virtual
Lease6Ptr
getLease6
(
Lease6
::
LeaseType
type
,
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
;
/// @brief Updates IPv4 lease.
///
...
...
src/lib/dhcpsrv/mysql_lease_mgr.cc
View file @
95729b09
...
...
@@ -984,8 +984,9 @@ public:
default:
isc_throw
(
BadValue
,
"invalid lease type returned ("
<<
lease_type_
<<
") for lease with address "
<<
address
<<
". Only 0, 1, or 2 are allowed."
);
static_cast
<
int
>
(
lease_type_
)
<<
") for lease with "
<<
"address "
<<
address
<<
". Only 0, 1, or 2 are "
<<
"allowed."
);
}
// Set up DUID,
...
...
@@ -1650,7 +1651,8 @@ MySqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const {
Lease6Ptr
MySqlLeaseMgr
::
getLease6
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
MySqlLeaseMgr
::
getLease6
(
Lease6
::
LeaseType
/* type - not used yet */
,
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MYSQL_GET_ADDR6
).
arg
(
addr
.
toText
());
...
...
@@ -1676,7 +1678,8 @@ MySqlLeaseMgr::getLease6(const isc::asiolink::IOAddress& addr) const {
Lease6Collection
MySqlLeaseMgr
::
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
)
const
{
MySqlLeaseMgr
::
getLease6
(
Lease6
::
LeaseType
/* type - not used yet */
,
const
DUID
&
duid
,
uint32_t
iaid
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MYSQL_GET_IAID_DUID
).
arg
(
iaid
).
arg
(
duid
.
toText
());
...
...
@@ -1718,7 +1721,8 @@ MySqlLeaseMgr::getLease6(const DUID& duid, uint32_t iaid) const {
Lease6Ptr
MySqlLeaseMgr
::
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
,
MySqlLeaseMgr
::
getLease6
(
Lease6
::
LeaseType
/* type - not used yet */
,
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MYSQL_GET_IAID_SUBID_DUID
)
...
...
src/lib/dhcpsrv/mysql_lease_mgr.h
View file @
95729b09
...
...
@@ -244,6 +244,7 @@ public:
/// The assumption here is that there will not be site or link-local
/// addresses used, so there is no way of having address duplication.
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param addr address of the searched lease
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
...
...
@@ -255,7 +256,8 @@ public:
/// programming error.
/// @throw isc::dhcp::DbOperationError An operation on the open database has
/// failed.
virtual
Lease6Ptr
getLease6
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
;
virtual
Lease6Ptr
getLease6
(
Lease6
::
LeaseType
type
,
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
;
/// @brief Returns existing IPv6 leases for a given DUID+IA combination
///
...
...
@@ -264,6 +266,7 @@ public:
/// can be more than one. Thus return type is a container, not a single
/// pointer.
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param duid client DUID
/// @param iaid IA identifier
///
...
...
@@ -276,11 +279,12 @@ public:
/// programming error.
/// @throw isc::dhcp::DbOperationError An operation on the open database has
/// failed.
virtual
Lease6Collection
getLease6
(
const
DUID
&
duid
,
virtual
Lease6Collection
getLease6
(
Lease6
::
LeaseType
type
,
const
DUID
&
duid
,
uint32_t
iaid
)
const
;
/// @brief Returns existing IPv6 lease for a given DUID+IA combination
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param duid client DUID
/// @param iaid IA identifier
/// @param subnet_id subnet id of the subnet the lease belongs to
...
...
@@ -294,8 +298,8 @@ public:
/// programming error.
/// @throw isc::dhcp::DbOperationError An operation on the open database has
/// failed.
virtual
Lease6Ptr
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
;
virtual
Lease6Ptr
getLease6
(
Lease6
::
LeaseType
type
,
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
;
/// @brief Updates IPv4 lease.
///
...
...
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
View file @
95729b09
...
...
@@ -219,7 +219,8 @@ TEST_F(AllocEngine6Test, simpleAlloc6) {
checkLease6
(
lease
);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
addr_
);
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
type_
,
lease
->
addr_
);
ASSERT_TRUE
(
from_mgr
);
// Now check that the lease in LeaseMgr has the same parameters
...
...
@@ -244,7 +245,8 @@ TEST_F(AllocEngine6Test, fakeAlloc6) {
checkLease6
(
lease
);
// Check that the lease is NOT in LeaseMgr
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
addr_
);
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
type_
,
lease
->
addr_
);
ASSERT_FALSE
(
from_mgr
);
}
...
...
@@ -270,7 +272,8 @@ TEST_F(AllocEngine6Test, allocWithValidHint6) {
checkLease6
(
lease
);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
addr_
);
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
type_
,
lease
->
addr_
);
ASSERT_TRUE
(
from_mgr
);
// Now check that the lease in LeaseMgr has the same parameters
...
...
@@ -311,7 +314,8 @@ TEST_F(AllocEngine6Test, allocWithUsedHint6) {
checkLease6
(
lease
);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
addr_
);
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
type_
,
lease
->
addr_
);
ASSERT_TRUE
(
from_mgr
);
// Now check that the lease in LeaseMgr has the same parameters
...
...
@@ -342,7 +346,8 @@ TEST_F(AllocEngine6Test, allocBogusHint6) {
checkLease6
(
lease
);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
addr_
);
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
type_
,
lease
->
addr_
);
ASSERT_TRUE
(
from_mgr
);
// Now check that the lease in LeaseMgr has the same parameters
...
...
@@ -468,7 +473,8 @@ TEST_F(AllocEngine6Test, smallPool6) {
checkLease6
(
lease
);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
addr_
);
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
type_
,
lease
->
addr_
);
ASSERT_TRUE
(
from_mgr
);
// Now check that the lease in LeaseMgr has the same parameters
...
...
@@ -595,7 +601,8 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) {
EXPECT_EQ
(
addr
.
toText
(),
lease
->
addr_
.
toText
());
// Check that the lease is indeed updated in LeaseMgr
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
addr
);
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6
::
LEASE_IA_NA
,
addr
);
ASSERT_TRUE
(
from_mgr
);
// Now check that the lease in LeaseMgr has the same parameters
...
...
@@ -1272,7 +1279,8 @@ TEST_F(HookAllocEngine6Test, lease6_select) {
checkLease6
(
lease
);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
addr_
);
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
type_
,
lease
->
addr_
);
ASSERT_TRUE
(
from_mgr
);
// Check that callouts were indeed called
...
...
@@ -1345,7 +1353,8 @@ TEST_F(HookAllocEngine6Test, change_lease6_select) {
EXPECT_EQ
(
valid_override_
,
lease
->
valid_lft_
);
// Now check if the lease is in the database
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
addr_
);
Lease6Ptr
from_mgr
=
LeaseMgrFactory
::
instance
().
getLease6
(
lease
->
type_
,
lease
->
addr_
);
ASSERT_TRUE
(
from_mgr
);
// Check if values in the database are overridden
...
...
src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
View file @
95729b09
...
...
@@ -128,7 +128,8 @@ public:
/// @param addr address of the searched lease
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual
Lease6Ptr
getLease6
(
const
isc
::
asiolink
::
IOAddress
&
)
const
{
virtual
Lease6Ptr
getLease6
(
Lease6
::
LeaseType
/* not used yet */
,
const
isc
::
asiolink
::
IOAddress
&
)
const
{
return
(
Lease6Ptr
());
}
...
...
@@ -138,7 +139,8 @@ public:
/// @param iaid IA identifier
///
/// @return collection of IPv6 leases
virtual
Lease6Collection
getLease6
(
const
DUID
&
,
uint32_t
)
const
{
virtual
Lease6Collection
getLease6
(
Lease6
::
LeaseType
/* not used yet */
,
const
DUID
&
,
uint32_t
)
const
{
return
(
Lease6Collection
());
}
...
...
@@ -149,7 +151,8 @@ public:
/// @param subnet_id identifier of the subnet the lease must belong to
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual
Lease6Ptr
getLease6
(
const
DUID
&
,
uint32_t
,
SubnetID
)
const
{
virtual
Lease6Ptr
getLease6
(
Lease6
::
LeaseType
/* not used yet */
,
const
DUID
&
,
uint32_t
,
SubnetID
)
const
{
return
(
Lease6Ptr
());
}
...
...
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
View file @
95729b09
...
...
@@ -80,10 +80,12 @@ TEST_F(MemfileLeaseMgrTest, addGetDelete6) {
// should not be allowed to add a second lease with the same address
EXPECT_FALSE
(
lease_mgr
->
addLease
(
lease
));
Lease6Ptr
x
=
lease_mgr
->
getLease6
(
IOAddress
(
"2001:db8:1::234"
));
Lease6Ptr
x
=
lease_mgr
->
getLease6
(
Lease6
::
LEASE_IA_NA
,
IOAddress
(
"2001:db8:1::234"
));
EXPECT_EQ
(
Lease6Ptr
(),
x
);