From: Francis Dupont Date: Tue, 1 Aug 2023 15:58:41 +0000 (+0200) Subject: [#2908] Fixed class assigned logs X-Git-Tag: Kea-2.5.1~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8deb3ba5b9ee422e272ff7be10831d15bf351ea8;p=thirdparty%2Fkea.git [#2908] Fixed class assigned logs --- diff --git a/ChangeLog b/ChangeLog index 38f5877d79..8291a7159e 100644 --- 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 diff --git a/src/bin/dhcp4/dhcp4_messages.cc b/src/bin/dhcp4/dhcp4_messages.cc index 8bb9b02a4d..ebb35e7f66 100644 --- a/src/bin/dhcp4/dhcp4_messages.cc +++ b/src/bin/dhcp4/dhcp4_messages.cc @@ -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", diff --git a/src/bin/dhcp4/dhcp4_messages.h b/src/bin/dhcp4/dhcp4_messages.h index 31ffe3e152..50a05d6d1f 100644 --- a/src/bin/dhcp4/dhcp4_messages.h +++ b/src/bin/dhcp4/dhcp4_messages.h @@ -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; diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index 5e37eb8a2a..3c566477f5 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -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 diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index ec1f56f475..fd4221d665 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -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) diff --git a/src/bin/dhcp6/dhcp6_messages.cc b/src/bin/dhcp6/dhcp6_messages.cc index 613d343d93..f4fd815f97 100644 --- a/src/bin/dhcp6/dhcp6_messages.cc +++ b/src/bin/dhcp6/dhcp6_messages.cc @@ -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", diff --git a/src/bin/dhcp6/dhcp6_messages.h b/src/bin/dhcp6/dhcp6_messages.h index 8324384ae8..82ab872972 100644 --- a/src/bin/dhcp6/dhcp6_messages.h +++ b/src/bin/dhcp6/dhcp6_messages.h @@ -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; diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index 042be281b7..93a317defd 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -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 diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index a0f4dc3a08..58fd2f004c 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -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) diff --git a/src/lib/dhcpsrv/client_class_def.cc b/src/lib/dhcpsrv/client_class_def.cc index 465d94f58b..a5c92aaade 100644 --- a/src/lib/dhcpsrv/client_class_def.cc +++ b/src/lib/dhcpsrv/client_class_def.cc @@ -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)