From 4e44b9e3c77ba4d6d5e19e8fc59bb10c3685c6dd Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Mon, 15 Sep 2025 14:24:34 +0200 Subject: [PATCH] [#4096] Created pkt[46]-service-disabled --- doc/sphinx/arm/dhcp4-srv.rst | 9 +++++++ doc/sphinx/arm/dhcp6-srv.rst | 9 +++++++ doc/sphinx/arm/stats.rst | 24 +++++++++++++++++++ src/bin/dhcp4/dhcp4_srv.cc | 6 +++++ .../dhcp4/tests/ctrl_dhcp4_srv_unittest.cc | 1 + .../tests/http_control_socket_unittest.cc | 1 + src/bin/dhcp6/dhcp6_srv.cc | 6 +++++ .../dhcp6/tests/ctrl_dhcp6_srv_unittest.cc | 1 + src/bin/dhcp6/tests/dhcp6_srv_unittest.cc | 2 +- .../tests/http_control_socket_unittest.cc | 1 + 10 files changed, 59 insertions(+), 1 deletion(-) diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index 28701b7c7c..ff1dcae88d 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -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`` diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index 8372a0445d..45abd0304a 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -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`` diff --git a/doc/sphinx/arm/stats.rst b/doc/sphinx/arm/stats.rst index 74236c51bd..40b5df58d0 100644 --- a/doc/sphinx/arm/stats.rst +++ b/doc/sphinx/arm/stats.rst @@ -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, diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 87893bdae8..3dd73ec1d8 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -181,6 +181,7 @@ std::set 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(1)); + isc::stats::StatsMgr::instance().addValue("pkt4-receive-drop", + static_cast(1)); return; } else { if (MultiThreadingMgr::instance().getMode()) { diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index 2f6b161450..11a4adff30 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -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", diff --git a/src/bin/dhcp4/tests/http_control_socket_unittest.cc b/src/bin/dhcp4/tests/http_control_socket_unittest.cc index c3132ded53..ee901f162b 100644 --- a/src/bin/dhcp4/tests/http_control_socket_unittest.cc +++ b/src/bin/dhcp4/tests/http_control_socket_unittest.cc @@ -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", diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 331adcd1ff..78145dedeb 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -241,6 +241,7 @@ std::set 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(1)); + StatsMgr::instance().addValue("pkt6-receive-drop", + static_cast(1)); return; } else { if (MultiThreadingMgr::instance().getMode()) { diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc index e4e9ffa99b..0134ff17ca 100644 --- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc @@ -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", diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc index 58806c63fb..f1d3240e1f 100644 --- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc @@ -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; diff --git a/src/bin/dhcp6/tests/http_control_socket_unittest.cc b/src/bin/dhcp6/tests/http_control_socket_unittest.cc index 37287937a5..a9dae620bc 100644 --- a/src/bin/dhcp6/tests/http_control_socket_unittest.cc +++ b/src/bin/dhcp6/tests/http_control_socket_unittest.cc @@ -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", -- 2.47.3