]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2908] Fixed class assigned logs
authorFrancis Dupont <fdupont@isc.org>
Tue, 1 Aug 2023 15:58:41 +0000 (17:58 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 1 Aug 2023 15:58:41 +0000 (17:58 +0200)
ChangeLog
src/bin/dhcp4/dhcp4_messages.cc
src/bin/dhcp4/dhcp4_messages.h
src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/dhcp6_messages.cc
src/bin/dhcp6/dhcp6_messages.h
src/bin/dhcp6/dhcp6_messages.mes
src/bin/dhcp6/dhcp6_srv.cc
src/lib/dhcpsrv/client_class_def.cc

index 38f5877d797423c42b3db0cc5b95f6bf152e75fe..8291a7159e512ea0dd69ad36f29d83dbdf3973e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2172.  [func]          fdupont
+       Completed and imporved logs showing what client classes
+       are assigned to queries during processing.
+       (Gitlab #2908)
+
 Kea 2.5.0 (development) released on July 26, 2023
 
 2171.  [build]         andrei
index 8bb9b02a4d9200baf9e3c099432df4dcbea0037e..ebb35e7f6691b676b05a707c1f98642dd9ff9d48 100644 (file)
@@ -16,6 +16,7 @@ extern const isc::log::MessageID DHCP4_BUFFER_WAIT_SIGNAL = "DHCP4_BUFFER_WAIT_S
 extern const isc::log::MessageID DHCP4_CB_ON_DEMAND_FETCH_UPDATES_FAIL = "DHCP4_CB_ON_DEMAND_FETCH_UPDATES_FAIL";
 extern const isc::log::MessageID DHCP4_CB_PERIODIC_FETCH_UPDATES_FAIL = "DHCP4_CB_PERIODIC_FETCH_UPDATES_FAIL";
 extern const isc::log::MessageID DHCP4_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED = "DHCP4_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED";
+extern const isc::log::MessageID DHCP4_CLASSES_ASSIGNED = "DHCP4_CLASSES_ASSIGNED";
 extern const isc::log::MessageID DHCP4_CLASS_ASSIGNED = "DHCP4_CLASS_ASSIGNED";
 extern const isc::log::MessageID DHCP4_CLASS_UNCONFIGURED = "DHCP4_CLASS_UNCONFIGURED";
 extern const isc::log::MessageID DHCP4_CLASS_UNDEFINED = "DHCP4_CLASS_UNDEFINED";
@@ -186,7 +187,8 @@ const char* values[] = {
     "DHCP4_CB_ON_DEMAND_FETCH_UPDATES_FAIL", "error on demand attempt to fetch configuration updates from the configuration backend(s): %1",
     "DHCP4_CB_PERIODIC_FETCH_UPDATES_FAIL", "error on periodic attempt to fetch configuration updates from the configuration backend(s): %1",
     "DHCP4_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED", "maximum number of configuration fetch attempts: 10, has been exhausted without success",
-    "DHCP4_CLASS_ASSIGNED", "%1: client packet has been assigned to the following class(es): %2",
+    "DHCP4_CLASSES_ASSIGNED", "%1: client packet has been assigned to following classes: %2",
+    "DHCP4_CLASS_ASSIGNED", "%1: client packet has been assigned to the following class: %2",
     "DHCP4_CLASS_UNCONFIGURED", "%1: client packet belongs to an unconfigured class: %2",
     "DHCP4_CLASS_UNDEFINED", "required class %1 has no definition",
     "DHCP4_CLASS_UNTESTABLE", "required class %1 has no test expression",
index 31ffe3e152df4ca089c72b7172e8b6b706de1f54..50a05d6d1f1ecc746b77e2d112d6e71fb613385d 100644 (file)
@@ -17,6 +17,7 @@ extern const isc::log::MessageID DHCP4_BUFFER_WAIT_SIGNAL;
 extern const isc::log::MessageID DHCP4_CB_ON_DEMAND_FETCH_UPDATES_FAIL;
 extern const isc::log::MessageID DHCP4_CB_PERIODIC_FETCH_UPDATES_FAIL;
 extern const isc::log::MessageID DHCP4_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED;
+extern const isc::log::MessageID DHCP4_CLASSES_ASSIGNED;
 extern const isc::log::MessageID DHCP4_CLASS_ASSIGNED;
 extern const isc::log::MessageID DHCP4_CLASS_UNCONFIGURED;
 extern const isc::log::MessageID DHCP4_CLASS_UNDEFINED;
index 5e37eb8a2a6182af509ac6614ae5d7709780126e..3c566477f5098f9cd79e0b41bfe064eceb727e1c 100644 (file)
@@ -65,13 +65,20 @@ The server will continue to operate but won't make any further attempts
 to fetch configuration updates. The administrator must fix the configuration
 in the database and reload (or restart) the server.
 
-% DHCP4_CLASS_ASSIGNED %1: client packet has been assigned to the following class(es): %2
+% DHCP4_CLASSES_ASSIGNED %1: client packet has been assigned to following classes: %2
 This debug message informs that incoming packet has been assigned to specified
-class or classes. This is a normal behavior and indicates successful operation.
+classes. This is a normal behavior and indicates successful operation.
 The first argument specifies the client and transaction identification
 information. The second argument includes all classes to which the
 packet has been assigned.
 
+% DHCP4_CLASS_ASSIGNED %1: client packet has been assigned to the following class: %2
+This debug message informs that incoming packet has been assigned to specified
+class. This is a normal behavior and indicates successful operation.
+The first argument specifies the client and transaction identification
+information. The second argument includes the new class to which the
+packet has been assigned.
+
 % DHCP4_CLASS_UNCONFIGURED %1: client packet belongs to an unconfigured class: %2
 This debug message informs that incoming packet belongs to a class
 which cannot be found in the configuration. Either a hook written
index ec1f56f475648121d6879e7e86c6065ae9cc0b60..fd4221d66514b6c8c0c44cb9fda25cb7c31bd6ed 100644 (file)
@@ -253,11 +253,9 @@ Dhcpv4Exchange::Dhcpv4Exchange(const AllocEnginePtr& alloc_engine,
     evaluateClasses(query, true);
 
     const ClientClasses& classes = query_->getClasses();
-    if (!classes.empty()) {
-        LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASS_ASSIGNED)
-            .arg(query_->getLabel())
-            .arg(classes.toText());
-    }
+    LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASSES_ASSIGNED)
+        .arg(query_->getLabel())
+        .arg(classes.toText());
 
     // Check the DROP special class.
     if (query_->inClass("DROP")) {
@@ -3436,6 +3434,10 @@ Dhcpv4Srv::processDiscover(Pkt4Ptr& discover, AllocEngine::ClientContext4Ptr& co
         // Required classification
         requiredClassify(ex);
 
+        LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASSES_ASSIGNED)
+            .arg(discover->getLabel())
+            .arg(discover->getClasses().toText());
+
         buildCfgOptionList(ex);
         appendRequestedOptions(ex);
         appendRequestedVendorOptions(ex);
@@ -3514,6 +3516,10 @@ Dhcpv4Srv::processRequest(Pkt4Ptr& request, AllocEngine::ClientContext4Ptr& cont
         // Required classification
         requiredClassify(ex);
 
+        LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASSES_ASSIGNED)
+            .arg(request->getLabel())
+            .arg(request->getClasses().toText());
+
         buildCfgOptionList(ex);
         appendRequestedOptions(ex);
         appendRequestedVendorOptions(ex);
@@ -3893,6 +3899,10 @@ Dhcpv4Srv::processInform(Pkt4Ptr& inform, AllocEngine::ClientContext4Ptr& contex
 
     requiredClassify(ex);
 
+    LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASSES_ASSIGNED)
+        .arg(inform->getLabel())
+        .arg(inform->getClasses().toText());
+
     buildCfgOptionList(ex);
     appendRequestedOptions(ex);
     appendRequestedVendorOptions(ex);
@@ -4296,13 +4306,13 @@ void Dhcpv4Srv::requiredClassify(Dhcpv4Exchange& ex) {
             if (status) {
                 LOG_INFO(dhcp4_logger, EVAL_RESULT)
                     .arg(*cclass)
-                    .arg(status);
+                    .arg("true");
                 // Matching: add the class
                 query->addClass(*cclass);
             } else {
                 LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, EVAL_RESULT)
                     .arg(*cclass)
-                    .arg(status);
+                    .arg("false");
             }
         } catch (const Exception& ex) {
             LOG_ERROR(dhcp4_logger, EVAL_RESULT)
index 613d343d9317ab716208a2e048ef897bb5cc5c37..f4fd815f97a8293a9622b47a58b2d3c0e9adf80b 100644 (file)
@@ -17,6 +17,7 @@ extern const isc::log::MessageID DHCP6_BUFFER_WAIT_SIGNAL = "DHCP6_BUFFER_WAIT_S
 extern const isc::log::MessageID DHCP6_CB_ON_DEMAND_FETCH_UPDATES_FAIL = "DHCP6_CB_ON_DEMAND_FETCH_UPDATES_FAIL";
 extern const isc::log::MessageID DHCP6_CB_PERIODIC_FETCH_UPDATES_FAIL = "DHCP6_CB_PERIODIC_FETCH_UPDATES_FAIL";
 extern const isc::log::MessageID DHCP6_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED = "DHCP6_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED";
+extern const isc::log::MessageID DHCP6_CLASSES_ASSIGNED = "DHCP6_CLASSES_ASSIGNED";
 extern const isc::log::MessageID DHCP6_CLASS_ASSIGNED = "DHCP6_CLASS_ASSIGNED";
 extern const isc::log::MessageID DHCP6_CLASS_UNCONFIGURED = "DHCP6_CLASS_UNCONFIGURED";
 extern const isc::log::MessageID DHCP6_CLASS_UNDEFINED = "DHCP6_CLASS_UNDEFINED";
@@ -185,7 +186,8 @@ const char* values[] = {
     "DHCP6_CB_ON_DEMAND_FETCH_UPDATES_FAIL", "error on demand attempt to fetch configuration updates from the configuration backend(s): %1",
     "DHCP6_CB_PERIODIC_FETCH_UPDATES_FAIL", "error on periodic attempt to fetch configuration updates from the configuration backend(s): %1",
     "DHCP6_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED", "maximum number of configuration fetch attempts: 10, has been exhausted without success",
-    "DHCP6_CLASS_ASSIGNED", "%1: client packet has been assigned to the following class(es): %2",
+    "DHCP6_CLASSES_ASSIGNED", "%1: client packet has been assigned to following classes: %2",
+    "DHCP6_CLASS_ASSIGNED", "%1: client packet has been assigned to the following class: %2",
     "DHCP6_CLASS_UNCONFIGURED", "%1: client packet belongs to an unconfigured class: %2",
     "DHCP6_CLASS_UNDEFINED", "required class %1 has no definition",
     "DHCP6_CLASS_UNTESTABLE", "required class %1 has no test expression",
index 8324384ae83164acfe4342a5afe8c161db75caa9..82ab872972c6143e40b8676624163e121059a6cd 100644 (file)
@@ -18,6 +18,7 @@ extern const isc::log::MessageID DHCP6_BUFFER_WAIT_SIGNAL;
 extern const isc::log::MessageID DHCP6_CB_ON_DEMAND_FETCH_UPDATES_FAIL;
 extern const isc::log::MessageID DHCP6_CB_PERIODIC_FETCH_UPDATES_FAIL;
 extern const isc::log::MessageID DHCP6_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED;
+extern const isc::log::MessageID DHCP6_CLASSES_ASSIGNED;
 extern const isc::log::MessageID DHCP6_CLASS_ASSIGNED;
 extern const isc::log::MessageID DHCP6_CLASS_UNCONFIGURED;
 extern const isc::log::MessageID DHCP6_CLASS_UNDEFINED;
index 042be281b7bf680a8664f8a4cb05fb82ad76f362..93a317defdd9efa27ea718ded4cbd1371d6e5df8 100644 (file)
@@ -72,13 +72,20 @@ The server will continue to operate but won't make any further attempts
 to fetch configuration updates. The administrator must fix the configuration
 in the database and reload (or restart) the server.
 
-% DHCP6_CLASS_ASSIGNED %1: client packet has been assigned to the following class(es): %2
+% DHCP6_CLASSES_ASSIGNED %1: client packet has been assigned to following classes: %2
 This debug message informs that incoming packet has been assigned to specified
-class or classes. This is a normal behavior and indicates successful operation.
+classes. This is a normal behavior and indicates successful operation.
 The first argument specifies the client and transaction identification
 information. The second argument includes all classes to which the
 packet has been assigned.
 
+% DHCP6_CLASS_ASSIGNED %1: client packet has been assigned to the following class: %2
+This debug message informs that incoming packet has been assigned to specified
+class. This is a normal behavior and indicates successful operation.
+The first argument specifies the client and transaction identification
+information. The second argument includes the new class to which the
+packet has been assigned.
+
 % DHCP6_CLASS_UNCONFIGURED %1: client packet belongs to an unconfigured class: %2
 This debug message informs that incoming packet belongs to a class
 which cannot be found in the configuration. Either a hook written
index a0f4dc3a088e4e1ad3fbfe8b6e0096a9dffb8844..58fd2f004c08aa1f673e7dfb51d833749bd373e4 100644 (file)
@@ -573,11 +573,9 @@ Dhcpv6Srv::initContext(const Pkt6Ptr& pkt,
     evaluateClasses(pkt, true);
 
     const ClientClasses& classes = pkt->getClasses();
-    if (!classes.empty()) {
-        LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASS_ASSIGNED)
-            .arg(pkt->getLabel())
-            .arg(classes.toText());
-    }
+    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASSES_ASSIGNED)
+        .arg(pkt->getLabel())
+        .arg(classes.toText());
 
     // Check the DROP special class.
     if (pkt->inClass("DROP")) {
@@ -3543,6 +3541,10 @@ Dhcpv6Srv::processSolicit(AllocEngine::ClientContext6& ctx) {
     conditionallySetReservedClientClasses(solicit, ctx);
     requiredClassify(solicit, ctx);
 
+    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASSES_ASSIGNED)
+        .arg(solicit->getLabel())
+        .arg(solicit->getClasses().toText());
+
     copyClientOptions(solicit, response);
     CfgOptionList co_list;
     buildCfgOptionList(solicit, ctx, co_list);
@@ -3581,6 +3583,10 @@ Dhcpv6Srv::processRequest(AllocEngine::ClientContext6& ctx) {
     conditionallySetReservedClientClasses(request, ctx);
     requiredClassify(request, ctx);
 
+    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASSES_ASSIGNED)
+        .arg(request->getLabel())
+        .arg(request->getClasses().toText());
+
     copyClientOptions(request, reply);
     CfgOptionList co_list;
     buildCfgOptionList(request, ctx, co_list);
@@ -3615,6 +3621,10 @@ Dhcpv6Srv::processRenew(AllocEngine::ClientContext6& ctx) {
     conditionallySetReservedClientClasses(renew, ctx);
     requiredClassify(renew, ctx);
 
+    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASSES_ASSIGNED)
+        .arg(renew->getLabel())
+        .arg(renew->getClasses().toText());
+
     copyClientOptions(renew, reply);
     CfgOptionList co_list;
     buildCfgOptionList(renew, ctx, co_list);
@@ -3649,6 +3659,10 @@ Dhcpv6Srv::processRebind(AllocEngine::ClientContext6& ctx) {
     conditionallySetReservedClientClasses(rebind, ctx);
     requiredClassify(rebind, ctx);
 
+    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASSES_ASSIGNED)
+        .arg(rebind->getLabel())
+        .arg(rebind->getClasses().toText());
+
     copyClientOptions(rebind, reply);
     CfgOptionList co_list;
     buildCfgOptionList(rebind, ctx, co_list);
@@ -3670,6 +3684,10 @@ Dhcpv6Srv::processConfirm(AllocEngine::ClientContext6& ctx) {
     conditionallySetReservedClientClasses(confirm, ctx);
     requiredClassify(confirm, ctx);
 
+    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASSES_ASSIGNED)
+        .arg(confirm->getLabel())
+        .arg(confirm->getClasses().toText());
+
     // Get IA_NAs from the Confirm. If there are none, the message is
     // invalid and must be discarded. There is nothing more to do.
     OptionCollection ias = confirm->getOptions(D6O_IA_NA);
@@ -3760,6 +3778,10 @@ Dhcpv6Srv::processRelease(AllocEngine::ClientContext6& ctx) {
     conditionallySetReservedClientClasses(release, ctx);
     requiredClassify(release, ctx);
 
+    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASSES_ASSIGNED)
+        .arg(release->getLabel())
+        .arg(release->getClasses().toText());
+
     // Create an empty Reply message.
     Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, release->getTransid()));
 
@@ -3786,6 +3808,10 @@ Dhcpv6Srv::processDecline(AllocEngine::ClientContext6& ctx) {
     conditionallySetReservedClientClasses(decline, ctx);
     requiredClassify(decline, ctx);
 
+    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASSES_ASSIGNED)
+        .arg(decline->getLabel())
+        .arg(decline->getClasses().toText());
+
     // Create an empty Reply message.
     Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, decline->getTransid()));
 
@@ -4102,6 +4128,10 @@ Dhcpv6Srv::processInfRequest(AllocEngine::ClientContext6& ctx) {
     conditionallySetReservedClientClasses(inf_request, ctx);
     requiredClassify(inf_request, ctx);
 
+    LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASSES_ASSIGNED)
+        .arg(inf_request->getLabel())
+        .arg(inf_request->getClasses().toText());
+
     // Create a Reply packet, with the same trans-id as the client's.
     Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, inf_request->getTransid()));
 
@@ -4230,13 +4260,6 @@ Dhcpv6Srv::setReservedClientClasses(const Pkt6Ptr& pkt,
             pkt->addClass(*cclass);
         }
     }
-
-    const ClientClasses& classes = pkt->getClasses();
-    if (!classes.empty()) {
-        LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASS_ASSIGNED)
-            .arg(pkt->getLabel())
-            .arg(classes.toText());
-    }
 }
 
 void
@@ -4324,13 +4347,13 @@ Dhcpv6Srv::requiredClassify(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx
             if (status) {
                 LOG_INFO(dhcp6_logger, EVAL_RESULT)
                     .arg(*cclass)
-                    .arg(status);
+                    .arg("true");
                 // Matching: add the class
                 pkt->addClass(*cclass);
             } else {
                 LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, EVAL_RESULT)
                     .arg(*cclass)
-                    .arg(status);
+                    .arg("false");
             }
         } catch (const Exception& ex) {
             LOG_ERROR(dhcp6_logger, EVAL_RESULT)
index 465d94f58b1bb8b82ad4ec32dbed71633b4c865b..a5c92aaade08597b19f456c9824c9469584d809e 100644 (file)
@@ -150,13 +150,13 @@ ClientClassDef::test(PktPtr pkt, const ExpressionPtr& expr_ptr) {
         if (status) {
             LOG_INFO(dhcpsrv_logger, EVAL_RESULT)
                 .arg(getName())
-                .arg(status);
+                .arg("true");
             // Matching: add the class
             pkt->addClass(getName());
         } else {
             LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, EVAL_RESULT)
                 .arg(getName())
-                .arg(status);
+                .arg("false");
         }
     } catch (const Exception& ex) {
         LOG_ERROR(dhcpsrv_logger, EVAL_RESULT)