From: Piotrek Zadroga Date: Tue, 23 Apr 2024 20:57:36 +0000 (+0200) Subject: [#2820] add tid in some bad-packets logs X-Git-Tag: Kea-2.5.8~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca345208ea78707f233a95705085b3a22346af9b;p=thirdparty%2Fkea.git [#2820] add tid in some bad-packets logs --- diff --git a/src/bin/dhcp4/dhcp4_messages.cc b/src/bin/dhcp4/dhcp4_messages.cc index 9a1069c0b3..647e103294 100644 --- a/src/bin/dhcp4/dhcp4_messages.cc +++ b/src/bin/dhcp4/dhcp4_messages.cc @@ -240,8 +240,8 @@ const char* values[] = { "DHCP4_DECLINE_LEASE", "Received DHCPDECLINE for addr %1 from client %2. The lease will be unavailable for %3 seconds.", "DHCP4_DECLINE_LEASE_MISMATCH", "Received DHCPDECLINE for addr %1 from client %2, but the data doesn't match: received hwaddr: %3, lease hwaddr: %4, received client-id: %5, lease client-id: %6", "DHCP4_DECLINE_LEASE_NOT_FOUND", "Received DHCPDECLINE for addr %1 from client %2, but no such lease found.", - "DHCP4_DEFERRED_OPTION_MISSING", "can find deferred option code %1 in the query", - "DHCP4_DEFERRED_OPTION_UNPACK_FAIL", "An error unpacking the deferred option %1: %2", + "DHCP4_DEFERRED_OPTION_MISSING", "%1: cannot find deferred option code %2 in the query", + "DHCP4_DEFERRED_OPTION_UNPACK_FAIL", "%1: An error unpacking the deferred option %2: %3", "DHCP4_DEPRECATED", "The following mechanism is now deprecated and will be removed in the future: %1", "DHCP4_DEVELOPMENT_VERSION", "This software is a development branch of Kea. It is not recommended for production use.", "DHCP4_DHCP4O6_BAD_PACKET", "received malformed DHCPv4o6 packet: %1", @@ -302,7 +302,7 @@ const char* values[] = { "DHCP4_OPEN_SOCKETS_FAILED", "maximum number of open service sockets attempts: %1, has been exhausted without success", "DHCP4_OPEN_SOCKETS_NO_RECONNECT_CTL", "unexpected error in bind service sockets.", "DHCP4_OPEN_SOCKET_FAIL", "failed to open socket: %1", - "DHCP4_PACKET_DROP_0001", "failed to parse packet from %1 to %2, received over interface %3, reason: %4, %5", + "DHCP4_PACKET_DROP_0001", "%1: failed to parse packet from %2 to %3, received over interface %4, reason: %5, %6", "DHCP4_PACKET_DROP_0002", "%1, from interface %2: no suitable subnet configured for a direct client", "DHCP4_PACKET_DROP_0003", "%1, from interface %2: it contains a foreign server identifier", "DHCP4_PACKET_DROP_0004", "%1, from interface %2: missing msg-type option", diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index 57f75d1d01..c3e5d624f3 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -281,11 +281,11 @@ detected as a duplicate (i.e. another device in the network is using this addres However, the server does not have a record for this address. This may indicate a client's error or a server's purged database. -% DHCP4_DEFERRED_OPTION_MISSING can find deferred option code %1 in the query +% DHCP4_DEFERRED_OPTION_MISSING %1: cannot find deferred option code %2 in the query This debug message is printed when a deferred option cannot be found in the query. -% DHCP4_DEFERRED_OPTION_UNPACK_FAIL An error unpacking the deferred option %1: %2 +% DHCP4_DEFERRED_OPTION_UNPACK_FAIL %1: An error unpacking the deferred option %2: %3 A debug message issued when deferred unpacking of an option failed, making it to be left unpacked in the packet. The first argument is the option code, the second the error. @@ -645,7 +645,7 @@ are unavailable, and the server exits. This error should be reported. A warning message issued when IfaceMgr fails to open and bind a socket. The reason for the failure is appended as an argument of the log message. -% DHCP4_PACKET_DROP_0001 failed to parse packet from %1 to %2, received over interface %3, reason: %4, %5 +% DHCP4_PACKET_DROP_0001 %1: failed to parse packet from %2 to %3, received over interface %4, reason: %5, %6 The DHCPv4 server has received a packet that it is unable to interpret. The reason why the packet is invalid is included in the message. diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 1a63a305b5..a0d6c96b24 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -1334,6 +1334,7 @@ Dhcpv4Srv::processPacket(Pkt4Ptr query, bool allow_answer_park) { } catch (const std::exception& e) { // Failed to parse the packet. LOG_DEBUG(bad_packet4_logger, DBGLVL_PKT_HANDLING, DHCP4_PACKET_DROP_0001) + .arg(query->getLabel()) .arg(query->getRemoteAddr().toText()) .arg(query->getLocalAddr().toText()) .arg(query->getIface()) @@ -4767,6 +4768,7 @@ Dhcpv4Srv::deferredUnpack(Pkt4Ptr& query) { // should not happen but do not crash anyway LOG_DEBUG(bad_packet4_logger, DBG_DHCP4_DETAIL, DHCP4_DEFERRED_OPTION_MISSING) + .arg(query->getLabel()) .arg(code); continue; } @@ -4780,6 +4782,7 @@ Dhcpv4Srv::deferredUnpack(Pkt4Ptr& query) { // Failed to parse the option. LOG_DEBUG(bad_packet4_logger, DBG_DHCP4_DETAIL, DHCP4_DEFERRED_OPTION_UNPACK_FAIL) + .arg(query->getLabel()) .arg(code) .arg(e.what()); continue; diff --git a/src/bin/dhcp6/dhcp6_messages.cc b/src/bin/dhcp6/dhcp6_messages.cc index d5ab190109..c7101553db 100644 --- a/src/bin/dhcp6/dhcp6_messages.cc +++ b/src/bin/dhcp6/dhcp6_messages.cc @@ -286,12 +286,12 @@ const char* values[] = { "DHCP6_PACKET_DROP_DROP_CLASS2", "dropped as member of the special class 'DROP' after host reservation lookup: %1 %2", "DHCP6_PACKET_DROP_DROP_CLASS_EARLY", "dropped as member of the special class 'DROP' after early global host reservations lookup: %1 %2", "DHCP6_PACKET_DROP_DUPLICATE", "dropped as sent by the same client than a packet being processed by another thread: dropped %1 %2 by thread %3 as duplicate of %4 %5 processed by %6", - "DHCP6_PACKET_DROP_PARSE_FAIL", "failed to parse packet from %1 to %2, received over interface %3, reason: %4, %5", + "DHCP6_PACKET_DROP_PARSE_FAIL", "%1: failed to parse packet from %2 to %3, received over interface %4, reason: %5, %6", "DHCP6_PACKET_DROP_SERVERID_MISMATCH", "%1: dropping packet with server identifier: %2, server is using: %3", "DHCP6_PACKET_DROP_UNICAST", "%1: dropping unicast %2 packet as this packet should be sent to multicast", "DHCP6_PACKET_OPTIONS_SKIPPED", "An error unpacking an option, caused subsequent options to be skipped: %1", "DHCP6_PACKET_PROCESS_EXCEPTION", "exception occurred during packet processing", - "DHCP6_PACKET_PROCESS_FAIL", "processing of %1 message received from %2 failed: %3", + "DHCP6_PACKET_PROCESS_FAIL", "%1: processing of %2 message received from %3 failed: %4", "DHCP6_PACKET_PROCESS_STD_EXCEPTION", "exception occurred during packet processing: %1", "DHCP6_PACKET_QUEUE_FULL", "multi-threading packet queue is full", "DHCP6_PACKET_RECEIVED", "%1: %2 (type %3) received from %4 to %5 on interface %6", @@ -332,7 +332,7 @@ const char* values[] = { "DHCP6_RELEASE_PD_FAIL", "%1: failed to release prefix %2/%3 for iaid=%4", "DHCP6_RELEASE_PD_FAIL_WRONG_DUID", "%1: client tried to release prefix %2/%3, but it belongs to another client (duid=%4)", "DHCP6_RELEASE_PD_FAIL_WRONG_IAID", "%1: client tried to release prefix %2/%3, but it used wrong IAID (expected %4, but got %5)", - "DHCP6_REQUIRED_OPTIONS_CHECK_FAIL", "%1 message received from %2 failed the following check: %3", + "DHCP6_REQUIRED_OPTIONS_CHECK_FAIL", "%1: %2 message received from %3 failed the following check: %4", "DHCP6_RESERVATIONS_LOOKUP_FIRST_ENABLED", "Multi-threading is enabled and host reservations lookup is always performed first.", "DHCP6_RESPONSE_DATA", "%1: responding with packet %2 (type %3), packet details: %4", "DHCP6_SERVER_FAILED", "server failed: %1", @@ -350,7 +350,7 @@ const char* values[] = { "DHCP6_SUBNET_DYNAMICALLY_CHANGED", "%1: changed selected subnet %2 to subnet %3 from shared network %4 for client assignments", "DHCP6_SUBNET_SELECTED", "%1: the subnet with ID %2 was selected for client assignments", "DHCP6_SUBNET_SELECTION_FAILED", "%1: failed to select subnet for the client", - "DHCP6_UNKNOWN_MSG_RECEIVED", "received unknown message (type %1) on interface %2", + "DHCP6_UNKNOWN_MSG_RECEIVED", "%1: received unknown message (type %2) on interface %3", "DHCP6_USING_SERVERID", "server is using server-id %1 and stores in the file %2", NULL }; diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index d380eae095..015f60247d 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -633,7 +633,7 @@ the same client by dropping new packets until processing is finished. Packet details and thread identifiers are included for both packets in this warning message. -% DHCP6_PACKET_DROP_PARSE_FAIL failed to parse packet from %1 to %2, received over interface %3, reason: %4, %5 +% DHCP6_PACKET_DROP_PARSE_FAIL %1: failed to parse packet from %2 to %3, received over interface %4, reason: %5, %6 The DHCPv6 server has received a packet that it is unable to interpret. The reason why the packet is invalid is included in the message. @@ -658,7 +658,7 @@ during packet processing that was not caught by other, more specific exception handlers. This packet will be dropped and the server will continue operation. -% DHCP6_PACKET_PROCESS_FAIL processing of %1 message received from %2 failed: %3 +% DHCP6_PACKET_PROCESS_FAIL %1: processing of %2 message received from %3 failed: %4 This is a general catch-all message indicating that the processing of the specified packet type from the indicated address failed. The reason is given in the message. The server will not send a response but will instead ignore the packet. @@ -945,7 +945,7 @@ client and transaction identification information. The second and third argument identify the prefix. The fourth and fifth argument hold the expected IAID and IAID found respectively. -% DHCP6_REQUIRED_OPTIONS_CHECK_FAIL %1 message received from %2 failed the following check: %3 +% DHCP6_REQUIRED_OPTIONS_CHECK_FAIL %1: %2 message received from %3 failed the following check: %4 This message indicates that received DHCPv6 packet is invalid. This may be due to a number of reasons, e.g. the mandatory client-id option is missing, the server-id forbidden in that particular type of message is present, @@ -1047,7 +1047,7 @@ processing will continue, but the response will only contain generic configuration and no addresses or prefixes. The argument includes the client and the transaction identification information. -% DHCP6_UNKNOWN_MSG_RECEIVED received unknown message (type %1) on interface %2 +% DHCP6_UNKNOWN_MSG_RECEIVED %1: received unknown message (type %2) on interface %3 This debug message is printed when server receives a message of unknown type. That could either mean missing functionality or invalid or broken relay or client. The list of formally defined message types is available here: diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index fe8e34e63a..ba8e4cbf3b 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -818,6 +818,7 @@ Dhcpv6Srv::processPacket(Pkt6Ptr query) { } catch (const std::exception &e) { // Failed to parse the packet. LOG_DEBUG(bad_packet6_logger, DBGLVL_PKT_HANDLING, DHCP6_PACKET_DROP_PARSE_FAIL) + .arg(query->getLabel()) .arg(query->getRemoteAddr().toText()) .arg(query->getLocalAddr().toText()) .arg(query->getIface()) @@ -1093,6 +1094,7 @@ Dhcpv6Srv::processLocalizedQuery6(AllocEngine::ClientContext6& ctx) { // disabled by default - it prevents a DDOS attack based on the // sending of problem packets.) LOG_DEBUG(bad_packet6_logger, DBG_DHCP6_BASIC, DHCP6_PACKET_PROCESS_FAIL) + .arg(query->getLabel()) .arg(query->getName()) .arg(query->getRemoteAddr().toText()) .arg(e.what()); @@ -1905,16 +1907,17 @@ Dhcpv6Srv::sanityCheck(const Pkt6Ptr& pkt) { default: LOG_DEBUG(bad_packet6_logger, DBG_DHCP6_BASIC, DHCP6_UNKNOWN_MSG_RECEIVED) + .arg(pkt->getLabel()) .arg(static_cast(pkt->getType())) .arg(pkt->getIface()); } } catch (const RFCViolation& e) { LOG_DEBUG(bad_packet6_logger, DBG_DHCP6_BASIC, DHCP6_REQUIRED_OPTIONS_CHECK_FAIL) + .arg(pkt->getLabel()) .arg(pkt->getName()) .arg(pkt->getRemoteAddr().toText()) .arg(e.what()); - } // Increase the statistic of dropped packets.