]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
cmdmon: add debug messages for receiving/sending packets
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 24 Jul 2015 13:19:31 +0000 (15:19 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 28 Jul 2015 09:57:57 +0000 (11:57 +0200)
cmdmon.c

index 5d5c5592a5861e650b5a79866b9764c8c5749d0c..912bc3d5ceda69ffc8b9c108b6cd0b7fe0774ed3 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -686,7 +686,11 @@ transmit_reply(CMD_Reply *msg, union sockaddr_in46 *where_to, int auth_len)
   int tx_message_length;
   int sock_fd;
   socklen_t addrlen;
+  unsigned short port;
+  IPAddr ip;
   
+  UTI_SockaddrToIPAndPort(&where_to->u, &ip, &port);
+
   switch (where_to->u.sa_family) {
     case AF_INET:
       sock_fd = sock_fd4;
@@ -707,12 +711,13 @@ transmit_reply(CMD_Reply *msg, union sockaddr_in46 *where_to, int auth_len)
                   &where_to->u, addrlen);
 
   if (status < 0) {
-    unsigned short port;
-    IPAddr ip;
-
-    UTI_SockaddrToIPAndPort(&where_to->u, &ip, &port);
-    DEBUG_LOG(LOGF_CmdMon, "Could not send response to %s:%hu", UTI_IPToString(&ip), port);
+    DEBUG_LOG(LOGF_CmdMon, "Could not send to %s:%hu fd %d : %s",
+              UTI_IPToString(&ip), port, sock_fd, strerror(errno));
+    return;
   }
+
+  DEBUG_LOG(LOGF_CmdMon, "Sent %d bytes to %s:%hu fd %d", status,
+            UTI_IPToString(&ip), port, sock_fd);
 }
   
 /* ================================================== */
@@ -1551,6 +1556,9 @@ read_from_cmd_socket(void *anything)
       assert(0);
   }
 
+  DEBUG_LOG(LOGF_CmdMon, "Received %d bytes from %s:%hu fd %d",
+            status, UTI_IPToString(&remote_ip), remote_port, sock_fd);
+
   if (!(localhost || ADF_IsAllowed(access_auth_table, &remote_ip))) {
     /* The client is not allowed access, so don't waste any more time
        on him.  Note that localhost is always allowed access