]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove duplicate "packet debug" developer/alandekok master
authorAlan T. DeKok <aland@freeradius.org>
Tue, 4 Aug 2026 22:28:41 +0000 (18:28 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 4 Aug 2026 22:36:24 +0000 (18:36 -0400)
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)

src/process/arp/base.c
src/process/bfd/base.c
src/process/dhcpv4/base.c
src/process/dhcpv6/base.c
src/process/dns/base.c
src/process/ldap_sync/base.c
src/process/tacacs/base.c
src/process/vmps/base.c

index d160942217c6e653b9372fd06c43969998891e66..6809f7509fa0b5162b3ee5390b3415eea571459d 100644 (file)
@@ -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);
 }
 
index 95a5923414c28fc35b2e2fd0d46a59396cf2b2a9..15a2458158752f78a5c57fda9856a72f8e28ab4c 100644 (file)
@@ -73,48 +73,6 @@ typedef struct {
 
 #include <freeradius-devel/server/process.h>
 
-/*
- *     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);
 }
 
index 023d9448e1e86ef999dfb6db2ded834369458722..22636b3d03044ab5c72d65f90ee1b2fa9870e8a1 100644 (file)
@@ -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);
        }
index 4a9625bc355f8044bc963a9fe299895134fccc54..8f722390d06be5651496e9583731c6d23c6b3081 100644 (file)
@@ -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);
        }
index 4a0f53d29ae4365a8ce2a96c50f463c723746c20..f23a4fc1a59bdce0326c75e5800dbbee97582d00 100644 (file)
@@ -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);
 }
 
index 74a60e2791a34e7eef1e72b63b543c2a8b841d33..01175f0b117b27a07d985d507f4e31ba72db9f73 100644 (file)
@@ -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] = {
-       "<INVALID>",                            //!< 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);
 }
 
index 9915a48c351ba3282b800186351ee2317526d2b4..79db6c29238bda27c1d47f723d73e95d3d8b6fe5 100644 (file)
@@ -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);
        }
index 8cb7e9b5d22cd9180d869405c01c209c85d72aa0..fa6a76eef9efc89b07cc502cd143171c8370599b 100644 (file)
@@ -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);
 }