]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4096] Created pkt[46]-service-disabled
authorFrancis Dupont <fdupont@isc.org>
Mon, 15 Sep 2025 12:24:34 +0000 (14:24 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 18 Sep 2025 17:35:04 +0000 (19:35 +0200)
doc/sphinx/arm/dhcp4-srv.rst
doc/sphinx/arm/dhcp6-srv.rst
doc/sphinx/arm/stats.rst
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/http_control_socket_unittest.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/http_control_socket_unittest.cc

index 28701b7c7c497d145548c727266b10063cc1c9e7..ff1dcae88df24affe7fe91d976bf86ea39b81a97 100644 (file)
@@ -7373,6 +7373,10 @@ The DHCPv4 server supports the following statistics:
    |                                                    |                | ``pkt4-nak-sent`` should be close  |
    |                                                    |                | to ``pkt4-request-received``.      |
    +----------------------------------------------------+----------------+------------------------------------+
+   | pkt4-service-disabled                              | integer        | Number of incoming packets that    |
+   |                                                    |                | were dropped when the DHCP service |
+   |                                                    |                | was disabled.                      |
+   +----------------------------------------------------+----------------+------------------------------------+
    | pkt4-parse-failed                                  | integer        | Number of incoming packets that    |
    |                                                    |                | could not be parsed. A non-zero    |
    |                                                    |                | value of this statistic indicates  |
@@ -7780,6 +7784,11 @@ The DHCPv4 server supports the following statistics:
    |                                                    |                | counter is increased by 1.         |
    +----------------------------------------------------+----------------+------------------------------------+
 
+Dropped incoming packets can be counted in the ``pkt4-receive-drop`` and
+a second counter detailing the drop cause:
+- ``pkt4-service-disabled`` - DHCP service is disabled
+- ``pkt4-parse-failed`` - packet parsing raised a fatal error
+
 .. note::
 
    The pool ID can be configured on each pool by explicitly setting the ``pool-id``
index 8372a0445d970b72daf11c38b86717f7ae628935..45abd0304a794cf1b282deffcb33400329fd3013 100644 (file)
@@ -6952,6 +6952,10 @@ The DHCPv6 server supports the following statistics:
    |                                                   |                | server's server ID, or the packet  |
    |                                                   |                | is malformed.                      |
    +---------------------------------------------------+----------------+------------------------------------+
+   | pkt6-service-disabled                             | integer        | Number of incoming packets that    |
+   |                                                   |                | were dropped when the DHCP service |
+   |                                                   |                | was disabled.                      |
+   +---------------------------------------------------+----------------+------------------------------------+
    | pkt6-parse-failed                                 | integer        | Number of incoming packets that    |
    |                                                   |                | could not be parsed. A non-zero    |
    |                                                   |                | value of this statistic indicates  |
@@ -7680,6 +7684,11 @@ The DHCPv6 server supports the following statistics:
    |                                                   |                | reconfiguration event.             |
    +---------------------------------------------------+----------------+------------------------------------+
 
+Dropped incoming packets can be counted in the ``pkt6-receive-drop`` and
+a second counter detailing the drop cause:
+- ``pkt6-service-disabled`` - DHCP service is disabled
+- ``pkt6-parse-failed`` - packet parsing raised a fatal error
+
 .. note::
 
    The pool ID can be configured on each pool by explicitly setting the ``pool-id``
index 74236c51bdb775e23cad54e714d55a107ba1cfd9..40b5df58d05e103200111073be84596cad21b52c 100644 (file)
@@ -334,6 +334,12 @@ Here is an example response returning all collected statistics:
                    "2023-06-13 20:42:46.616348"
                ]
            ],
+           "pkt4-service-disabled": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616351"
+               ]
+           ],
            "pkt4-unknown-received": [
                [
                    0,
@@ -645,6 +651,12 @@ or
                    "2023-06-13 21:28:57.177747"
                ]
            ],
+           "pkt6-service-disabled": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177747"
+               ]
+           ],
            "pkt6-solicit-received": [
                [
                    0,
@@ -1056,6 +1068,12 @@ Here is an example response returning all collected statistics:
                    "2023-06-13 20:42:46.616348"
                ]
            ],
+           "pkt4-service-disabled": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616351"
+               ]
+           ],
            "pkt4-unknown-received": [
                [
                    0,
@@ -1283,6 +1301,12 @@ or
                    "2023-06-13 21:28:57.177747"
                ]
            ],
+           "pkt6-service-disabled": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177747"
+               ]
+           ],
            "pkt6-solicit-received": [
                [
                    0,
index 87893bdae834541de197c21fc0afb6d3d4540c5d..3dd73ec1d895c681f69289d69eafc259551f2605 100644 (file)
@@ -181,6 +181,7 @@ std::set<std::string> dhcp4_statistics = {
     "pkt4-offer-sent",
     "pkt4-ack-sent",
     "pkt4-nak-sent",
+    "pkt4-service-disabled",
     "pkt4-parse-failed",
     "pkt4-receive-drop",
     "v4-allocation-fail",
@@ -1284,6 +1285,11 @@ Dhcpv4Srv::runOne() {
     if (!network_state_->isServiceEnabled()) {
         LOG_DEBUG(bad_packet4_logger, DBGLVL_PKT_HANDLING, DHCP4_PACKET_DROP_0008)
             .arg(query->getLabel());
+        // Increase the statistics of service disabled and dropped packets.
+        isc::stats::StatsMgr::instance().addValue("pkt4-service-disabled",
+                                                  static_cast<int64_t>(1));
+        isc::stats::StatsMgr::instance().addValue("pkt4-receive-drop",
+                                                  static_cast<int64_t>(1));
         return;
     } else {
         if (MultiThreadingMgr::instance().getMode()) {
index 2f6b161450a5051321b8ee46d07016be4647e1fd..11a4adff305776e1716951dd91f02400f501d3ae 100644 (file)
@@ -628,6 +628,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, controlChannelStats) {
         "pkt4-offer-sent",
         "pkt4-ack-sent",
         "pkt4-nak-sent",
+        "pkt4-service-disabled",
         "pkt4-parse-failed",
         "pkt4-receive-drop",
         "v4-allocation-fail",
index c3132ded537b59c9494a36ad47f9a811475528a7..ee901f162b314005b07a0ce8024cd68aaef9befe 100644 (file)
@@ -939,6 +939,7 @@ BaseCtrlChannelDhcpv4Test::testControlChannelStats() {
         "pkt4-offer-sent",
         "pkt4-ack-sent",
         "pkt4-nak-sent",
+        "pkt4-service-disabled",
         "pkt4-parse-failed",
         "pkt4-receive-drop",
         "v4-allocation-fail",
index 331adcd1ffc8048d3e0c3b397a4c120022ad345a..78145dedebb58f84c4362f7324f6913e78497238 100644 (file)
@@ -241,6 +241,7 @@ std::set<std::string> dhcp6_statistics = {
     "pkt6-reply-sent",
     "pkt6-dhcpv4-response-sent",
     "pkt6-addr-reg-reply-sent",
+    "pkt6-service-disabled",
     "pkt6-parse-failed",
     "pkt6-receive-drop",
     "v6-allocation-fail",
@@ -763,6 +764,11 @@ Dhcpv6Srv::runOne() {
     if (!network_state_->isServiceEnabled()) {
         LOG_DEBUG(bad_packet6_logger, DBGLVL_PKT_HANDLING, DHCP6_PACKET_DROP_DHCP_DISABLED)
             .arg(query->getLabel());
+        // Increase the statistics of service disabled and dropped packets.
+        StatsMgr::instance().addValue("pkt6-service-disabled",
+                                      static_cast<int64_t>(1));
+        StatsMgr::instance().addValue("pkt6-receive-drop",
+                                      static_cast<int64_t>(1));
         return;
     } else {
         if (MultiThreadingMgr::instance().getMode()) {
index e4e9ffa99b3801c9514ba83e2dbd173133dbe324..0134ff17ca64e22332ed36565d6c1a9b16d0e7fd 100644 (file)
@@ -638,6 +638,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, controlChannelStats) {
         "pkt6-reply-sent",
         "pkt6-dhcpv4-response-sent",
         "pkt6-addr-reg-reply-sent",
+        "pkt6-service-disabled",
         "pkt6-parse-failed",
         "pkt6-receive-drop",
         "v6-allocation-fail",
index 58806c63fb162db299fcde2fc9b3517c5ec6697e..f1d3240e1f8b78a601986152781c02c73a38ab93 100644 (file)
@@ -3626,7 +3626,7 @@ TEST_F(Dhcpv6SrvTest, receiveAddrRegInformStat) {
     testReceiveStats(DHCPV6_ADDR_REG_INFORM, "pkt6-addr-reg-inform-received");
 }
 
-// Test checks if reception of a malformed packet increases pkt-parse-failed
+// Test checks if reception of a malformed packet increases pkt6-parse-failed
 // and pkt6-receive-drop
 TEST_F(Dhcpv6SrvTest, receiveParseFailedStat) {
     using namespace isc::stats;
index 37287937a559b3af437710735cafca87ff137d25..a9dae620bcd84c581ae3cbd2450c90268f8bceb7 100644 (file)
@@ -956,6 +956,7 @@ BaseCtrlChannelDhcpv6Test::testControlChannelStats() {
         "pkt6-reply-sent",
         "pkt6-dhcpv4-response-sent",
         "pkt6-addr-reg-reply-sent",
+        "pkt6-service-disabled",
         "pkt6-parse-failed",
         "pkt6-receive-drop",
         "v6-allocation-fail",