From da6e9cb613c7469798fdb004af59120e3f604343 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 22 Jan 2017 12:35:32 +0100 Subject: [PATCH] more logging for cadet-core subsystem --- src/cadet/gnunet-service-cadet-new_core.c | 77 +++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/cadet/gnunet-service-cadet-new_core.c b/src/cadet/gnunet-service-cadet-new_core.c index 26952f616..6b5a02dc1 100644 --- a/src/cadet/gnunet-service-cadet-new_core.c +++ b/src/cadet/gnunet-service-cadet-new_core.c @@ -173,6 +173,11 @@ route_message (struct CadetPeer *prev, struct GNUNET_MQ_Envelope *env; struct GNUNET_CADET_ConnectionBrokenMessage *bm; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Failed to route message of type %u from %s on connection %s: no route\n", + ntohs (msg->type), + GCP_2s (prev), + GNUNET_sh2s (&cid->connection_of_tunnel)); env = GNUNET_MQ_msg (bm, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); bm->cid = *cid; @@ -184,6 +189,12 @@ route_message (struct CadetPeer *prev, dir = (prev == route->prev.hop) ? &route->next : &route->prev; if (GNUNET_YES == dir->is_ready) { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Routing message of type %u from %s to %s on connection %s\n", + ntohs (msg->type), + GCP_2s (prev), + GNUNET_i2s (GCP_get_id (dir->hop)), + GNUNET_sh2s (&cid->connection_of_tunnel)); dir->is_ready = GNUNET_NO; GCP_send (dir->mqm, GNUNET_MQ_msg_copy (msg)); @@ -193,12 +204,24 @@ route_message (struct CadetPeer *prev, if (NULL != env) { /* Queue full, drop earliest message in queue */ + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Queue full due to new message of type %u from %s to %s on connection %s, dropping old message\n", + ntohs (msg->type), + GCP_2s (prev), + GNUNET_i2s (GCP_get_id (dir->hop)), + GNUNET_sh2s (&cid->connection_of_tunnel)); GNUNET_assert (dir->out_rpos == dir->out_wpos); GNUNET_MQ_discard (env); dir->out_rpos++; if (ROUTE_BUFFER_SIZE == dir->out_rpos) dir->out_rpos = 0; } + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Queueing new message of type %u from %s to %s on connection %s\n", + ntohs (msg->type), + GCP_2s (prev), + GNUNET_i2s (GCP_get_id (dir->hop)), + GNUNET_sh2s (&cid->connection_of_tunnel)); env = GNUNET_MQ_msg_copy (msg); dir->out_buffer[dir->out_wpos] = env; dir->out_wpos++; @@ -261,6 +284,11 @@ destroy_direction (struct RouteDirection *dir) static void destroy_route (struct CadetRoute *route) { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Destroying route from %s to %s of connection %s\n", + GNUNET_i2s (GCP_get_id (route->prev.hop)), + GNUNET_i2s2 (GCP_get_id (route->next.hop)), + GNUNET_sh2s (&route->cid.connection_of_tunnel)); destroy_direction (&route->prev); destroy_direction (&route->next); GNUNET_free (route); @@ -284,6 +312,13 @@ send_broken (struct RouteDirection *target, struct GNUNET_MQ_Envelope *env; struct GNUNET_CADET_ConnectionBrokenMessage *bm; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Notifying %s about BROKEN route at %s-%s of connection %s\n", + GCP_2s (target->hop), + GNUNET_i2s (peer1), + GNUNET_i2s2 (peer2), + GNUNET_sh2s (&cid->connection_of_tunnel)); + env = GNUNET_MQ_msg (bm, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); bm->cid = *cid; @@ -407,6 +442,9 @@ handle_connection_create (void *cls, get_route (&msg->cid)) { /* Duplicate CREATE, pass it on, previous one might have been lost! */ + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Passing on duplicate CREATE message on connection %s\n", + GNUNET_sh2s (&msg->cid.connection_of_tunnel)); route_message (sender, &msg->cid, &msg->header); @@ -423,6 +461,9 @@ handle_connection_create (void *cls, &msg->cid.connection_of_tunnel); if (NULL != cc) { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received duplicate CREATE message on connection %s\n", + GNUNET_sh2s (&msg->cid.connection_of_tunnel)); GCC_handle_duplicate_create (cc); return; } @@ -431,6 +472,11 @@ handle_connection_create (void *cls, pids); origin = GCP_get (&pids[0], GNUNET_YES); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received CREATE message from %s via path %s for connection %s\n", + GCP_2s (origin), + GCPP_2s (path), + GNUNET_sh2s (&msg->cid.connection_of_tunnel)); GCT_add_inbound_connection (GCT_create_tunnel (origin), &msg->cid, path); @@ -446,6 +492,12 @@ handle_connection_create (void *cls, struct GNUNET_MQ_Envelope *env; struct GNUNET_CADET_ConnectionBrokenMessage *bm; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received CONNECTION_CREATE from %s for %s. Next hop %s:%u is down. Sending BROKEN\n", + GCP_2s (sender), + GNUNET_sh2s (&msg->cid.connection_of_tunnel), + GNUNET_i2s (&pids[off + 1]), + off + 1); env = GNUNET_MQ_msg (bm, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); bm->cid = msg->cid; @@ -457,6 +509,12 @@ handle_connection_create (void *cls, } /* Workable route, create routing entry */ + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received CONNECTION_CREATE from %s for %s. Next hop %s:%u is up. Creating route\n", + GCP_2s (sender), + GNUNET_sh2s (&msg->cid.connection_of_tunnel), + GNUNET_i2s (&pids[off + 1]), + off + 1); route = GNUNET_new (struct CadetRoute); route->cid = msg->cid; dir_init (&route->prev, @@ -502,6 +560,9 @@ handle_connection_create_ack (void *cls, GNUNET_break_op (0); return; } + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received CONNECTION_CREATE_ACK for connection %s.\n", + GNUNET_sh2s (&msg->cid.connection_of_tunnel)); GCC_handle_connection_create_ack (cc); return; } @@ -544,6 +605,9 @@ handle_connection_broken (void *cls, GNUNET_break_op (0); return; } + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received CONNECTION_BROKEN for connection %s. Destroying it.\n", + GNUNET_sh2s (&msg->cid.connection_of_tunnel)); GCC_destroy (cc); /* FIXME: also destroy the path up to the specified link! */ @@ -590,11 +654,18 @@ handle_connection_destroy (void *cls, GNUNET_break_op (0); return; } + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received CONNECTION_DESTROY for connection %s. Destroying connection.\n", + GNUNET_sh2s (&msg->cid.connection_of_tunnel)); + GCC_destroy (cc); return; } /* We're just an intermediary peer, route the message along its path */ + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received CONNECTION_DESTROY for connection %s. Destroying route.\n", + GNUNET_sh2s (&msg->cid.connection_of_tunnel)); route = get_route (&msg->cid); route_message (peer, &msg->cid, @@ -741,6 +812,9 @@ core_connect_cb (void *cls, { struct CadetPeer *cp; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "CORE connection to peer %s was established.\n", + GNUNET_i2s (peer)); cp = GCP_get (peer, GNUNET_YES); GCP_set_mq (cp, @@ -762,6 +836,9 @@ core_disconnect_cb (void *cls, { struct CadetPeer *cp = peer_cls; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "CORE connection to peer %s went down.\n", + GNUNET_i2s (peer)); GCP_set_mq (cp, NULL); } -- 2.25.1