Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
445
Issues
445
List
Boards
Labels
Service Desk
Milestones
Merge Requests
71
Merge Requests
71
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
e0966086
Commit
e0966086
authored
Sep 24, 2013
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[3171] alloc{Address -> Lease} rename, compilation fixes
parent
c83724e3
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
123 additions
and
126 deletions
+123
-126
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.cc
+5
-5
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
+9
-9
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
+7
-7
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+34
-22
src/bin/dhcp6/tests/dhcp6_test_utils.h
src/bin/dhcp6/tests/dhcp6_test_utils.h
+2
-1
src/bin/dhcp6/tests/hooks_unittest.cc
src/bin/dhcp6/tests/hooks_unittest.cc
+6
-6
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/alloc_engine.cc
+12
-20
src/lib/dhcpsrv/alloc_engine.h
src/lib/dhcpsrv/alloc_engine.h
+12
-20
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
+36
-36
No files found.
src/bin/dhcp4/dhcp4_srv.cc
View file @
e0966086
...
...
@@ -718,11 +718,11 @@ Dhcpv4Srv::assignLease(const Pkt4Ptr& question, Pkt4Ptr& answer) {
// be inserted into the LeaseMgr as well.
// @todo pass the actual FQDN data.
Lease4Ptr
old_lease
;
Lease4Ptr
lease
=
alloc_engine_
->
allocate
Address
4
(
subnet
,
client_id
,
hwaddr
,
hint
,
false
,
false
,
""
,
fake_allocation
,
callout_handle
,
old_lease
);
Lease4Ptr
lease
=
alloc_engine_
->
allocate
Lease
4
(
subnet
,
client_id
,
hwaddr
,
hint
,
false
,
false
,
""
,
fake_allocation
,
callout_handle
,
old_lease
);
if
(
lease
)
{
// We have a lease! Let's set it in the packet and send it back to
...
...
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
View file @
e0966086
...
...
@@ -390,7 +390,7 @@ public:
// Technically inPool implies inRange, but let's be on the safe
// side and check both.
EXPECT_TRUE
(
subnet
->
inRange
(
rsp
->
getYiaddr
()));
EXPECT_TRUE
(
subnet
->
inPool
(
rsp
->
getYiaddr
()));
EXPECT_TRUE
(
subnet
->
inPool
(
Lease
::
TYPE_V4
,
rsp
->
getYiaddr
()));
// Check lease time
OptionPtr
opt
=
rsp
->
getOption
(
DHO_DHCP_LEASE_TIME
);
...
...
@@ -1333,7 +1333,7 @@ TEST_F(Dhcpv4SrvTest, RenewBasic) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_V4
,
addr
));
// let's create a lease and put it in the LeaseMgr
uint8_t
hwaddr2
[]
=
{
0
,
0xfe
,
0xfe
,
0xfe
,
0xfe
,
0xfe
};
...
...
@@ -1444,7 +1444,7 @@ TEST_F(Dhcpv4SrvTest, ReleaseBasic) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_V4
,
addr
));
// Let's create a lease and put it in the LeaseMgr
uint8_t
mac_addr
[]
=
{
0
,
0xfe
,
0xfe
,
0xfe
,
0xfe
,
0xfe
};
...
...
@@ -1520,7 +1520,7 @@ TEST_F(Dhcpv4SrvTest, ReleaseReject) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_V4
,
addr
));
// Let's create a RELEASE
// Generate client-id also duid_
...
...
@@ -2696,7 +2696,7 @@ TEST_F(HooksDhcpv4SrvTest, subnet4SelectChange) {
// Advertised address must belong to the second pool (in subnet's range,
// in dynamic pool)
EXPECT_TRUE
((
*
subnets
)[
1
]
->
inRange
(
addr
));
EXPECT_TRUE
((
*
subnets
)[
1
]
->
inPool
(
addr
));
EXPECT_TRUE
((
*
subnets
)[
1
]
->
inPool
(
Lease
::
TYPE_V4
,
addr
));
}
// This test verifies that incoming (positive) REQUEST/Renewing can be handled
...
...
@@ -2718,7 +2718,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSimple) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_V4
,
addr
));
// let's create a lease and put it in the LeaseMgr
uint8_t
hwaddr2
[]
=
{
0
,
0xfe
,
0xfe
,
0xfe
,
0xfe
,
0xfe
};
...
...
@@ -2802,7 +2802,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSkip) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_V4
,
addr
));
// let's create a lease and put it in the LeaseMgr
uint8_t
hwaddr2
[]
=
{
0
,
0xfe
,
0xfe
,
0xfe
,
0xfe
,
0xfe
};
...
...
@@ -2866,7 +2866,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseSimple) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_V4
,
addr
));
// Let's create a lease and put it in the LeaseMgr
uint8_t
mac_addr
[]
=
{
0
,
0xfe
,
0xfe
,
0xfe
,
0xfe
,
0xfe
};
...
...
@@ -2951,7 +2951,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseSkip) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_V4
,
addr
));
// Let's create a lease and put it in the LeaseMgr
uint8_t
mac_addr
[]
=
{
0
,
0xfe
,
0xfe
,
0xfe
,
0xfe
,
0xfe
};
...
...
src/bin/dhcp6/dhcp6_srv.cc
View file @
e0966086
...
...
@@ -1223,13 +1223,13 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
// will try to honour the hint, but it is just a hint - some other address
// may be used instead. If fake_allocation is set to false, the lease will
// be inserted into the LeaseMgr as well.
Lease6Collection
leases
=
alloc_engine_
->
allocate
Address
6
(
subnet
,
duid
,
ia
->
getIAID
(),
hint
,
Lease
::
TYPE_NA
,
do_fwd
,
do_rev
,
hostname
,
fake_allocation
,
callout_handle
);
Lease6Collection
leases
=
alloc_engine_
->
allocate
Lease
6
(
subnet
,
duid
,
ia
->
getIAID
(),
hint
,
Lease
::
TYPE_NA
,
do_fwd
,
do_rev
,
hostname
,
fake_allocation
,
callout_handle
);
/// @todo: Handle more than one lease
Lease6Ptr
lease
;
if
(
!
leases
.
empty
())
{
...
...
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
View file @
e0966086
...
...
@@ -265,7 +265,7 @@ public:
// Check that we have got the address we requested.
checkIAAddr
(
addr
,
IOAddress
(
"2001:db8:1:1::dead:beef"
),
subnet_
->
getPreferred
(),
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
if
(
msg_type
!=
DHCPV6_SOLICIT
)
{
...
...
@@ -663,7 +663,8 @@ TEST_F(Dhcpv6SrvTest, SolicitBasic) {
ASSERT_TRUE
(
addr
);
// Check that the assigned address is indeed from the configured pool
checkIAAddr
(
addr
,
addr
->
getAddress
(),
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr
,
addr
->
getAddress
(),
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
// check DUIDs
checkServerId
(
reply
,
srv
.
getServerID
());
...
...
@@ -695,7 +696,7 @@ TEST_F(Dhcpv6SrvTest, SolicitHint) {
// with a valid hint
IOAddress
hint
(
"2001:db8:1:1::dead:beef"
);
ASSERT_TRUE
(
subnet_
->
inPool
(
hint
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
hint
));
OptionPtr
hint_opt
(
new
Option6IAAddr
(
D6O_IAADDR
,
hint
,
300
,
500
));
ia
->
addOption
(
hint_opt
);
sol
->
addOption
(
ia
);
...
...
@@ -717,7 +718,8 @@ TEST_F(Dhcpv6SrvTest, SolicitHint) {
ASSERT_TRUE
(
addr
);
// check that we've got the address we requested
checkIAAddr
(
addr
,
hint
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr
,
hint
,
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
// check DUIDs
checkServerId
(
reply
,
srv
.
getServerID
());
...
...
@@ -747,7 +749,7 @@ TEST_F(Dhcpv6SrvTest, SolicitInvalidHint) {
sol
->
setRemoteAddr
(
IOAddress
(
"fe80::abcd"
));
boost
::
shared_ptr
<
Option6IA
>
ia
=
generateIA
(
234
,
1500
,
3000
);
IOAddress
hint
(
"2001:db8:1::cafe:babe"
);
ASSERT_FALSE
(
subnet_
->
inPool
(
hint
));
ASSERT_FALSE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
hint
));
OptionPtr
hint_opt
(
new
Option6IAAddr
(
D6O_IAADDR
,
hint
,
300
,
500
));
ia
->
addOption
(
hint_opt
);
sol
->
addOption
(
ia
);
...
...
@@ -766,8 +768,9 @@ TEST_F(Dhcpv6SrvTest, SolicitInvalidHint) {
ASSERT_TRUE
(
addr
);
// Check that the assigned address is indeed from the configured pool
checkIAAddr
(
addr
,
addr
->
getAddress
(),
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
EXPECT_TRUE
(
subnet_
->
inPool
(
addr
->
getAddress
()));
checkIAAddr
(
addr
,
addr
->
getAddress
(),
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
EXPECT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
addr
->
getAddress
()));
// check DUIDs
checkServerId
(
reply
,
srv
.
getServerID
());
...
...
@@ -830,9 +833,12 @@ TEST_F(Dhcpv6SrvTest, ManySolicits) {
ASSERT_TRUE
(
addr3
);
// Check that the assigned address is indeed from the configured pool
checkIAAddr
(
addr1
,
addr1
->
getAddress
(),
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr2
,
addr2
->
getAddress
(),
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr3
,
addr3
->
getAddress
(),
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr1
,
addr1
->
getAddress
(),
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr2
,
addr2
->
getAddress
(),
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr3
,
addr3
->
getAddress
(),
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
// check DUIDs
checkServerId
(
reply1
,
srv
.
getServerID
());
...
...
@@ -876,7 +882,7 @@ TEST_F(Dhcpv6SrvTest, RequestBasic) {
// with a valid hint
IOAddress
hint
(
"2001:db8:1:1::dead:beef"
);
ASSERT_TRUE
(
subnet_
->
inPool
(
hint
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
hint
));
OptionPtr
hint_opt
(
new
Option6IAAddr
(
D6O_IAADDR
,
hint
,
300
,
500
));
ia
->
addOption
(
hint_opt
);
req
->
addOption
(
ia
);
...
...
@@ -896,12 +902,14 @@ TEST_F(Dhcpv6SrvTest, RequestBasic) {
ASSERT_TRUE
(
tmp
);
// check that IA_NA was returned and that there's an address included
boost
::
shared_ptr
<
Option6IAAddr
>
addr
=
checkIA_NA
(
reply
,
234
,
subnet_
->
getT1
(),
subnet_
->
getT2
());
boost
::
shared_ptr
<
Option6IAAddr
>
addr
=
checkIA_NA
(
reply
,
234
,
subnet_
->
getT1
(),
subnet_
->
getT2
());
ASSERT_TRUE
(
addr
);
// check that we've got the address we requested
checkIAAddr
(
addr
,
hint
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr
,
hint
,
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
// check DUIDs
checkServerId
(
reply
,
srv
.
getServerID
());
...
...
@@ -974,9 +982,12 @@ TEST_F(Dhcpv6SrvTest, ManyRequests) {
ASSERT_TRUE
(
addr3
);
// Check that the assigned address is indeed from the configured pool
checkIAAddr
(
addr1
,
addr1
->
getAddress
(),
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr2
,
addr2
->
getAddress
(),
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr3
,
addr3
->
getAddress
(),
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr1
,
addr1
->
getAddress
(),
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr2
,
addr2
->
getAddress
(),
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr3
,
addr3
->
getAddress
(),
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
// check DUIDs
checkServerId
(
reply1
,
srv
.
getServerID
());
...
...
@@ -1014,7 +1025,7 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
addr
));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
...
...
@@ -1065,7 +1076,8 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) {
ASSERT_TRUE
(
addr_opt
);
// Check that we've got the address we requested
checkIAAddr
(
addr_opt
,
addr
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
checkIAAddr
(
addr_opt
,
addr
,
Lease
::
TYPE_NA
,
subnet_
->
getPreferred
(),
subnet_
->
getValid
());
// Check DUIDs
checkServerId
(
reply
,
srv
.
getServerID
());
...
...
@@ -1111,7 +1123,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
const
uint32_t
bogus_iaid
=
456
;
// Quick sanity check that the address we're about to use is ok
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
addr
));
// GenerateClientId() also sets duid_
OptionPtr
clientid
=
generateClientId
();
...
...
@@ -1218,7 +1230,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
addr
));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
...
...
@@ -1299,7 +1311,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
const
uint32_t
bogus_iaid
=
456
;
// Quick sanity check that the address we're about to use is ok
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
addr
));
// GenerateClientId() also sets duid_
OptionPtr
clientid
=
generateClientId
();
...
...
src/bin/dhcp6/tests/dhcp6_test_utils.h
View file @
e0966086
...
...
@@ -358,6 +358,7 @@ public:
// and lifetime values match the configured subnet
void
checkIAAddr
(
const
boost
::
shared_ptr
<
Option6IAAddr
>&
addr
,
const
IOAddress
&
expected_addr
,
Lease
::
Type
type
,
uint32_t
/* expected_preferred */
,
uint32_t
/* expected_valid */
)
{
...
...
@@ -365,7 +366,7 @@ public:
// Note that when comparing addresses, we compare the textual
// representation. IOAddress does not support being streamed to
// an ostream, which means it can't be used in EXPECT_EQ.
EXPECT_TRUE
(
subnet_
->
inPool
(
addr
->
getAddress
()));
EXPECT_TRUE
(
subnet_
->
inPool
(
type
,
addr
->
getAddress
()));
EXPECT_EQ
(
expected_addr
.
toText
(),
addr
->
getAddress
().
toText
());
EXPECT_EQ
(
addr
->
getPreferred
(),
subnet_
->
getPreferred
());
EXPECT_EQ
(
addr
->
getValid
(),
subnet_
->
getValid
());
...
...
src/bin/dhcp6/tests/hooks_unittest.cc
View file @
e0966086
...
...
@@ -1047,7 +1047,7 @@ TEST_F(HooksDhcpv6SrvTest, subnet_select_change) {
// Advertised address must belong to the second pool (in subnet's range,
// in dynamic pool)
EXPECT_TRUE
((
*
subnets
)[
1
]
->
inRange
(
addr_opt
->
getAddress
()));
EXPECT_TRUE
((
*
subnets
)[
1
]
->
inPool
(
addr_opt
->
getAddress
()));
EXPECT_TRUE
((
*
subnets
)[
1
]
->
inPool
(
Lease
::
TYPE_NA
,
addr_opt
->
getAddress
()));
}
// This test verifies that incoming (positive) RENEW can be handled properly,
...
...
@@ -1066,7 +1066,7 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_renew) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
addr
));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
...
...
@@ -1163,7 +1163,7 @@ TEST_F(HooksDhcpv6SrvTest, leaseUpdate_lease6_renew) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
addr
));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
...
...
@@ -1254,7 +1254,7 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
addr
));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
...
...
@@ -1330,7 +1330,7 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
addr
));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
...
...
@@ -1411,7 +1411,7 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
OptionPtr
clientid
=
generateClientId
();
// Check that the address we are about to use is indeed in pool
ASSERT_TRUE
(
subnet_
->
inPool
(
addr
));
ASSERT_TRUE
(
subnet_
->
inPool
(
Lease
::
TYPE_NA
,
addr
));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
...
...
src/lib/dhcpsrv/alloc_engine.cc
View file @
e0966086
...
...
@@ -282,16 +282,12 @@ AllocEngine::AllocEngine(AllocType engine_type, unsigned int attempts,
}
Lease6Collection
AllocEngine
::
allocateAddress6
(
const
Subnet6Ptr
&
subnet
,
const
DuidPtr
&
duid
,
uint32_t
iaid
,
const
IOAddress
&
hint
,
Lease
::
Type
type
,
const
bool
fwd_dns_update
,
const
bool
rev_dns_update
,
const
std
::
string
&
hostname
,
bool
fake_allocation
,
const
isc
::
hooks
::
CalloutHandlePtr
&
callout_handle
)
{
AllocEngine
::
allocateLease6
(
const
Subnet6Ptr
&
subnet
,
const
DuidPtr
&
duid
,
uint32_t
iaid
,
const
IOAddress
&
hint
,
Lease
::
Type
type
,
const
bool
fwd_dns_update
,
const
bool
rev_dns_update
,
const
std
::
string
&
hostname
,
bool
fake_allocation
,
const
isc
::
hooks
::
CalloutHandlePtr
&
callout_handle
)
{
try
{
AllocatorPtr
allocator
=
getAllocator
(
type
);
...
...
@@ -445,16 +441,12 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
}
Lease4Ptr
AllocEngine
::
allocateAddress4
(
const
SubnetPtr
&
subnet
,
const
ClientIdPtr
&
clientid
,
const
HWAddrPtr
&
hwaddr
,
const
IOAddress
&
hint
,
const
bool
fwd_dns_update
,
const
bool
rev_dns_update
,
const
std
::
string
&
hostname
,
bool
fake_allocation
,
const
isc
::
hooks
::
CalloutHandlePtr
&
callout_handle
,
Lease4Ptr
&
old_lease
)
{
AllocEngine
::
allocateLease4
(
const
SubnetPtr
&
subnet
,
const
ClientIdPtr
&
clientid
,
const
HWAddrPtr
&
hwaddr
,
const
IOAddress
&
hint
,
const
bool
fwd_dns_update
,
const
bool
rev_dns_update
,
const
std
::
string
&
hostname
,
bool
fake_allocation
,
const
isc
::
hooks
::
CalloutHandlePtr
&
callout_handle
,
Lease4Ptr
&
old_lease
)
{
// The NULL pointer indicates that the old lease didn't exist. It may
// be later set to non NULL value if existing lease is found in the
...
...
src/lib/dhcpsrv/alloc_engine.h
View file @
e0966086
...
...
@@ -266,16 +266,13 @@ protected:
///
/// @return Allocated IPv4 lease (or NULL if allocation failed)
Lease4Ptr
allocateAddress4
(
const
SubnetPtr
&
subnet
,
const
ClientIdPtr
&
clientid
,
const
HWAddrPtr
&
hwaddr
,
const
isc
::
asiolink
::
IOAddress
&
hint
,
const
bool
fwd_dns_update
,
const
bool
rev_dns_update
,
const
std
::
string
&
hostname
,
bool
fake_allocation
,
const
isc
::
hooks
::
CalloutHandlePtr
&
callout_handle
,
Lease4Ptr
&
old_lease
);
allocateLease4
(
const
SubnetPtr
&
subnet
,
const
ClientIdPtr
&
clientid
,
const
HWAddrPtr
&
hwaddr
,
const
isc
::
asiolink
::
IOAddress
&
hint
,
const
bool
fwd_dns_update
,
const
bool
rev_dns_update
,
const
std
::
string
&
hostname
,
bool
fake_allocation
,
const
isc
::
hooks
::
CalloutHandlePtr
&
callout_handle
,
Lease4Ptr
&
old_lease
);
/// @brief Renews a IPv4 lease
///
...
...
@@ -335,16 +332,11 @@ protected:
///
/// @return Allocated IPv6 leases (may be empty if allocation failed)
Lease6Collection
allocateAddress6
(
const
Subnet6Ptr
&
subnet
,
const
DuidPtr
&
duid
,
uint32_t
iaid
,
const
isc
::
asiolink
::
IOAddress
&
hint
,
Lease
::
Type
type
,
const
bool
fwd_dns_update
,
const
bool
rev_dns_update
,
const
std
::
string
&
hostname
,
bool
fake_allocation
,
const
isc
::
hooks
::
CalloutHandlePtr
&
callout_handle
);
allocateLease6
(
const
Subnet6Ptr
&
subnet
,
const
DuidPtr
&
duid
,
uint32_t
iaid
,
const
isc
::
asiolink
::
IOAddress
&
hint
,
Lease
::
Type
type
,
const
bool
fwd_dns_update
,
const
bool
rev_dns_update
,
const
std
::
string
&
hostname
,
bool
fake_allocation
,
const
isc
::
hooks
::
CalloutHandlePtr
&
callout_handle
);
/// @brief returns allocator for a given pool type
/// @param type type of pool (V4, IA, TA or PD)
...
...
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
View file @
e0966086
...
...
@@ -194,7 +194,7 @@ public:
}
Lease6Ptr
lease
;
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Address
6
(
subnet_
,
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Lease
6
(
subnet_
,
duid_
,
iaid_
,
hint
,
type
,
false
,
false
,
""
,
fake
,
CalloutHandlePtr
())));
...
...
@@ -248,7 +248,7 @@ public:
// unfortunately it is used already. The same address must not be allocated
// twice.
Lease6Ptr
lease
;
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Address
6
(
subnet_
,
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Lease
6
(
subnet_
,
duid_
,
iaid_
,
requested
,
type
,
false
,
false
,
""
,
false
,
CalloutHandlePtr
())));
...
...
@@ -292,7 +292,7 @@ public:
// supported lease. Allocation engine should ignore it and carry on
// with the normal allocation
Lease6Ptr
lease
;
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Address
6
(
subnet_
,
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Lease
6
(
subnet_
,
duid_
,
iaid_
,
hint
,
type
,
false
,
false
,
""
,
false
,
CalloutHandlePtr
())));
...
...
@@ -494,13 +494,13 @@ TEST_F(AllocEngine6Test, allocateAddress6Nulls) {
// Allocations without subnet are not allowed
Lease6Ptr
lease
;
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Address
6
(
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Lease
6
(
Subnet6Ptr
(),
duid_
,
iaid_
,
IOAddress
(
"::"
),
Lease
::
TYPE_NA
,
false
,
false
,
""
,
false
,
CalloutHandlePtr
())));
ASSERT_FALSE
(
lease
);
// Allocations without DUID are not allowed either
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Address
6
(
subnet_
,
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Lease
6
(
subnet_
,
DuidPtr
(),
iaid_
,
IOAddress
(
"::"
),
Lease
::
TYPE_NA
,
false
,
false
,
""
,
false
,
CalloutHandlePtr
())));
ASSERT_FALSE
(
lease
);
...
...
@@ -749,7 +749,7 @@ TEST_F(AllocEngine6Test, smallPool6) {
cfg_mgr
.
addSubnet6
(
subnet_
);
Lease6Ptr
lease
;
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Address
6
(
subnet_
,
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Lease
6
(
subnet_
,
duid_
,
iaid_
,
IOAddress
(
"::"
),
Lease
::
TYPE_NA
,
false
,
false
,
""
,
false
,
CalloutHandlePtr
())));
...
...
@@ -798,7 +798,7 @@ TEST_F(AllocEngine6Test, outOfAddresses6) {
// There is just a single address in the pool and allocated it to someone
// else, so the allocation should fail
Lease6Ptr
lease2
;
EXPECT_NO_THROW
(
lease2
=
expectOneLease
(
engine
->
allocate
Address
6
(
subnet_
,
EXPECT_NO_THROW
(
lease2
=
expectOneLease
(
engine
->
allocate
Lease
6
(
subnet_
,
duid_
,
iaid_
,
IOAddress
(
"::"
),
Lease
::
TYPE_NA
,
false
,
false
,
""
,
false
,
CalloutHandlePtr
())));
EXPECT_FALSE
(
lease2
);
...
...
@@ -833,7 +833,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
ASSERT_TRUE
(
lease
->
expired
());
// CASE 1: Asking for any address
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Address
6
(
subnet_
,
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Lease
6
(
subnet_
,
duid_
,
iaid_
,
IOAddress
(
"::"
),
Lease
::
TYPE_NA
,
false
,
false
,
""
,
true
,
CalloutHandlePtr
())));
// Check that we got that single lease
...
...
@@ -844,7 +844,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
checkLease6
(
lease
,
Lease
::
TYPE_NA
,
128
);
// CASE 2: Asking specifically for this address
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Address
6
(
subnet_
,
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Lease
6
(
subnet_
,
duid_
,
iaid_
,
addr
,
Lease
::
TYPE_NA
,
false
,
false
,
""
,
true
,
CalloutHandlePtr
())));
...
...
@@ -880,7 +880,7 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) {
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// A client comes along, asking specifically for this address
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Address
6
(
subnet_
,
EXPECT_NO_THROW
(
lease
=
expectOneLease
(
engine
->
allocate
Lease
6
(
subnet_
,
duid_
,
iaid_
,
addr
,
Lease
::
TYPE_NA
,
false
,
false
,
""
,
false
,
CalloutHandlePtr
())));
...
...
@@ -932,7 +932,7 @@ TEST_F(AllocEngine4Test, simpleAlloc4) {
100
,
false
)));
ASSERT_TRUE
(
engine
);
Lease4Ptr
lease
=
engine
->
allocate
Address
4
(
subnet_
,
clientid_
,
hwaddr_
,
Lease4Ptr
lease
=
engine
->
allocate
Lease
4
(
subnet_
,
clientid_
,
hwaddr_
,
IOAddress
(
"0.0.0.0"
),
false
,
true
,
"somehost.example.com."
,
...
...
@@ -962,7 +962,7 @@ TEST_F(AllocEngine4Test, fakeAlloc4) {
100
,
false
)));
ASSERT_TRUE
(
engine
);
Lease4Ptr
lease
=
engine
->
allocate
Address
4
(
subnet_
,
clientid_
,
hwaddr_
,
Lease4Ptr
lease
=
engine
->
allocate
Lease
4
(
subnet_
,
clientid_
,
hwaddr_
,
IOAddress
(
"0.0.0.0"
),
false
,
true
,
"host.example.com."
,
true
,
CalloutHandlePtr
(),
...
...
@@ -991,7 +991,7 @@ TEST_F(AllocEngine4Test, allocWithValidHint4) {
100
,
false
)));
ASSERT_TRUE
(
engine
);
Lease4Ptr
lease
=
engine
->
allocate
Address
4
(
subnet_
,
clientid_
,
hwaddr_
,
Lease4Ptr
lease
=
engine
->
allocate
Lease
4
(
subnet_
,
clientid_
,
hwaddr_
,
IOAddress
(
"192.0.2.105"
),
true
,
true
,
"host.example.com."
,
false
,
CalloutHandlePtr
(),
...
...
@@ -1036,7 +1036,7 @@ TEST_F(AllocEngine4Test, allocWithUsedHint4) {
// Another client comes in and request an address that is in pool, but
// unfortunately it is used already. The same address must not be allocated
// twice.
Lease4Ptr
lease
=
engine
->
allocate
Address
4
(
subnet_
,
clientid_
,
hwaddr_
,
Lease4Ptr
lease
=
engine
->
allocate
Lease
4
(
subnet_
,
clientid_
,
hwaddr_
,
IOAddress
(
"192.0.2.106"
),
false
,
false
,
""
,
false
,
CalloutHandlePtr
(),
...
...
@@ -1077,7 +1077,7 @@ TEST_F(AllocEngine4Test, allocBogusHint4) {
// Client would like to get a 3000::abc lease, which does not belong to any
// supported lease. Allocation engine should ignore it and carry on
// with the normal allocation
Lease4Ptr
lease
=
engine
->
allocate
Address
4
(
subnet_
,
clientid_
,
hwaddr_
,
Lease4Ptr
lease
=
engine
->
allocate
Lease
4
(
subnet_
,
clientid_
,
hwaddr_
,
IOAddress
(
"10.1.1.1"
),
false
,
false
,
""
,
false
,
CalloutHandlePtr
(),
...
...
@@ -1104,14 +1104,14 @@ TEST_F(AllocEngine4Test, allocBogusHint4) {
// This test checks that NULL values are handled properly
TEST_F
(
AllocEngine4Test
,
allocate
Address
4Nulls
)
{
TEST_F
(
AllocEngine4Test
,
allocate
Lease
4Nulls
)
{
boost
::
scoped_ptr
<
AllocEngine
>
engine
;
ASSERT_NO_THROW
(
engine
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_ITERATIVE
,
100
,
false
)));
ASSERT_TRUE
(
engine
);
// Allocations without subnet are not allowed
Lease4Ptr
lease
=
engine
->
allocate
Address
4
(
SubnetPtr
(),
clientid_
,
hwaddr_
,
Lease4Ptr
lease
=
engine
->
allocate
Lease
4
(
SubnetPtr
(),
clientid_
,
hwaddr_
,
IOAddress
(
"0.0.0.0"
),
false
,
false
,
""
,
false
,
CalloutHandlePtr
(),
...
...
@@ -1119,7 +1119,7 @@ TEST_F(AllocEngine4Test, allocateAddress4Nulls) {
EXPECT_FALSE
(
lease
);
// Allocations without HW address are not allowed
lease
=
engine
->
allocate
Address
4
(
subnet_
,
clientid_
,
HWAddrPtr
(),
lease
=
engine
->
allocate
Lease
4
(
subnet_
,
clientid_
,
HWAddrPtr
(),
IOAddress
(
"0.0.0.0"
),
false
,
false
,
""
,
false
,
CalloutHandlePtr
(),
...
...
@@ -1129,7 +1129,7 @@ TEST_F(AllocEngine4Test, allocateAddress4Nulls) {
// Allocations without client-id are allowed
clientid_
=
ClientIdPtr
();
lease
=
engine
->
allocate
Address
4
(
subnet_
,
ClientIdPtr
(),
hwaddr_
,
lease
=
engine
->
allocate
Lease
4
(
subnet_
,
ClientIdPtr
(),
hwaddr_
,
IOAddress
(
"0.0.0.0"
),
true
,
true
,
"myhost.example.com."
,
false
,
CalloutHandlePtr
(),
...
...
@@ -1239,7 +1239,7 @@ TEST_F(AllocEngine4Test, smallPool4) {
subnet_
->
addPool
(
pool_
);
cfg_mgr
.
addSubnet4
(
subnet_
);
Lease4Ptr
lease
=
engine
->
allocate
Address
4
(
subnet_
,
clientid_
,
hwaddr_
,
Lease4Ptr
lease
=
engine
->