From: Alan T. DeKok Date: Tue, 4 Aug 2026 22:28:41 +0000 (-0400) Subject: remove duplicate "packet debug" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7096e6d085151e0880cd6309e7f6cf69fa593d7;p=thirdparty%2Ffreeradius-server.git remove duplicate "packet debug" now that it's being printed in the "call" instruction. This change also cleans up the output. The previous functions mostly did similar things (but not always), and were mostly called from the same stages of packet processing (but not always) --- diff --git a/src/process/arp/base.c b/src/process/arp/base.c index d160942217..6809f7509f 100644 --- a/src/process/arp/base.c +++ b/src/process/arp/base.c @@ -165,25 +165,6 @@ static fr_process_state_t const process_state[] = { }, }; -/* - * Debug the packet if requested. - */ -static void arp_packet_debug(request_t *request, fr_packet_t const *packet, fr_pair_list_t const *list, bool received) -{ - if (!packet) return; - if (!RDEBUG_ENABLED) return; - - log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s", - received ? "Received" : "Sending", - fr_arp_packet_codes[packet->code]); - - if (received || request->parent) { - log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } else { - log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } -} - static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) { fr_process_state_t const *state; @@ -204,8 +185,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const RETURN_UNLANG_FAIL; } - arp_packet_debug(request, request->packet, &request->request_pairs, true); - return state->recv(p_result, mctx, request); } diff --git a/src/process/bfd/base.c b/src/process/bfd/base.c index 95a5923414..15a2458158 100644 --- a/src/process/bfd/base.c +++ b/src/process/bfd/base.c @@ -73,48 +73,6 @@ typedef struct { #include -/* - * Debug the packet if requested. - */ -static void bfd_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received) -{ -#ifdef WITH_IFINDEX_NAME_RESOLUTION - char if_name[IFNAMSIZ]; -#endif - - if (!packet) return; - if (!RDEBUG_ENABLED) return; - - log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s ID %d from %s%pV%s:%i to %s%pV%s:%i " -#ifdef WITH_IFINDEX_NAME_RESOLUTION - "%s%s%s" -#endif - "", - received ? "Received" : "Sending", - fr_bfd_packet_names[packet->code], - packet->id, - packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "", - fr_box_ipaddr(packet->socket.inet.src_ipaddr), - packet->socket.inet.src_ipaddr.af == AF_INET6 ? "]" : "", - packet->socket.inet.src_port, - packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "[" : "", - fr_box_ipaddr(packet->socket.inet.dst_ipaddr), - packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "", - packet->socket.inet.dst_port -#ifdef WITH_IFINDEX_NAME_RESOLUTION - , packet->socket.inet.ifindex ? "via " : "", - packet->socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "", - packet->socket.inet.ifindex ? " " : "" -#endif - ); - - if (received || request->parent) { - log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } else { - log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } -} - RESUME_FLAG(recv_bfd, UNUSED,) { rlm_rcode_t rcode = RESULT_RCODE; @@ -253,7 +211,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const UPDATE_STATE(reply); - bfd_packet_debug(request, request->reply, &request->reply_pairs, false); return state->send(p_result, mctx, request); } @@ -266,8 +223,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const RETURN_UNLANG_FAIL; } - bfd_packet_debug(request, request->packet, &request->request_pairs, true); - return state->recv(p_result, mctx, request); } diff --git a/src/process/dhcpv4/base.c b/src/process/dhcpv4/base.c index 023d9448e1..22636b3d03 100644 --- a/src/process/dhcpv4/base.c +++ b/src/process/dhcpv4/base.c @@ -52,48 +52,6 @@ fr_dict_attr_autoload_t process_dhcpv4_dict_attr[] = { DICT_AUTOLOAD_TERMINATOR }; -/* - * Debug the packet if requested. - */ -static void dhcpv4_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received) -{ -#ifdef WITH_IFINDEX_NAME_RESOLUTION - char if_name[IFNAMSIZ]; -#endif - - if (!packet) return; - if (!RDEBUG_ENABLED) return; - - log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s XID %08x from %s%pV%s:%i to %s%pV%s:%i " -#ifdef WITH_IFINDEX_NAME_RESOLUTION - "%s%s%s" -#endif - "", - received ? "Received" : "Sending", - dhcp_message_types[packet->code], - packet->id, - packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "", - fr_box_ipaddr(packet->socket.inet.src_ipaddr), - packet->socket.inet.src_ipaddr.af == AF_INET6 ? "]" : "", - packet->socket.inet.src_port, - packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "[" : "", - fr_box_ipaddr(packet->socket.inet.dst_ipaddr), - packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "", - packet->socket.inet.dst_port -#ifdef WITH_IFINDEX_NAME_RESOLUTION - , packet->socket.inet.ifindex ? "via " : "", - packet->socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "", - packet->socket.inet.ifindex ? " " : "" -#endif - ); - - if (received || request->parent) { - log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } else { - log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } -} - typedef struct { uint64_t nothing; // so that the next field isn't at offset 0 @@ -447,8 +405,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const RETURN_UNLANG_FAIL; } - dhcpv4_packet_debug(request, request->packet, &request->request_pairs, true); - if (unlikely(request_is_dynamic_client(request))) { return new_client(p_result, mctx, request); } diff --git a/src/process/dhcpv6/base.c b/src/process/dhcpv6/base.c index 4a9625bc35..8f722390d0 100644 --- a/src/process/dhcpv6/base.c +++ b/src/process/dhcpv6/base.c @@ -272,57 +272,6 @@ static const virtual_server_compile_t compile_list[] = { COMPILE_TERMINATOR }; -/* - * Debug the packet if requested. - */ -static void dhcpv6_packet_debug(request_t *request, fr_packet_t const *packet, fr_pair_list_t const *list, bool received) -{ -#ifdef WITH_IFINDEX_NAME_RESOLUTION - char if_name[IFNAMSIZ]; -#endif - char const *module; - - if (!packet) return; - if (!RDEBUG_ENABLED) return; - - /* - * Looks better without module prefix - */ - module = request->module; - request->module = NULL; - - log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s XID %08x from %s%pV%s:%i to %s%pV%s:%i " -#ifdef WITH_IFINDEX_NAME_RESOLUTION - "%s%s%s" -#endif - "", - received ? "Received" : "Sending", - fr_dhcpv6_packet_names[packet->code], - packet->id, - packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "", - fr_box_ipaddr(packet->socket.inet.src_ipaddr), - packet->socket.inet.src_ipaddr.af == AF_INET6 ? "]" : "", - packet->socket.inet.src_port, - packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "[" : "", - fr_box_ipaddr(packet->socket.inet.dst_ipaddr), - packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "", - packet->socket.inet.dst_port -#ifdef WITH_IFINDEX_NAME_RESOLUTION - , packet->socket.inet.ifindex ? "via " : "", - packet->socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "", - packet->socket.inet.ifindex ? " " : "" -#endif - ); - - if (received || request->parent) { - log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } else { - log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } - - request->module = module; -} - /** Keep a copy of header fields to prevent them being tampered with * */ @@ -614,8 +563,6 @@ RESUME(send_to_client) if (unlikely(restore_field_list(request, &fields->client_id) < 0)) goto fail; if (unlikely(restore_field_list(request, &fields->server_id) < 0)) goto fail; - dhcpv6_packet_debug(request, request->reply, &request->reply_pairs, false); - return CALL_RESUME(send_generic); } @@ -711,8 +658,6 @@ RESUME(send_to_relay) if (unlikely(restore_field(request, &fields->peer_address) < 0)) goto fail; if (fields->interface_id && unlikely(restore_field(request, &fields->interface_id) < 0)) goto fail; - dhcpv6_packet_debug(request, request->reply, &request->reply_pairs, false); - return CALL_RESUME(send_generic); } @@ -739,8 +684,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const RETURN_UNLANG_FAIL; } - dhcpv6_packet_debug(request, request->packet, &request->request_pairs, true); - if (unlikely(request_is_dynamic_client(request))) { return new_client(p_result, mctx, request); } diff --git a/src/process/dns/base.c b/src/process/dns/base.c index 4a0f53d29a..f23a4fc1a5 100644 --- a/src/process/dns/base.c +++ b/src/process/dns/base.c @@ -218,28 +218,6 @@ static const virtual_server_compile_t compile_list[] = { COMPILE_TERMINATOR }; -/* - * Debug the packet if requested. - */ -static void dns_packet_debug(request_t *request, fr_packet_t const *packet, fr_pair_list_t const *list, bool received) -{ - if (!packet) return; - if (!RDEBUG_ENABLED) return; - - if ((packet->code & 0x0f) >= FR_DNS_CODE_MAX) return; - - if (!fr_dns_packet_names[packet->code & 0x0f]) return; - - log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s", - received ? "Received" : "Sending", - fr_dns_packet_names[packet->code & 0x0f]); - - if (received || request->parent) { - log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } else { - log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } -} /** Keep a copy of header fields to prevent them being tampered with * @@ -450,12 +428,6 @@ RESUME(send_response) */ dns_fields_restore(request, talloc_get_type_abort(mctx->rctx, process_rctx_t)); - /* - * Do this last, so we show everything - * we'll be sending back. - */ - dns_packet_debug(request, request->reply, &request->reply_pairs, false); - /* * Hack. This is because this stupid framework uses * packet_type values to represent request and response @@ -491,8 +463,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const RETURN_UNLANG_FAIL; } - dns_packet_debug(request, request->packet, &request->request_pairs, true); - return state->recv(p_result, mctx, request); } diff --git a/src/process/ldap_sync/base.c b/src/process/ldap_sync/base.c index 74a60e2791..01175f0b11 100644 --- a/src/process/ldap_sync/base.c +++ b/src/process/ldap_sync/base.c @@ -44,42 +44,6 @@ fr_dict_attr_autoload_t process_ldap_sync_dict_attr[] = { DICT_AUTOLOAD_TERMINATOR }; -static char const *ldap_sync_message_types[FR_LDAP_SYNC_CODE_MAX] = { - "", //!< 0 - "Present", - "Add", - "Modify", - "Delete", - "Entry-Response", - "Cookie-Load", - "Cookie-Load-Response", - "Cookie-Load-Fail", - "Cookie-Store", - "Cookie-Store-Response", -}; - -static void ldap_sync_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received) -{ - - if (!packet) return; - if (!RDEBUG_ENABLED) return; - - log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s", - received ? "Received" : "Sending", - ldap_sync_message_types[packet->code] - ); - - if (received) { - log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } else { - /* - * At higher debug levels, log returned data as well. - */ - log_request_pair_list(L_DBG_LVL_2, request, NULL, list, NULL); - } - -} - typedef struct { uint64_t nothing; // so that the next field isn't at offset 0 @@ -118,8 +82,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const UPDATE_STATE(packet); - ldap_sync_packet_debug(request, request->packet, &request->request_pairs, true); - return state->recv(p_result, mctx, request); } diff --git a/src/process/tacacs/base.c b/src/process/tacacs/base.c index 9915a48c35..79db6c2923 100644 --- a/src/process/tacacs/base.c +++ b/src/process/tacacs/base.c @@ -1047,9 +1047,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const RETURN_UNLANG_FAIL; } - // @todo - debug stuff! -// tacacs_packet_debug(request, request->packet, &request->request_pairs, true); - if (unlikely(request_is_dynamic_client(request))) { return new_client(p_result, mctx, request); } diff --git a/src/process/vmps/base.c b/src/process/vmps/base.c index 8cb7e9b5d2..fa6a76eef9 100644 --- a/src/process/vmps/base.c +++ b/src/process/vmps/base.c @@ -165,48 +165,6 @@ static fr_process_state_t const process_state[] = { }; -/* - * Debug the packet if requested. - */ -static void vmps_packet_debug(request_t *request, fr_packet_t const *packet, fr_pair_list_t const *list, bool received) -{ -#ifdef WITH_IFINDEX_NAME_RESOLUTION - char if_name[IFNAMSIZ]; -#endif - - if (!packet) return; - if (!RDEBUG_ENABLED) return; - - log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s XID %08x from %s%pV%s:%i to %s%pV%s:%i " -#ifdef WITH_IFINDEX_NAME_RESOLUTION - "%s%s%s" -#endif - "", - received ? "Received" : "Sending", - fr_vmps_packet_names[packet->code], - packet->id, - packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "", - fr_box_ipaddr(packet->socket.inet.src_ipaddr), - packet->socket.inet.src_ipaddr.af == AF_INET6 ? "]" : "", - packet->socket.inet.src_port, - packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "[" : "", - fr_box_ipaddr(packet->socket.inet.dst_ipaddr), - packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "", - packet->socket.inet.dst_port -#ifdef WITH_IFINDEX_NAME_RESOLUTION - , packet->socket.inet.ifindex ? "via " : "", - packet->socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "", - packet->socket.inet.ifindex ? " " : "" -#endif - ); - - if (received || request->parent) { - log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } else { - log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); - } -} - static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) { fr_process_state_t const *state; @@ -227,8 +185,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const RETURN_UNLANG_FAIL; } - vmps_packet_debug(request, request->packet, &request->request_pairs, true); - return state->recv(p_result, mctx, request); }