summaryrefslogtreecommitdiffstats
path: root/src/bin/dhcp6
diff options
context:
space:
mode:
authorFranciszek Gorski <fagorski9@gmail.com>2019-09-05 09:35:19 +0200
committerMarcin Siodelski <marcin@isc.org>2019-09-06 11:34:54 +0200
commit3a92d227275d014404c477fa1624c2bc0b03be56 (patch)
treed70bc3d996625cd8ed8cf0d43c2adcb523b25550 /src/bin/dhcp6
parent[755-Kea-DHCP-servers-observations-should-be-reset-to-some-initial] changes t... (diff)
downloadkea-3a92d227275d014404c477fa1624c2bc0b03be56.tar.xz
kea-3a92d227275d014404c477fa1624c2bc0b03be56.zip
[755-Kea-DHCP-servers-observations-should-be-reset] implement required changes to dhcp4 and dhcp6 servers
Diffstat (limited to 'src/bin/dhcp6')
-rw-r--r--src/bin/dhcp6/dhcp6_srv.cc84
-rw-r--r--src/bin/dhcp6/dhcp6_srv.h3
-rw-r--r--src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc6
3 files changed, 39 insertions, 54 deletions
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index a82a0e634e..3da15808e7 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -172,6 +172,28 @@ createStatusCode(const Pkt6& pkt, const Option6IA& ia, const uint16_t status_cod
return (option_status);
}
+ /// Set of all statistics observed in DHCPv6 server
+ std::set<std::string> dhcp6_statistics = {
+ "pkt6-received",
+ "pkt6-solicit-received",
+ "pkt6-advertise-received",
+ "pkt6-request-received",
+ "pkt6-reply-received",
+ "pkt6-renew-received",
+ "pkt6-rebind-received",
+ "pkt6-decline-received",
+ "pkt6-release-received",
+ "pkt6-infrequest-received",
+ "pkt6-dhcpv4-query-received",
+ "pkt6-dhcpv4-response-received",
+ "pkt6-unknown-received",
+ "pkt6-sent",
+ "pkt6-advertise-sent",
+ "pkt6-reply-sent",
+ "pkt6-dhcpv4-response-sent",
+ "pkt6-parse-failed",
+ "pkt6-receive-drop"
+ };
}; // anonymous namespace
namespace isc {
@@ -216,58 +238,24 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t server_port, uint16_t client_port)
LOG_ERROR(dhcp6_logger, DHCP6_SRV_CONSTRUCT_ERROR).arg(e.what());
return;
}
- // Initializing all observations with zero value
- isc::stats::StatsMgr::instance().setValue("pkt6-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-solicit-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-advertise-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-request-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-reply-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-renew-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-rebind-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-release-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-decline-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-infrequest-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-dhcpv4-query-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-dhcpv4-response-received",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-unknown-received",
- static_cast<int64_t>(0));
-
- isc::stats::StatsMgr::instance().setValue("pkt6-sent",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-advertise-sent",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-reply-sent",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-dhcpv4-response-sent",
- static_cast<int64_t>(0));
-
- isc::stats::StatsMgr::instance().setValue("pkt6-parse-failed",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("pkt6-receive-drop",
- static_cast<int64_t>(0));
-
- isc::stats::StatsMgr::instance().setValue("reclaimed-leases",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("declined-addresses",
- static_cast<int64_t>(0));
- isc::stats::StatsMgr::instance().setValue("reclaimed-declined-addresses",
- static_cast<int64_t>(0));
+ // Initializing all observations with default value
+ setPacketStatisticsDefaults();
+
// All done, so can proceed
shutdown_ = false;
}
+void Dhcpv6Srv::setPacketStatisticsDefaults() {
+ std::set<std::string>::iterator it;
+ isc::stats::StatsMgr& stats_mgr = isc::stats::StatsMgr::instance();
+
+ // Iterate over set of observed statistics
+ for (it = dhcp6_statistics.begin(); it != dhcp6_statistics.end(); ++it) {
+ // Initialize them with default value 0
+ stats_mgr.setValue((*it), static_cast<int64_t>(0));
+ }
+}
+
Dhcpv6Srv::~Dhcpv6Srv() {
discardPackets();
try {
diff --git a/src/bin/dhcp6/dhcp6_srv.h b/src/bin/dhcp6/dhcp6_srv.h
index e421832d03..3e44bd0113 100644
--- a/src/bin/dhcp6/dhcp6_srv.h
+++ b/src/bin/dhcp6/dhcp6_srv.h
@@ -89,6 +89,9 @@ public:
/// @brief Destructor. Used during DHCPv6 service shutdown.
virtual ~Dhcpv6Srv();
+ /// @brief This function set to defaults all statistics starting with pkt6-.
+ void setPacketStatisticsDefaults();
+
/// @brief Checks if the server is running in unit test mode.
///
/// @return true if the server is running in unit test mode,
diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
index 8cdb0a4f62..9fff87a2bc 100644
--- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
@@ -1136,8 +1136,6 @@ TEST_F(CtrlChannelDhcpv6SrvTest, controlChannelStats) {
// preparing the schema which check if all statistics are set to zero
std::string stats_get_all = "{ \"arguments\": { "
- "\"declined-addresses\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("declined-addresses")
- ->getInteger().second) + "\" ] ], "
"\"pkt6-advertise-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-advertise-received")
->getInteger().second) + "\" ] ], "
"\"pkt6-advertise-sent\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-advertise-sent")
@@ -1175,10 +1173,6 @@ TEST_F(CtrlChannelDhcpv6SrvTest, controlChannelStats) {
"\"pkt6-solicit-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-solicit-received")
->getInteger().second) + "\" ] ], "
"\"pkt6-unknown-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-unknown-received")
- ->getInteger().second) + "\" ] ], "
- "\"reclaimed-declined-addresses\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("reclaimed-declined-addresses")
- ->getInteger().second) + "\" ] ], "
- "\"reclaimed-leases\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("reclaimed-leases")
->getInteger().second) + "\" ] ] }, "
"\"result\": 0 }";