Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
b0756763
Commit
b0756763
authored
Dec 18, 2012
by
Stephen Morris
Browse files
[2524] Add logging to configuration manager
parent
46cf8771
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/cfgmgr.cc
View file @
b0756763
...
...
@@ -14,6 +14,7 @@
#include <asiolink/io_address.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcpsrv_log.h>
using
namespace
isc
::
asiolink
;
using
namespace
isc
::
util
;
...
...
@@ -21,9 +22,6 @@ using namespace isc::util;
namespace
isc
{
namespace
dhcp
{
CfgMgr
&
CfgMgr
::
instance
()
{
static
CfgMgr
cfg_mgr
;
...
...
@@ -42,6 +40,9 @@ CfgMgr::getSubnet6(const isc::asiolink::IOAddress& hint) {
// The server does not need to have a global address (using just link-local
// is ok for DHCPv6 server) from the pool it serves.
if
((
subnets6_
.
size
()
==
1
)
&&
hint
.
getAddress
().
to_v6
().
is_link_local
())
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_ONLY_SUBNET6
)
.
arg
(
subnets6_
[
0
]
->
toText
()).
arg
(
hint
.
toText
());
return
(
subnets6_
[
0
]);
}
...
...
@@ -49,11 +50,16 @@ CfgMgr::getSubnet6(const isc::asiolink::IOAddress& hint) {
for
(
Subnet6Collection
::
iterator
subnet
=
subnets6_
.
begin
();
subnet
!=
subnets6_
.
end
();
++
subnet
)
{
if
((
*
subnet
)
->
inRange
(
hint
))
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_SUBNET6
)
.
arg
((
*
subnet
)
->
toText
()).
arg
(
hint
.
toText
());
return
(
*
subnet
);
}
}
// sorry, we don't support that subnet
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_NO_SUBNET6
)
.
arg
(
hint
.
toText
());
return
(
Subnet6Ptr
());
}
...
...
@@ -65,6 +71,8 @@ Subnet6Ptr CfgMgr::getSubnet6(OptionPtr /*interfaceId*/) {
void
CfgMgr
::
addSubnet6
(
const
Subnet6Ptr
&
subnet
)
{
/// @todo: Check that this new subnet does not cross boundaries of any
/// other already defined subnet.
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_ADD_SUBNET6
)
.
arg
(
subnet
->
toText
());
subnets6_
.
push_back
(
subnet
);
}
...
...
@@ -80,6 +88,9 @@ CfgMgr::getSubnet4(const isc::asiolink::IOAddress& hint) {
// The server does not need to have a global address (using just link-local
// is ok for DHCPv6 server) from the pool it serves.
if
(
subnets4_
.
size
()
==
1
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_ONLY_SUBNET4
)
.
arg
(
subnets4_
[
0
]
->
toText
()).
arg
(
hint
.
toText
());
return
(
subnets4_
[
0
]);
}
...
...
@@ -87,25 +98,34 @@ CfgMgr::getSubnet4(const isc::asiolink::IOAddress& hint) {
for
(
Subnet4Collection
::
iterator
subnet
=
subnets4_
.
begin
();
subnet
!=
subnets4_
.
end
();
++
subnet
)
{
if
((
*
subnet
)
->
inRange
(
hint
))
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_SUBNET4
)
.
arg
((
*
subnet
)
->
toText
()).
arg
(
hint
.
toText
());
return
(
*
subnet
);
}
}
// sorry, we don't support that subnet
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_NO_SUBNET4
)
.
arg
(
hint
.
toText
());
return
(
Subnet4Ptr
());
}
void
CfgMgr
::
addSubnet4
(
const
Subnet4Ptr
&
subnet
)
{
/// @todo: Check that this new subnet does not cross boundaries of any
/// other already defined subnet.
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_ADD_SUBNET4
)
.
arg
(
subnet
->
toText
());
subnets4_
.
push_back
(
subnet
);
}
void
CfgMgr
::
deleteSubnets4
()
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_DELETE_SUBNET4
);
subnets4_
.
clear
();
}
void
CfgMgr
::
deleteSubnets6
()
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_CFGMGR_DELETE_SUBNET6
);
subnets6_
.
clear
();
}
...
...
src/lib/dhcpsrv/dhcpsrv_log.h
View file @
b0756763
...
...
@@ -39,10 +39,16 @@ const int DHCPSRV_DBG_TRACE = DBGLVL_TRACE_BASIC;
/// just record the summary results.
const
int
DHCPSRV_DBG_RESULTS
=
DBGLVL_TRACE_BASIC_DATA
;
/// @brief Additional information
///
/// Record detailed tracing. This is generally reserved for tracing access to
/// the lease database.
const
int
DHCPSRV_DBG_TRACE_DETAIL
=
DBGLVL_TRACE_DETAIL
;
/// @brief Additional information
///
/// Record detailed (and verbose) data on the server.
const
int
DHCPSRV_DBG_
RTT
=
DBGLVL_TRACE_DETAIL_DATA
;
const
int
DHCPSRV_DBG_
TRACE_DETAIL_DATA
=
DBGLVL_TRACE_DETAIL_DATA
;
///@}
...
...
src/lib/dhcpsrv/dhcpsrv_messages.mes
View file @
b0756763
...
...
@@ -14,6 +14,52 @@
$NAMESPACE isc::dhcp
% DHCPSRV_CFGMGR_ADD_SUBNET4 adding subnet %1
A debug message reported when the DHCP configuration manager is adding the
specified IPv4 subnet to its database.
% DHCPSRV_CFGMGR_ADD_SUBNET6 adding subnet %1
A debug message reported when the DHCP configuration manager is adding the
specified IPv6 subnet to its database.
% DHCPSRV_CFGMGR_DELETE_SUBNET4 deleting all IPv4 subnets
A debug message noting that the DHCP configuration manager has deleted all IPv4
subnets in its database.
% DHCPSRV_CFGMGR_DELETE_SUBNET6 deleting all IPv6 subnets
A debug message noting that the DHCP configuration manager has deleted all IPv6
subnets in its database.
% DHCPSRV_CFGMGR_NO_SUBNET4 no suitable subnet is defined for address hint %1
This debug message is output when the DHCP configuration manager has received
a request for an IPv4 subnet for the specified address, but no such
subnet exists.
% DHCPSRV_CFGMGR_NO_SUBNET6 no suitable subnet is defined for address hint %1
This debug message is output when the DHCP configuration manager has received
a request for an IPv6 subnet for the specified address, but no such
subnet exists.
% DHCPSRV_CFGMGR_ONLY_SUBNET4 retrieved subnet %1 for address hint %2
This is a debug message reporting that the DHCP configuration manager has
returned the specified IPv4 subnet when given the address hint specified
because it is the only subnet defined.
% DHCPSRV_CFGMGR_ONLY_SUBNET6 retrieved subnet %1 for address hint %2
This is a debug message reporting that the DHCP configuration manager has
returned the specified IPv6 subnet when given the address hint specified
because it is the only subnet defined.
% DHCPSRV_CFGMGR_SUBNET4 retrieved subnet %1 for address hint %2
This is a debug message reporting that the DHCP configuration manager has
returned the specified IPv4 subnet when given the address hint specified
as the address is within the subnet.
% DHCPSRV_CFGMGR_SUBNET6 retrieved subnet %1 for address hint %2
This is a debug message reporting that the DHCP configuration manager has
returned the specified IPv6 subnet when given the address hint specified
as the address is within the subnet.
% DHCPSRV_INVALID_ACCESS invalid database access string: %1
This is logged when an attempt has been made to parse a database access string
and the attempt ended in error. The access string in question - which
...
...
src/lib/dhcpsrv/memfile_lease_mgr.cc
View file @
b0756763
...
...
@@ -30,14 +30,14 @@ Memfile_LeaseMgr::~Memfile_LeaseMgr() {
}
bool
Memfile_LeaseMgr
::
addLease
(
const
Lease4Ptr
&
lease
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_ADD_ADDR4
)
.
arg
(
lease
->
addr_
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_ADD_ADDR4
)
.
arg
(
lease
->
addr_
.
toText
());
return
(
false
);
}
bool
Memfile_LeaseMgr
::
addLease
(
const
Lease6Ptr
&
lease
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_ADD_ADDR6
)
.
arg
(
lease
->
addr_
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_ADD_ADDR6
)
.
arg
(
lease
->
addr_
.
toText
());
if
(
getLease6
(
lease
->
addr_
))
{
// there is a lease with specified address already
...
...
@@ -49,43 +49,45 @@ bool Memfile_LeaseMgr::addLease(const Lease6Ptr& lease) {
Lease4Ptr
Memfile_LeaseMgr
::
getLease4
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_GET_ADDR4
)
.
arg
(
addr
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_GET_ADDR4
)
.
arg
(
addr
.
toText
());
return
(
Lease4Ptr
());
}
Lease4Collection
Memfile_LeaseMgr
::
getLease4
(
const
HWAddr
&
hwaddr
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_GET_HWADDR
)
.
arg
(
hardwareAddressString
(
hwaddr
));
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_GET_HWADDR
)
.
arg
(
hardwareAddressString
(
hwaddr
));
return
(
Lease4Collection
());
}
Lease4Ptr
Memfile_LeaseMgr
::
getLease4
(
const
HWAddr
&
hwaddr
,
SubnetID
subnet_id
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_GET_SUBID_HWADDR
)
.
arg
(
subnet_id
).
arg
(
hardwareAddressString
(
hwaddr
));
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_GET_SUBID_HWADDR
).
arg
(
subnet_id
)
.
arg
(
hardwareAddressString
(
hwaddr
));
return
(
Lease4Ptr
());
}
Lease4Collection
Memfile_LeaseMgr
::
getLease4
(
const
ClientId
&
clientid
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_GET_CLIENTID
)
.
arg
(
clientid
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_GET_CLIENTID
)
.
arg
(
clientid
.
toText
());
return
(
Lease4Collection
());
}
Lease4Ptr
Memfile_LeaseMgr
::
getLease4
(
const
ClientId
&
clientid
,
SubnetID
subnet_id
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_GET_SUBID_CLIENTID
)
.
arg
(
subnet_id
).
arg
(
clientid
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_GET_SUBID_CLIENTID
).
arg
(
subnet_id
)
.
arg
(
clientid
.
toText
());
return
(
Lease4Ptr
());
}
Lease6Ptr
Memfile_LeaseMgr
::
getLease6
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_GET_ADDR6
)
.
arg
(
addr
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_GET_ADDR6
)
.
arg
(
addr
.
toText
());
Lease6Storage
::
iterator
l
=
storage6_
.
find
(
addr
);
if
(
l
==
storage6_
.
end
())
{
...
...
@@ -97,15 +99,15 @@ Lease6Ptr Memfile_LeaseMgr::getLease6(
Lease6Collection
Memfile_LeaseMgr
::
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_GET_IAID_DUID
)
.
arg
(
iaid
).
arg
(
duid
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_GET_IAID_DUID
)
.
arg
(
iaid
).
arg
(
duid
.
toText
());
return
(
Lease6Collection
());
}
Lease6Ptr
Memfile_LeaseMgr
::
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID
)
.
arg
(
iaid
).
arg
(
subnet_id
).
arg
(
duid
.
toText
());
...
...
@@ -121,21 +123,21 @@ Lease6Ptr Memfile_LeaseMgr::getLease6(const DUID& duid, uint32_t iaid,
}
void
Memfile_LeaseMgr
::
updateLease4
(
const
Lease4Ptr
&
lease
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_UPDATE_ADDR4
)
.
arg
(
lease
->
addr_
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_UPDATE_ADDR4
)
.
arg
(
lease
->
addr_
.
toText
());
}
void
Memfile_LeaseMgr
::
updateLease6
(
const
Lease6Ptr
&
lease
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_UPDATE_ADDR6
)
.
arg
(
lease
->
addr_
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_UPDATE_ADDR6
)
.
arg
(
lease
->
addr_
.
toText
());
}
bool
Memfile_LeaseMgr
::
deleteLease
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_DELETE_ADDR
)
.
arg
(
addr
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_DELETE_ADDR
)
.
arg
(
addr
.
toText
());
if
(
addr
.
isV4
())
{
// V4 not implemented yet
return
(
false
);
...
...
@@ -161,10 +163,11 @@ std::string Memfile_LeaseMgr::getDescription() const {
void
Memfile_LeaseMgr
::
commit
()
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_COMMIT
);
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MEMFILE_COMMIT
);
}
void
Memfile_LeaseMgr
::
rollback
()
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MEMFILE_ROLLBACK
);
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_ROLLBACK
);
}
src/lib/dhcpsrv/mysql_lease_mgr.cc
View file @
b0756763
...
...
@@ -1115,8 +1115,8 @@ MySqlLeaseMgr::addLeaseCommon(StatementIndex stindex,
bool
MySqlLeaseMgr
::
addLease
(
const
Lease4Ptr
&
lease
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_ADD_ADDR4
)
.
arg
(
lease
->
addr_
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_ADD_ADDR4
)
.
arg
(
lease
->
addr_
.
toText
());
// Create the MYSQL_BIND array for the lease
std
::
vector
<
MYSQL_BIND
>
bind
=
exchange4_
->
createBindForSend
(
lease
);
...
...
@@ -1127,8 +1127,8 @@ MySqlLeaseMgr::addLease(const Lease4Ptr& lease) {
bool
MySqlLeaseMgr
::
addLease
(
const
Lease6Ptr
&
lease
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_ADD_ADDR6
)
.
arg
(
lease
->
addr_
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_ADD_ADDR6
)
.
arg
(
lease
->
addr_
.
toText
());
// Create the MYSQL_BIND array for the lease
std
::
vector
<
MYSQL_BIND
>
bind
=
exchange6_
->
createBindForSend
(
lease
);
...
...
@@ -1266,8 +1266,8 @@ void MySqlLeaseMgr::getLease(StatementIndex stindex, MYSQL_BIND* bind,
Lease4Ptr
MySqlLeaseMgr
::
getLease4
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_GET_ADDR4
)
.
arg
(
addr
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_GET_ADDR4
)
.
arg
(
addr
.
toText
());
// Set up the WHERE clause value
MYSQL_BIND
inbind
[
1
];
...
...
@@ -1288,8 +1288,8 @@ MySqlLeaseMgr::getLease4(const isc::asiolink::IOAddress& addr) const {
Lease4Collection
MySqlLeaseMgr
::
getLease4
(
const
HWAddr
&
hwaddr
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_GET_HWADDR
)
.
arg
(
hardwareAddressString
(
hwaddr
));
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_GET_HWADDR
)
.
arg
(
hardwareAddressString
(
hwaddr
));
// Set up the WHERE clause value
MYSQL_BIND
inbind
[
1
];
...
...
@@ -1318,8 +1318,9 @@ MySqlLeaseMgr::getLease4(const HWAddr& hwaddr) const {
Lease4Ptr
MySqlLeaseMgr
::
getLease4
(
const
HWAddr
&
hwaddr
,
SubnetID
subnet_id
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_GET_SUBID_HWADDR
)
.
arg
(
subnet_id
).
arg
(
hardwareAddressString
(
hwaddr
));
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MYSQL_GET_SUBID_HWADDR
)
.
arg
(
subnet_id
).
arg
(
hardwareAddressString
(
hwaddr
));
// Set up the WHERE clause value
MYSQL_BIND
inbind
[
2
];
...
...
@@ -1352,8 +1353,8 @@ MySqlLeaseMgr::getLease4(const HWAddr& hwaddr, SubnetID subnet_id) const {
Lease4Collection
MySqlLeaseMgr
::
getLease4
(
const
ClientId
&
clientid
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_GET_CLIENTID
)
.
arg
(
clientid
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_GET_CLIENTID
)
.
arg
(
clientid
.
toText
());
// Set up the WHERE clause value
MYSQL_BIND
inbind
[
1
];
...
...
@@ -1376,8 +1377,9 @@ MySqlLeaseMgr::getLease4(const ClientId& clientid) const {
Lease4Ptr
MySqlLeaseMgr
::
getLease4
(
const
ClientId
&
clientid
,
SubnetID
subnet_id
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_GET_SUBID_CLIENTID
)
.
arg
(
subnet_id
).
arg
(
clientid
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MYSQL_GET_SUBID_CLIENTID
)
.
arg
(
subnet_id
).
arg
(
clientid
.
toText
());
// Set up the WHERE clause value
MYSQL_BIND
inbind
[
2
];
...
...
@@ -1404,8 +1406,8 @@ MySqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const {
Lease6Ptr
MySqlLeaseMgr
::
getLease6
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_GET_ADDR6
)
.
arg
(
addr
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_GET_ADDR6
)
.
arg
(
addr
.
toText
());
// Set up the WHERE clause value
MYSQL_BIND
inbind
[
1
];
...
...
@@ -1430,8 +1432,8 @@ MySqlLeaseMgr::getLease6(const isc::asiolink::IOAddress& addr) const {
Lease6Collection
MySqlLeaseMgr
::
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_GET_IAID_DUID
)
.
arg
(
iaid
).
arg
(
duid
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_GET_IAID_DUID
)
.
arg
(
iaid
).
arg
(
duid
.
toText
());
// Set up the WHERE clause value
MYSQL_BIND
inbind
[
2
];
...
...
@@ -1473,8 +1475,9 @@ MySqlLeaseMgr::getLease6(const DUID& duid, uint32_t iaid) const {
Lease6Ptr
MySqlLeaseMgr
::
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_GET_IAID_SUBID_DUID
)
.
arg
(
iaid
).
arg
(
subnet_id
).
arg
(
duid
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MYSQL_GET_IAID_SUBID_DUID
)
.
arg
(
iaid
).
arg
(
subnet_id
).
arg
(
duid
.
toText
());
// Set up the WHERE clause value
MYSQL_BIND
inbind
[
3
];
...
...
@@ -1542,8 +1545,8 @@ void
MySqlLeaseMgr
::
updateLease4
(
const
Lease4Ptr
&
lease
)
{
const
StatementIndex
stindex
=
UPDATE_LEASE4
;
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_UPDATE_ADDR4
)
.
arg
(
lease
->
addr_
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_UPDATE_ADDR4
)
.
arg
(
lease
->
addr_
.
toText
());
// Create the MYSQL_BIND array for the data being updated
std
::
vector
<
MYSQL_BIND
>
bind
=
exchange4_
->
createBindForSend
(
lease
);
...
...
@@ -1567,8 +1570,8 @@ void
MySqlLeaseMgr
::
updateLease6
(
const
Lease6Ptr
&
lease
)
{
const
StatementIndex
stindex
=
UPDATE_LEASE6
;
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_UPDATE_ADDR6
)
.
arg
(
lease
->
addr_
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_UPDATE_ADDR6
)
.
arg
(
lease
->
addr_
.
toText
());
// Create the MYSQL_BIND array for the data being updated
std
::
vector
<
MYSQL_BIND
>
bind
=
exchange6_
->
createBindForSend
(
lease
);
...
...
@@ -1616,8 +1619,8 @@ MySqlLeaseMgr::deleteLeaseCommon(StatementIndex stindex, MYSQL_BIND* bind) {
bool
MySqlLeaseMgr
::
deleteLease
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_DELETE_ADDR
)
.
arg
(
addr
.
toText
());
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_DELETE_ADDR
)
.
arg
(
addr
.
toText
());
// Set up the WHERE clause value
MYSQL_BIND
inbind
[
1
];
...
...
@@ -1671,7 +1674,8 @@ std::pair<uint32_t, uint32_t>
MySqlLeaseMgr
::
getVersion
()
const
{
const
StatementIndex
stindex
=
GET_VERSION
;
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_GET_VERSION
);
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MYSQL_GET_VERSION
);
uint32_t
major
;
// Major version number
uint32_t
minor
;
// Minor version number
...
...
@@ -1719,7 +1723,7 @@ MySqlLeaseMgr::getVersion() const {
void
MySqlLeaseMgr
::
commit
()
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_COMMIT
);
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_COMMIT
);
if
(
mysql_commit
(
mysql_
)
!=
0
)
{
isc_throw
(
DbOperationError
,
"commit failed: "
<<
mysql_error
(
mysql_
));
}
...
...
@@ -1728,7 +1732,7 @@ MySqlLeaseMgr::commit() {
void
MySqlLeaseMgr
::
rollback
()
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
,
DHCPSRV_MYSQL_ROLLBACK
);
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE
_DETAIL
,
DHCPSRV_MYSQL_ROLLBACK
);
if
(
mysql_rollback
(
mysql_
)
!=
0
)
{
isc_throw
(
DbOperationError
,
"rollback failed: "
<<
mysql_error
(
mysql_
));
}
...
...
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
View file @
b0756763
...
...
@@ -42,6 +42,7 @@ public:
}
~
CfgMgrTest
()
{
CfgMgr
::
instance
().
deleteSubnets4
();
CfgMgr
::
instance
().
deleteSubnets6
();
}
};
...
...
@@ -56,8 +57,8 @@ TEST_F(CfgMgrTest, subnet4) {
Subnet4Ptr
subnet2
(
new
Subnet4
(
IOAddress
(
"192.0.2.64"
),
26
,
1
,
2
,
3
));
Subnet4Ptr
subnet3
(
new
Subnet4
(
IOAddress
(
"192.0.2.128"
),
26
,
1
,
2
,
3
));
//
t
here shouldn't be any subnet configured at this stage
EXPECT_EQ
(
Subnet4Ptr
(),
cfg_mgr
.
getSubnet4
(
IOAddress
(
"192.0.2.0"
)));
//
T
here shouldn't be any subnet configured at this stage
EXPECT_EQ
(
Subnet4Ptr
(),
cfg_mgr
.
getSubnet4
(
IOAddress
(
"192.0.2.0"
)));
cfg_mgr
.
addSubnet4
(
subnet1
);
...
...
@@ -75,6 +76,12 @@ TEST_F(CfgMgrTest, subnet4) {
// Try to find an address that does not belong to any subnet
EXPECT_EQ
(
Subnet4Ptr
(),
cfg_mgr
.
getSubnet4
(
IOAddress
(
"192.0.2.192"
)));
// Check that deletion of the subnets works.
cfg_mgr
.
deleteSubnets4
();
EXPECT_EQ
(
Subnet4Ptr
(),
cfg_mgr
.
getSubnet4
(
IOAddress
(
"192.0.2.191"
)));
EXPECT_EQ
(
Subnet4Ptr
(),
cfg_mgr
.
getSubnet4
(
IOAddress
(
"192.0.2.15"
)));
EXPECT_EQ
(
Subnet4Ptr
(),
cfg_mgr
.
getSubnet4
(
IOAddress
(
"192.0.2.85"
)));
}
// This test verifies if the configuration manager is able to hold and return
...
...
@@ -87,8 +94,8 @@ TEST_F(CfgMgrTest, subnet6) {
Subnet6Ptr
subnet2
(
new
Subnet6
(
IOAddress
(
"3000::"
),
48
,
1
,
2
,
3
,
4
));
Subnet6Ptr
subnet3
(
new
Subnet6
(
IOAddress
(
"4000::"
),
48
,
1
,
2
,
3
,
4
));
//
t
here shouldn't be any subnet configured at this stage
EXPECT_EQ
(
Subnet6Ptr
(),
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2000::1"
)));
//
T
here shouldn't be any subnet configured at this stage
EXPECT_EQ
(
Subnet6Ptr
(),
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2000::1"
)));
cfg_mgr
.
addSubnet6
(
subnet1
);
...
...
@@ -106,6 +113,7 @@ TEST_F(CfgMgrTest, subnet6) {
EXPECT_EQ
(
subnet2
,
cfg_mgr
.
getSubnet6
(
IOAddress
(
"3000::dead:beef"
)));
EXPECT_EQ
(
Subnet6Ptr
(),
cfg_mgr
.
getSubnet6
(
IOAddress
(
"5000::1"
)));
// Check that deletion of the subnets works.
cfg_mgr
.
deleteSubnets6
();
EXPECT_EQ
(
Subnet6Ptr
(),
cfg_mgr
.
getSubnet6
(
IOAddress
(
"200::123"
)));
EXPECT_EQ
(
Subnet6Ptr
(),
cfg_mgr
.
getSubnet6
(
IOAddress
(
"3000::123"
)));
...
...
Write
Preview
Supports
Markdown
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