gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit 8ee3c5121e87d8f25193ae6044d5818f4629fa1e
parent d4641d36b885ba764945d6353ed71b7bc485c6ac
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 10 Jan 2022 14:22:35 +0100

-DHT: add path signature verification logic; tests pass, but logic remains dead

Diffstat:
Msrc/dht/Makefile.am | 1+
Msrc/dht/dht_api.c | 42+++++++++++++++++++++++++++++++-----------
Msrc/dht/dht_test_lib.c | 15---------------
Msrc/dht/gnunet-service-dht_neighbours.c | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Msrc/dht/test_dht_topo.c | 190+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
Msrc/include/gnunet_dht_service.h | 22+++++++++++++---------
Msrc/testbed/gnunet-service-testbed_connectionpool.c | 33+++++++++++++++++++++++----------
Msrc/testbed/gnunet-service-testbed_oc.c | 44+++++++++++++++++++++++++++++++-------------
Msrc/testbed/testbed_api_topology.c | 2+-
9 files changed, 309 insertions(+), 114 deletions(-)

diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am @@ -63,6 +63,7 @@ gnunet_service_dht_SOURCES = \ gnunet-service-dht_neighbours.c gnunet-service-dht_neighbours.h \ gnunet-service-dht_routing.c gnunet-service-dht_routing.h gnunet_service_dht_LDADD = \ + libgnunetdht.la \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/nse/libgnunetnse.la \ diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c @@ -1198,31 +1198,51 @@ GNUNET_DHT_verify_path (const struct GNUNET_HashCode *key, const void *data, size_t data_size, struct GNUNET_TIME_Absolute exp_time, - const struct GNUNET_DHT_PathElement *path, - unsigned int path_len, + const struct GNUNET_DHT_PathElement *put_path, + unsigned int put_path_len, + const struct GNUNET_DHT_PathElement *get_path, + unsigned int get_path_len, const struct GNUNET_PeerIdentity *me) { - struct GNUNET_DHT_HopSignature hs = { .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DHT_HOP), .purpose.size = htonl (sizeof (hs)), .expiration_time = GNUNET_TIME_absolute_hton (exp_time), .key = *key, }; - unsigned int i = path_len - 1; - + unsigned int i; + + if (0 == get_path_len + put_path_len) + return 0; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Verifying signatures with GPL: %u PPL: %u!\n", + get_path_len, + put_path_len); + i = put_path_len + get_path_len - 1; GNUNET_CRYPTO_hash (data, data_size, &hs.h_data); while (i > 0) { - hs.pred = path[i - 1].pred; - hs.succ = (path_len == i + 1) ? *me : path[i + 1].pred; + hs.pred = (i - 1 >= put_path_len) + ? get_path[i - put_path_len - 1].pred + : put_path[i - 1].pred; + if (i + 1 == get_path_len + put_path_len) + hs.succ = *me; + else + hs.succ = (i + 1 >= put_path_len) + ? get_path[i + 1 - put_path_len].pred + : put_path[i + 1].pred; if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_DHT_HOP, - &hs, - &path[i - 1].sig, - &path[i].pred.public_key)) + GNUNET_CRYPTO_eddsa_verify ( + GNUNET_SIGNATURE_PURPOSE_DHT_HOP, + &hs, + (i - 1 >= put_path_len) + ? &get_path[i - put_path_len - 1].sig + : &put_path[i - 1].sig, + (i >= put_path_len) + ? &get_path[i - put_path_len].pred.public_key + : &put_path[i].pred.public_key)) return i; i--; } diff --git a/src/dht/dht_test_lib.c b/src/dht/dht_test_lib.c @@ -138,11 +138,6 @@ dht_connect_cb (void *cls, } -/** - * Clean up the testbed. - * - * @param ctx handle for the testbed - */ void GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx) { @@ -179,16 +174,6 @@ dht_test_run (void *cls, } -/** - * Run a test using the given name, configuration file and number of - * peers. - * - * @param testname name of the test (for logging) - * @param cfgname name of the configuration file - * @param num_peers number of peers to start - * @param tmain main function to run once the testbed is ready - * @param tmain_cls closure for 'tmain' - */ void GNUNET_DHT_TEST_run (const char *testname, const char *cfgname, diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c @@ -1308,6 +1308,21 @@ GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd, unsigned int put_path_length = bd->put_path_length; GNUNET_assert (NULL != bf); +#if SANITY_CHECKS + if (0 != + GNUNET_DHT_verify_path (&bd->key, + bd->data, + bd->data_size, + bd->expiration_time, + bd->put_path, + bd->put_path_length, + NULL, 0, /* get_path */ + &my_identity)) + { + GNUNET_break_op (0); + put_path_length = 0; + } +#endif GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding myself (%s) to PUT bloomfilter for %s\n", GNUNET_i2s (&my_identity), @@ -1564,13 +1579,43 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, struct PeerResultMessage *prm; struct GNUNET_DHT_PathElement *paths; size_t msize; + unsigned int ppl = bd->put_path_length; - msize = bd->data_size + (get_path_length + bd->put_path_length) +#if SANITY_CHECKS + if (0 != + GNUNET_DHT_verify_path (&bd->key, + bd->data, + bd->data_size, + bd->expiration_time, + bd->put_path, + bd->put_path_length, + get_path, + get_path_length, + &my_identity)) + { + GNUNET_break_op (0); + get_path_length = 0; + ppl = 0; + } +#endif + msize = bd->data_size + (get_path_length + ppl) * sizeof(struct GNUNET_DHT_PathElement); if ( (msize + sizeof(struct PeerResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) || (get_path_length > GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) || - (bd->put_path_length > + (ppl > + GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) || + (bd->data_size > GNUNET_MAX_MESSAGE_SIZE)) + { + ppl = 0; + get_path_length = 0; + msize = bd->data_size + (get_path_length + ppl) + * sizeof(struct GNUNET_DHT_PathElement); + } + if ( (msize + sizeof(struct PeerResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) || + (get_path_length > + GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) || + (ppl > GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) || (bd->data_size > GNUNET_MAX_MESSAGE_SIZE)) { @@ -1602,15 +1647,15 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, msize, GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT); prm->type = htonl (bd->type); - prm->put_path_length = htonl (bd->put_path_length); + prm->put_path_length = htonl (ppl); prm->get_path_length = htonl (get_path_length); prm->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); prm->key = *query_hash; paths = (struct GNUNET_DHT_PathElement *) &prm[1]; GNUNET_memcpy (paths, bd->put_path, - bd->put_path_length * sizeof(struct GNUNET_DHT_PathElement)); - GNUNET_memcpy (&paths[bd->put_path_length], + ppl * sizeof(struct GNUNET_DHT_PathElement)); + GNUNET_memcpy (&paths[ppl], get_path, get_path_length * sizeof(struct GNUNET_DHT_PathElement)); /* 0 == get_path_length means path is not being tracked */ @@ -1622,11 +1667,11 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, bd->data, bd->data_size, bd->expiration_time, - &paths[bd->put_path_length + get_path_length - 1].pred, + &paths[ppl + get_path_length - 1].pred, pi->id, - &paths[bd->put_path_length + get_path_length - 1].sig); + &paths[ppl + get_path_length - 1].sig); } - GNUNET_memcpy (&paths[bd->put_path_length + get_path_length], + GNUNET_memcpy (&paths[ppl + get_path_length], bd->data, bd->data_size); GNUNET_MQ_send (pi->mq, @@ -1798,6 +1843,19 @@ handle_dht_p2p_put (void *cls, GNUNET_memcmp (&pp[i].pred, peer->id)); } + if (0 != + GNUNET_DHT_verify_path (&bd.key, + bd.data, + bd.data_size, + bd.expiration_time, + bd.put_path, + putlen, + NULL, 0, /* get_path */ + &my_identity)) + { + GNUNET_break_op (0); + putlen = 0; + } #endif GNUNET_memcpy (pp, put_path, diff --git a/src/dht/test_dht_topo.c b/src/dht/test_dht_topo.c @@ -58,16 +58,36 @@ struct GetOperation struct GetOperation *prev; /** + * Operation to fetch @a me. + */ + struct GNUNET_TESTBED_Operation *to; + + /** * Handle for the operation. */ struct GNUNET_DHT_GetHandle *get; + + /** + * DHT used by this operation. + */ + struct GNUNET_DHT_Handle *dht; + + /** + * Key we are looking up. + */ + struct GNUNET_HashCode key; + + /** + * At which peer is this operation being performed? + */ + struct GNUNET_PeerIdentity me; }; /** * Result of the test. */ -static int ok = 1; +static int ok; /** * Task to do DHT_puts @@ -154,7 +174,7 @@ static struct static struct GNUNET_DHT_TEST_Context * -stop_ops () +stop_ops (void) { struct GetOperation *get_op; struct GNUNET_DHT_TEST_Context *ctx = NULL; @@ -176,7 +196,16 @@ stop_ops () } while (NULL != (get_op = get_tail)) { - GNUNET_DHT_get_stop (get_op->get); + if (NULL != get_op->to) + { + GNUNET_TESTBED_operation_done (get_op->to); + get_op->to = NULL; + } + if (NULL != get_op->get) + { + GNUNET_DHT_get_stop (get_op->get); + get_op->get = NULL; + } GNUNET_CONTAINER_DLL_remove (get_head, get_tail, get_op); @@ -199,7 +228,6 @@ stats_finished (void *cls, const char *emsg) { struct GNUNET_DHT_TEST_Context *ctx = cls; - unsigned int i; if (NULL != op) GNUNET_TESTBED_operation_done (op); @@ -212,7 +240,7 @@ stats_finished (void *cls, GNUNET_DHT_TEST_cleanup (ctx); return; } - for (i = 0; NULL != stats[i].name; i++) + for (unsigned int i = 0; NULL != stats[i].name; i++) fprintf (stderr, "%6s/%60s = %12llu\n", stats[i].subsystem, @@ -234,7 +262,7 @@ stats_finished (void *cls, * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration */ -static int +static enum GNUNET_GenericReturnValue handle_stats (void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, @@ -242,9 +270,7 @@ handle_stats (void *cls, uint64_t value, int is_persistent) { - unsigned int i; - - for (i = 0; NULL != stats[i].name; i++) + for (unsigned int i = 0; NULL != stats[i].name; i++) if ((0 == strcasecmp (subsystem, stats[i].subsystem)) && (0 == strcasecmp (name, @@ -263,7 +289,14 @@ handle_stats (void *cls, static void shutdown_task (void *cls) { - (void) stop_ops (); + struct GNUNET_DHT_TEST_Context *ctx; + + (void) cls; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Performing shutdown\n"); + ctx = stop_ops (); + if (NULL != ctx) + GNUNET_DHT_TEST_cleanup (ctx); } @@ -276,7 +309,11 @@ shutdown_task (void *cls) static void timeout_cb (void *cls) { - timeout_task = NULL; + struct GNUNET_DHT_TEST_Context *ctx = cls; + + timeout_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, + &timeout_cb, + ctx); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout\n"); GNUNET_SCHEDULER_shutdown (); @@ -314,6 +351,13 @@ dht_get_handler (void *cls, struct GNUNET_HashCode want; struct GNUNET_DHT_TEST_Context *ctx; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Handling reply with GPL: %u PPL: %u!\n", + get_path_len, + put_path_len); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "GET HANDLER called on PID %s\n", + GNUNET_i2s (&get_op->me)); if (sizeof(struct GNUNET_HashCode) != size) { GNUNET_break (0); @@ -329,26 +373,26 @@ dht_get_handler (void *cls, GNUNET_break (0); return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Get successful\n"); -#if 0 + if (0 != + GNUNET_DHT_verify_path (key, + data, + size, + exp, + get_path, + get_path_length, + put_path, + put_path_length, + &get_op->me)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Path signature verification failed!\n"); + } + else { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "PATH: (get %u, put %u)\n", - get_path_length, - put_path_length); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - " LOCAL\n"); - for (int i = get_path_length - 1; i >= 0; i--) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - " %s\n", - GNUNET_i2s (&get_path[i])); - for (int i = put_path_length - 1; i >= 0; i--) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - " %s\n", - GNUNET_i2s (&put_path[i])); + "Get successful\n"); + ok--; } -#endif GNUNET_DHT_get_stop (get_op->get); GNUNET_CONTAINER_DLL_remove (get_head, get_tail, @@ -359,7 +403,6 @@ dht_get_handler (void *cls, /* all DHT GET operations successful; get stats! */ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "All DHT operations successful. Obtaining stats!\n"); - ok = 0; ctx = stop_ops (); GNUNET_assert (NULL != ctx); (void) GNUNET_TESTBED_get_statistics (NUM_PEERS, @@ -386,7 +429,8 @@ do_puts (void *cls) put_task = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Putting values into DHT\n"); + "Putting %u values into DHT\n", + NUM_PEERS); for (unsigned int i = 0; i < NUM_PEERS; i++) { GNUNET_CRYPTO_hash (&i, @@ -414,37 +458,86 @@ do_puts (void *cls) /** + * Callback to be called when the requested peer information is available + * The peer information in the callback is valid until the operation 'op' is canceled. + * + * @param cls a `struct GetOperation *` + * @param op the operation this callback corresponds to + * @param pinfo the result; will be NULL if the operation has failed + * @param emsg error message if the operation has failed; will be NULL if the + * operation is successful + */ +static void +pid_cb (void *cls, + struct GNUNET_TESTBED_Operation *op, + const struct GNUNET_TESTBED_PeerInformation *pinfo, + const char *emsg) +{ + struct GetOperation *get_op = cls; + + if (NULL != emsg) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Testbed failure: %s\n", + emsg); + GNUNET_TESTBED_operation_done (get_op->to); + get_op->to = NULL; + GNUNET_SCHEDULER_shutdown (); + return; + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Testbed provided PID %s\n", + GNUNET_i2s (pinfo->result.id)); + get_op->me = *pinfo->result.id; + GNUNET_TESTBED_operation_done (get_op->to); + get_op->to = NULL; + get_op->get = GNUNET_DHT_get_start (get_op->dht, + GNUNET_BLOCK_TYPE_TEST, + &get_op->key, + 4U, /* replication level */ + GNUNET_DHT_RO_RECORD_ROUTE + | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, + NULL, /* xquery */ + 0, /* xquery bits */ + &dht_get_handler, + get_op); +} + + +/** * Start GET operations. */ static void start_get (void *cls) { struct GNUNET_DHT_Handle **dhts = cls; - unsigned int i; - unsigned int j; - struct GNUNET_HashCode key; - struct GetOperation *get_op; get_task = NULL; - for (i = 0; i < NUM_PEERS; i++) + for (unsigned int i = 0; i < NUM_PEERS; i++) { - GNUNET_CRYPTO_hash (&i, sizeof(i), &key); - for (j = 0; j < NUM_PEERS; j++) + struct GNUNET_HashCode key; + + GNUNET_CRYPTO_hash (&i, + sizeof(i), + &key); + for (unsigned int j = 0; j < NUM_PEERS; j++) { + struct GetOperation *get_op; + get_op = GNUNET_new (struct GetOperation); + ok++; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Starting GET %p\n", + get_op); + get_op->key = key; + get_op->dht = dhts[j]; + get_op->to = GNUNET_TESTBED_peer_get_information (my_peers[j], + GNUNET_TESTBED_PIT_IDENTITY, + &pid_cb, + get_op); GNUNET_CONTAINER_DLL_insert (get_head, get_tail, get_op); - get_op->get = GNUNET_DHT_get_start (dhts[j], - GNUNET_BLOCK_TYPE_TEST, /* type */ - &key, /*key to search */ - 4U, /* replication level */ - GNUNET_DHT_RO_RECORD_ROUTE - | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, - NULL, /* xquery */ - 0, /* xquery bits */ - &dht_get_handler, - get_op); } } } @@ -492,6 +585,9 @@ main (int xargc, char *xargv[]) const char *cfg_filename; const char *test_name; + unsetenv ("XDG_DATA_HOME"); + unsetenv ("XDG_CONFIG_HOME"); + unsetenv ("XDG_CACHE_HOME"); if (NULL != strstr (xargv[0], "test_dht_2dtorus")) { cfg_filename = "test_dht_2dtorus.conf"; diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h @@ -482,29 +482,33 @@ GNUNET_DHT_pp2s (const struct GNUNET_DHT_PathElement *path, /** - * Verify signatures on a @a path, in reverse order (starting at - * the last element of the path). Note that the last signature - * on the path is never verified as that is the slot where our - * peer (@a me) would need to sign. + * Verify signatures on a path consisting of @a put_path and @a get_path in + * reverse order (starting at the last element of the @a get_path). Note that + * the last signature on the path is never verified as that is the slot where + * our peer (@a me) would need to sign. * * @param key key of the data (not necessarily the query hash) * @param data payload (the block) * @param data_size number of bytes in @a data * @param exp_time expiration time of @a data - * @param path array of path elements to verify - * @param path_len length of the @a path array + * @param get_path array of path elements to verify + * @param get_path_len length of the @a get_path array + * @param put_path array of path elements to verify + * @param put_path_len length of the @a put_path array * @param me our own peer identity (needed to verify the last element) * @return 0 on success, otherwise the index of * the last path element that succeeded with verification; - * @a path_len -1 if no signature was valid + * @a get_path_len + @a put_path_len - 1 if no signature was valid */ unsigned int GNUNET_DHT_verify_path (const struct GNUNET_HashCode *key, const void *data, size_t data_size, struct GNUNET_TIME_Absolute exp_time, - const struct GNUNET_DHT_PathElement *path, - unsigned int path_len, + const struct GNUNET_DHT_PathElement *put_path, + unsigned int put_path_len, + const struct GNUNET_DHT_PathElement *get_path, + unsigned int get_path_len, const struct GNUNET_PeerIdentity *me); diff --git 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 @@ -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 @@ -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;