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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
Adam Osuchowski
Kea
Commits
15df9974
Commit
15df9974
authored
Jul 19, 2015
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[3958] Allocation engine allows for overriding the # of allocation attempts.
parent
3946e8ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
4 deletions
+53
-4
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.cc
+4
-2
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
+4
-2
src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc
src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc
+45
-0
No files found.
src/bin/dhcp4/dhcp4_srv.cc
View file @
15df9974
...
...
@@ -240,8 +240,10 @@ Dhcpv4Srv::Dhcpv4Srv(uint16_t port, const bool use_bcast,
IfaceMgr
::
instance
().
setMatchingPacketFilter
(
direct_response_desired
);
}
// Instantiate allocation engine
alloc_engine_
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_ITERATIVE
,
100
,
// Instantiate allocation engine. The number of allocation attempts equal
// to zero indicates that the allocation engine will use the number of
// attempts depending on the pool size.
alloc_engine_
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_ITERATIVE
,
0
,
false
/* false = IPv4 */
));
// Register hook points
...
...
src/bin/dhcp6/dhcp6_srv.cc
View file @
15df9974
...
...
@@ -212,8 +212,10 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
}
}
// Instantiate allocation engine
alloc_engine_
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_ITERATIVE
,
100
));
// Instantiate allocation engine. The number of allocation attempts equal
// to zero indicates that the allocation engine will use the number of
// attempts depending on the pool size.
alloc_engine_
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_ITERATIVE
,
0
));
/// @todo call loadLibraries() when handling configuration changes
...
...
src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc
View file @
15df9974
...
...
@@ -1610,6 +1610,51 @@ TEST_F(AllocEngine6Test, largePoolOver32bits) {
ASSERT_EQ
(
1
,
leases
.
size
());
}
// This test verifies that it is possible to override the number of allocation
// attempts made by the allocation engine for a single lease.
TEST_F
(
AllocEngine6Test
,
largeAllocationAttemptsOverride
)
{
// Remove the default NA pools.
subnet_
->
delPools
(
Lease
::
TYPE_NA
);
// Add exactly one pool with many addresses.
Pool6Ptr
pool
(
new
Pool6
(
Lease
::
TYPE_NA
,
IOAddress
(
"2001:db8:1::"
),
56
));
subnet_
->
addPool
(
pool
);
// Allocate 5 addresses from the pool configured.
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
DuidPtr
duid
=
DuidPtr
(
new
DUID
(
vector
<
uint8_t
>
(
12
,
static_cast
<
uint8_t
>
(
i
))));
// Get the unique IAID.
const
uint32_t
iaid
=
3568
+
i
;
// Construct the unique address from the pool.
std
::
ostringstream
address
;
address
<<
"2001:db8:1::"
;
address
<<
i
;
// Allocate the leease.
Lease6Ptr
lease
(
new
Lease6
(
Lease
::
TYPE_NA
,
IOAddress
(
address
.
str
()),
duid
,
iaid
,
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
HWAddrPtr
(),
0
));
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
}
// Try to use the allocation engine to allocate the lease. The iterative
// allocator will pick the addresses already allocated until it finds the
// available address. Since, we have restricted the number of attempts the
// allocation should fail.
AllocEngine
engine
(
AllocEngine
::
ALLOC_ITERATIVE
,
3
);
Lease6Collection
leases
=
allocateTest
(
engine
,
pool_
,
IOAddress
(
"::"
),
false
,
true
);
ASSERT_EQ
(
0
,
leases
.
size
());
// This time, lets allow more attempts, and expect that the allocation will
// be successful.
AllocEngine
engine2
(
AllocEngine
::
ALLOC_ITERATIVE
,
6
);
leases
=
allocateTest
(
engine2
,
pool_
,
IOAddress
(
"::"
),
false
,
true
);
ASSERT_EQ
(
1
,
leases
.
size
());
}
};
// namespace test
};
// namespace dhcp
};
// namespace isc
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment