From 8ee3c5121e87d8f25193ae6044d5818f4629fa1e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 10 Jan 2022 14:22:35 +0100 Subject: -DHT: add path signature verification logic; tests pass, but logic remains dead --- .../gnunet-service-testbed_connectionpool.c | 33 +++++++++++----- src/testbed/gnunet-service-testbed_oc.c | 44 +++++++++++++++------- src/testbed/testbed_api_topology.c | 2 +- 3 files changed, 55 insertions(+), 24 deletions(-) (limited to 'src/testbed') diff --git a/src/testbed/gnunet-service-testbed_connectionpool.c b/src/testbed/gnunet-service-testbed_connectionpool.c index 7318971b3..59780e6c1 100644 --- a/src/testbed/gnunet-service-testbed_connectionpool.c +++ b/src/testbed/gnunet-service-testbed_connectionpool.c @@ -445,10 +445,13 @@ connection_ready (void *cls) gh_next = NULL; if (NULL != gh->next) gh_next = search_waiting (entry, gh->next); - GNUNET_CONTAINER_DLL_remove (entry->head_waiting, entry->tail_waiting, gh); + GNUNET_CONTAINER_DLL_remove (entry->head_waiting, + entry->tail_waiting, + gh); gh->connection_ready_called = 1; if (NULL != gh_next) - entry->notify_task = GNUNET_SCHEDULER_add_now (&connection_ready, entry); + entry->notify_task = GNUNET_SCHEDULER_add_now (&connection_ready, + entry); if ((NULL != gh->target) && (NULL != gh->connect_notify_cb)) { GNUNET_CONTAINER_DLL_insert_tail (entry->head_notify, @@ -456,7 +459,9 @@ connection_ready (void *cls) gh); gh->notify_waiting = 1; } - LOG_DEBUG ("Connection ready for handle type %u\n", gh->service); + LOG_DEBUG ("Connection ready to %u for handle type %u\n", + (unsigned int) entry->index, + gh->service); gh->cb (gh->cb_cls, entry->handle_core, entry->handle_transport, @@ -625,7 +630,8 @@ core_peer_connect_cb (void *cls, * @param my_identity ID of this peer, NULL if we failed */ static void -core_startup_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) +core_startup_cb (void *cls, + const struct GNUNET_PeerIdentity *my_identity) { struct PooledConnection *entry = cls; @@ -637,6 +643,10 @@ core_startup_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) GNUNET_assert (NULL == entry->peer_identity); entry->peer_identity = GNUNET_new (struct GNUNET_PeerIdentity); *entry->peer_identity = *my_identity; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Established CORE connection for peer %s (%u)\n", + GNUNET_i2s (my_identity), + (unsigned int) entry->index); if (0 == entry->demand) return; if (NULL != entry->notify_task) @@ -857,19 +867,20 @@ GST_connection_pool_get_handle ( case GST_CONNECTIONPOOL_SERVICE_TRANSPORT: handle = entry->handle_transport; if (NULL != handle) - LOG_DEBUG ("Found TRANSPORT handle for peer %u\n", entry->index); + LOG_DEBUG ("Found TRANSPORT handle for peer %u\n", + entry->index); break; - case GST_CONNECTIONPOOL_SERVICE_CORE: handle = entry->handle_core; if (NULL != handle) - LOG_DEBUG ("Found CORE handle for peer %u\n", entry->index); + LOG_DEBUG ("Found CORE handle for peer %u\n", + entry->index); break; - case GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY: handle = entry->handle_ats_connectivity; if (NULL != handle) - LOG_DEBUG ("Found ATS CONNECTIVITY handle for peer %u\n", entry->index); + LOG_DEBUG ("Found ATS CONNECTIVITY handle for peer %u\n", + entry->index); break; } } @@ -905,7 +916,9 @@ GST_connection_pool_get_handle ( gh->connect_notify_cb = connect_notify_cb; gh->connect_notify_cb_cls = connect_notify_cb_cls; gh->service = service; - GNUNET_CONTAINER_DLL_insert (entry->head_waiting, entry->tail_waiting, gh); + GNUNET_CONTAINER_DLL_insert (entry->head_waiting, + entry->tail_waiting, + gh); if (NULL != handle) { if (NULL == entry->notify_task) diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index 4fe7c20b3..b13a3b7e0 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c @@ -685,15 +685,14 @@ overlay_connect_notify (void *cls, LOG_DEBUG ("Overlay connect notify\n"); if (0 == - memcmp (new_peer, &occ->peer_identity, - sizeof(struct GNUNET_PeerIdentity))) + GNUNET_memcmp (new_peer, + &occ->peer_identity)) return; new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer)); other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); if (0 != - memcmp (new_peer, - &occ->other_peer_identity, - sizeof(struct GNUNET_PeerIdentity))) + GNUNET_memcmp (new_peer, + &occ->other_peer_identity)) { LOG_DEBUG ("Unexpected peer %s connected when expecting peer %s\n", new_peer_str, @@ -1180,19 +1179,23 @@ occ_cache_get_handle_core_cb (void *cls, return; } occ->emsg = NULL; + occ->peer_identity = *my_identity; if (NULL != GNUNET_CORE_get_mq (ch, &occ->other_peer_identity)) { - LOG_DEBUG ("0x%llx: Target peer already connected\n", - (unsigned long long) occ->op_id); + LOG_DEBUG ("0x%llx: Target peer %s already connected\n", + (unsigned long long) occ->op_id, + GNUNET_i2s (&occ->other_peer_identity)); + LOG_DEBUG ("0x%llx: Target peer %s connected\n", + (unsigned long long) occ->op_id, + GNUNET_i2s (&occ->peer_identity)); GNUNET_SCHEDULER_cancel (occ->timeout_task); occ->timeout_task = NULL; send_overlay_connect_success_msg (occ); occ->cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup_occ, occ); return; } - occ->peer_identity = *my_identity; LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", (unsigned long long) occ->op_id, GNUNET_i2s (&occ->peer_identity)); @@ -1259,12 +1262,11 @@ overlay_connect_get_config (void *cls, GST_connection_pool_get_handle (occ->peer->id, occ->peer->details.local.cfg, GST_CONNECTIONPOOL_SERVICE_CORE, - occ_cache_get_handle_core_cb, + &occ_cache_get_handle_core_cb, occ, &occ->other_peer_identity, &overlay_connect_notify, occ); - return; } @@ -1540,6 +1542,12 @@ handle_overlay_connect (void *cls, p1 = ntohl (msg->peer1); p2 = ntohl (msg->peer2); + if (p1 == p2) + { + GNUNET_break (0); + GNUNET_SERVICE_client_drop (client); + return; + } if (! VALID_PEER_ID (p1)) { GNUNET_break (0); @@ -1620,12 +1628,10 @@ handle_overlay_connect (void *cls, &p2_controller_connect_cb, occ); break; - case OCC_TYPE_REMOTE_SLAVE: p2_controller_connect_cb (occ, occ->p2ctx.remote.p2c); break; - case OCC_TYPE_LOCAL: peer2 = GST_peer_list[occ->other_peer_id]; peer2->reference_cnt++; @@ -1636,11 +1642,23 @@ handle_overlay_connect (void *cls, "id: %u", (unsigned long long) occ->op_id, occ->peer->id); + LOG_DEBUG ("Peer %u has PID %s\n", + occ->other_peer_id, + GNUNET_i2s (&occ->other_peer_identity)); + { + struct GNUNET_PeerIdentity lpid; + + GNUNET_TESTING_peer_get_identity (peer->details.local.peer, + &lpid); + LOG_DEBUG ("Peer %u has PID %s\n", + p1, + GNUNET_i2s (&lpid)); + } occ->cgh_ch = GST_connection_pool_get_handle (occ->peer->id, occ->peer->details.local.cfg, GST_CONNECTIONPOOL_SERVICE_CORE, - occ_cache_get_handle_core_cb, occ, + &occ_cache_get_handle_core_cb, occ, &occ->other_peer_identity, &overlay_connect_notify, occ); break; diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c index 0f7c0b15c..e68e449ad 100644 --- a/src/testbed/testbed_api_topology.c +++ b/src/testbed/testbed_api_topology.c @@ -1441,7 +1441,7 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, (c->opq_parallel_topology_config_operations, op); GNUNET_TESTBED_operation_begin_wait_ (op); LOG (GNUNET_ERROR_TYPE_DEBUG, - "Generated %u connections\n", + "Generated topology with %u connections\n", tc->link_array_size); if (NULL != max_connections) *max_connections = tc->link_array_size; -- cgit v1.2.3