]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3337] Made stats responsibility clearer master
authorFrancis Dupont <fdupont@isc.org>
Tue, 14 Oct 2025 10:01:04 +0000 (12:01 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 5 Nov 2025 21:39:48 +0000 (22:39 +0100)
src/bin/dhcp4/dhcp4_hooks.dox
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/dhcp6_hooks.dox
src/bin/dhcp6/dhcp6_srv.cc

index 04f57c10cc568fd9248e61a1ed18c1e5f4b6e2d9..b81b361af1ab9e4a8ca7640d03eb7493e34fc4ae 100644 (file)
@@ -37,7 +37,9 @@
  - Next step status: the action taken by the server when a callout chooses to set
    status to specified value. Actions not listed explicitly are not supported.
    If a callout sets status to unsupported value, this specific value will be
-   ignored and treated as if the status was CONTINUE.
+   ignored and treated as if the status was CONTINUE. If the action is to
+   drop the incoming query it is the responsibilty of the hook to increase
+   statistics.
 
 @section dhcpv4HooksHookPoints Hooks in the DHCPv4 Server
 
index 93fb8d3b2595a3435a6f88254c785f88e912240a..cbec84c2f6f37a460f68ea5cb43025c2b11f8563 100644 (file)
@@ -1371,6 +1371,9 @@ Dhcpv4Srv::processPacket(Pkt4Ptr query, bool allow_answer_park) {
                 .arg(query->getRemoteAddr().toText())
                 .arg(query->getLocalAddr().toText())
                 .arg(query->getIface());
+
+            // Not increasing the statistics of the dropped packets because it
+            // is the callouts' responsibility to increase it.
             return (Pkt4Ptr());;
         }
 
@@ -1388,6 +1391,10 @@ Dhcpv4Srv::processPacket(Pkt4Ptr query, bool allow_answer_park) {
         }
 
         callout_handle->getArgument("query4", query);
+        if (!query) {
+            // Please use the status instead of resetting query!
+            return (Pkt4Ptr());
+        }
     }
 
     // Unpack the packet information unless the buffer4_receive callouts
@@ -1498,10 +1505,16 @@ Dhcpv4Srv::processPacket(Pkt4Ptr query, bool allow_answer_park) {
             LOG_DEBUG(hooks_logger, DBG_DHCP4_HOOKS,
                       DHCP4_HOOK_PACKET_RCVD_SKIP)
                 .arg(query->getLabel());
+            // Not increasing the statistics of the dropped packets because it
+            // is the callouts' responsibility to increase it.
             return (Pkt4Ptr());
         }
 
         callout_handle->getArgument("query4", query);
+        if (!query) {
+            // Please use the status instead of resetting query!
+            return (Pkt4Ptr());
+        }
     }
 
     // Check the DROP special class.
index 3dca3eb908544f11add4d1cff49ac8e3dca5dfed..f11967a6db85d2093873aae68304865d46cecdf1 100644 (file)
@@ -37,7 +37,9 @@
  - Next step status: the action taken by the server when a callout chooses to set
     status to specified value. Actions not listed explicitly are not supported.
    If a callout sets status to unsupported value, this specific value will be
-   ignored and treated as if the status was CONTINUE.
+   ignored and treated as if the status was CONTINUE. If the action is to
+   drop        the incoming query it is the responsibilty of the hook to increase
+   statistics.
 
 @section dhcpv6HooksHookPoints Hooks in the DHCPv6 Server
 
index ce67a47c4505fea70859fa2138f23aa1befc152f..8083a4e17a96729ea4d494070c3ae80fb383f5ef 100644 (file)
@@ -862,10 +862,7 @@ Dhcpv6Srv::processPacket(Pkt6Ptr query) {
                 .arg(query->getIface());
 
             // Not increasing the statistics of the dropped packets because it
-            // is the callouts' responsibility to increase it. There are some
-            // cases when the callouts may elect to not increase the statistics.
-            // For example, packets dropped by the load-balancing algorithm must
-            // not increase the statistics.
+            // is the callouts' responsibility to increase it.
             return (Pkt6Ptr());
         }
 
@@ -980,10 +977,7 @@ Dhcpv6Srv::processPacket(Pkt6Ptr query) {
             LOG_DEBUG(hooks_logger, DBG_DHCP6_HOOKS, DHCP6_HOOK_PACKET_RCVD_SKIP)
                 .arg(query->getLabel());
             // Not increasing the statistics of the dropped packets because it
-            // is the callouts' responsibility to increase it. There are some
-            // cases when the callouts may elect to not increase the statistics.
-            // For example, packets dropped by the load-balancing algorithm must
-            // not increase the statistics.
+            // is the callouts' responsibility to increase it.
             return (Pkt6Ptr());
         }