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
03e1804d
Commit
03e1804d
authored
Jul 27, 2017
by
Marcin Siodelski
Committed by
Tomek Mrugalski
Aug 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[5315] Added functions that remove subnets from a configuration.
parent
a43f9155
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
102 additions
and
0 deletions
+102
-0
src/lib/dhcpsrv/cfg_subnets4.cc
src/lib/dhcpsrv/cfg_subnets4.cc
+14
-0
src/lib/dhcpsrv/cfg_subnets4.h
src/lib/dhcpsrv/cfg_subnets4.h
+7
-0
src/lib/dhcpsrv/cfg_subnets6.cc
src/lib/dhcpsrv/cfg_subnets6.cc
+14
-0
src/lib/dhcpsrv/cfg_subnets6.h
src/lib/dhcpsrv/cfg_subnets6.h
+7
-0
src/lib/dhcpsrv/dhcpsrv_messages.mes
src/lib/dhcpsrv/dhcpsrv_messages.mes
+7
-0
src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
+28
-0
src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
+25
-0
No files found.
src/lib/dhcpsrv/cfg_subnets4.cc
View file @
03e1804d
...
...
@@ -39,6 +39,20 @@ CfgSubnets4::add(const Subnet4Ptr& subnet) {
subnets_
.
push_back
(
subnet
);
}
void
CfgSubnets4
::
del
(
const
ConstSubnet4Ptr
&
subnet
)
{
auto
&
index
=
subnets_
.
get
<
SubnetIdIndexTag
>
();
auto
subnet_it
=
index
.
find
(
subnet
->
getID
());
if
(
subnet_it
==
index
.
end
())
{
isc_throw
(
BadValue
,
"no subnet with ID of '"
<<
subnet
->
getID
()
<<
"' found"
);
}
index
.
erase
(
subnet_it
);
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_DEL_SUBNET4
)
.
arg
(
subnet
->
toText
());
}
ConstSubnet4Ptr
CfgSubnets4
::
getBySubnetId
(
const
SubnetID
&
subnet_id
)
const
{
const
auto
&
index
=
subnets_
.
get
<
SubnetSubnetIdIndexTag
>
();
...
...
src/lib/dhcpsrv/cfg_subnets4.h
View file @
03e1804d
...
...
@@ -39,6 +39,13 @@ public:
/// duplicates id of an existing subnet.
void
add
(
const
Subnet4Ptr
&
subnet
);
/// @brief Removes subnet from the configuration.
///
/// @param subnet Pointer to the subnet to be removed.
///
/// @throw isc::BadValue if such subnet doesn't exist.
void
del
(
const
ConstSubnet4Ptr
&
subnet
);
/// @brief Returns pointer to the collection of all IPv4 subnets.
///
/// This is used in a hook (subnet4_select), where the hook is able
...
...
src/lib/dhcpsrv/cfg_subnets6.cc
View file @
03e1804d
...
...
@@ -38,6 +38,20 @@ CfgSubnets6::add(const Subnet6Ptr& subnet) {
subnets_
.
push_back
(
subnet
);
}
void
CfgSubnets6
::
del
(
const
ConstSubnet6Ptr
&
subnet
)
{
auto
&
index
=
subnets_
.
get
<
SubnetIdIndexTag
>
();
auto
subnet_it
=
index
.
find
(
subnet
->
getID
());
if
(
subnet_it
==
index
.
end
())
{
isc_throw
(
BadValue
,
"no subnet with ID of '"
<<
subnet
->
getID
()
<<
"' found"
);
}
index
.
erase
(
subnet_it
);
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_DEL_SUBNET6
)
.
arg
(
subnet
->
toText
());
}
ConstSubnet6Ptr
CfgSubnets6
::
getBySubnetId
(
const
SubnetID
&
subnet_id
)
const
{
const
auto
&
index
=
subnets_
.
get
<
SubnetSubnetIdIndexTag
>
();
...
...
src/lib/dhcpsrv/cfg_subnets6.h
View file @
03e1804d
...
...
@@ -40,6 +40,13 @@ public:
/// duplicates id of an existing subnet.
void
add
(
const
Subnet6Ptr
&
subnet
);
/// @brief Removes subnet from the configuration.
///
/// @param subnet Pointer to the subnet to be removed.
///
/// @throw isc::BadValue if such subnet doesn't exist.
void
del
(
const
ConstSubnet6Ptr
&
subnet
);
/// @brief Returns pointer to the collection of all IPv6 subnets.
///
/// This is used in a hook (subnet6_select), where the hook is able
...
...
src/lib/dhcpsrv/dhcpsrv_messages.mes
View file @
03e1804d
...
...
@@ -44,6 +44,13 @@ there is a good reason for it, to avoid increased number of renewals and
a need for rebinding (increase of multicast traffic, which may be received
by multiple servers).
% DHCPSRV_CFGMGR_DEL_SUBNET4 IPv4 subnet %1 removed
This debug message is issued when a subnet is successfully removed from the
server configuration. The argument identifies the subnet removed.
% DHCPSRV_CFGMGR_DEL_SUBNET6 IPv6 subnet %1 removed
This debug message is issued when a subnet is successfully removed from the
% DHCPSRV_CFGMGR_NEW_SUBNET4 a new subnet has been added to configuration: %1
This is an informational message reporting that the configuration has
been extended to include the specified IPv4 subnet.
...
...
src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
View file @
03e1804d
...
...
@@ -74,6 +74,34 @@ TEST(CfgSubnets4Test, getSpecificSubnet) {
EXPECT_FALSE
(
cfg
.
getByPrefix
(
"10.20.30.0/29"
));
}
// This test verifies that a single subnet can be removed from the configuration.
TEST
(
CfgSubnets4Test
,
deleteSubnet
)
{
CfgSubnets4
cfg
;
// Create 3 subnets.
Subnet4Ptr
subnet1
(
new
Subnet4
(
IOAddress
(
"192.0.2.0"
),
26
,
1
,
2
,
3
,
SubnetID
(
5
)));
Subnet4Ptr
subnet2
(
new
Subnet4
(
IOAddress
(
"192.0.3.0"
),
26
,
1
,
2
,
3
,
SubnetID
(
8
)));
Subnet4Ptr
subnet3
(
new
Subnet4
(
IOAddress
(
"192.0.4.0"
),
26
,
1
,
2
,
3
,
SubnetID
(
10
)));
ASSERT_NO_THROW
(
cfg
.
add
(
subnet1
));
ASSERT_NO_THROW
(
cfg
.
add
(
subnet2
));
ASSERT_NO_THROW
(
cfg
.
add
(
subnet3
));
// There should be three subnets.
ASSERT_EQ
(
3
,
cfg
.
getAll
()
->
size
());
// We're going to remove the subnet #2. Let's make sure it exists before
// we remove it.
ASSERT_TRUE
(
cfg
.
getByPrefix
(
"192.0.3.0/26"
));
// Remove the subnet and make sure it is gone.
ASSERT_NO_THROW
(
cfg
.
del
(
subnet2
));
ASSERT_EQ
(
2
,
cfg
.
getAll
()
->
size
());
EXPECT_FALSE
(
cfg
.
getByPrefix
(
"192.0.3.0/26"
));
}
// This test verifies that it is possible to retrieve a subnet using an
// IP address.
TEST
(
CfgSubnets4Test
,
selectSubnetByCiaddr
)
{
...
...
src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
View file @
03e1804d
...
...
@@ -83,6 +83,31 @@ TEST(CfgSubnets6Test, getSpecificSubnet) {
EXPECT_FALSE
(
cfg
.
getByPrefix
(
"3000::/16"
));
}
// This test verifies that a single subnet can be removed from the configuration.
TEST
(
CfgSubnets6Test
,
deleteSubnet
)
{
CfgSubnets6
cfg
;
// Create 3 subnets.
Subnet6Ptr
subnet1
(
new
Subnet6
(
IOAddress
(
"2001:db8:1::"
),
48
,
1
,
2
,
3
,
4
));
Subnet6Ptr
subnet2
(
new
Subnet6
(
IOAddress
(
"2001:db8:2::"
),
48
,
1
,
2
,
3
,
4
));
Subnet6Ptr
subnet3
(
new
Subnet6
(
IOAddress
(
"2001:db8:3::"
),
48
,
1
,
2
,
3
,
4
));
ASSERT_NO_THROW
(
cfg
.
add
(
subnet1
));
ASSERT_NO_THROW
(
cfg
.
add
(
subnet2
));
ASSERT_NO_THROW
(
cfg
.
add
(
subnet3
));
// There should be three subnets.
ASSERT_EQ
(
3
,
cfg
.
getAll
()
->
size
());
// We're going to remove the subnet #2. Let's make sure it exists before
// we remove it.
ASSERT_TRUE
(
cfg
.
getByPrefix
(
"2001:db8:2::/48"
));
// Remove the subnet and make sure it is gone.
ASSERT_NO_THROW
(
cfg
.
del
(
subnet2
));
ASSERT_EQ
(
2
,
cfg
.
getAll
()
->
size
());
EXPECT_FALSE
(
cfg
.
getByPrefix
(
"2001:db8:2::/48"
));
}
// This test checks that the subnet can be selected using a relay agent's
// link address.
TEST
(
CfgSubnets6Test
,
selectSubnetByRelayAddress
)
{
...
...
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