From b1f8b32c7bf518e10f6c87bd0479b5110a7fec26 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 2 Feb 2017 10:17:38 +0100 Subject: [PATCH] have sanity checks for DHT path construction --- src/dht/gnunet-service-dht_neighbours.c | 33 +++++++++++++++++++++++++ src/dht/gnunet-service-dht_routing.c | 19 ++++++++------ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 20bdc0ce4..7f3a44588 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c @@ -48,6 +48,11 @@ #define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__) +/** + * Enable slow sanity checks to debug issues. + */ +#define SANITY_CHECKS 1 + /** * How many buckets will we allow total. */ @@ -1746,6 +1751,20 @@ handle_dht_p2p_put (void *cls, /* extend 'put path' by sender */ if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE)) { +#if SANITY_CHECKS + for (unsigned int i=0;i<=putlen;i++) + { + for (unsigned int j=0;jid, + sizeof (struct GNUNET_PeerIdentity))); + } +#endif GNUNET_memcpy (pp, put_path, putlen * sizeof (struct GNUNET_PeerIdentity)); @@ -2280,6 +2299,20 @@ handle_dht_p2p_result (void *cls, { struct GNUNET_PeerIdentity xget_path[get_path_length + 1]; +#if SANITY_CHECKS + for (unsigned int i=0;i<=get_path_length;i++) + { + for (unsigned int j=0;jid, + sizeof (struct GNUNET_PeerIdentity))); + } +#endif GNUNET_memcpy (xget_path, get_path, get_path_length * sizeof (struct GNUNET_PeerIdentity)); diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c index 978c46d73..71240a503 100644 --- a/src/dht/gnunet-service-dht_routing.c +++ b/src/dht/gnunet-service-dht_routing.c @@ -128,17 +128,17 @@ struct ProcessContext struct GNUNET_TIME_Absolute expiration_time; /** - * Number of entries in 'put_path'. + * Number of entries in @e put_path. */ unsigned int put_path_length; /** - * Number of entries in 'get_path'. + * Number of entries in @e get_path. */ unsigned int get_path_length; /** - * Number of bytes in 'data'. + * Number of bytes in @e data. */ size_t data_size; @@ -223,8 +223,13 @@ process (void *cls, gettext_noop ("# Good REPLIES matched against routing table"), 1, GNUNET_NO); - GDS_NEIGHBOURS_handle_reply (&rr->peer, pc->type, pc->expiration_time, key, - ppl, pc->put_path, gpl, pc->get_path, pc->data, + GDS_NEIGHBOURS_handle_reply (&rr->peer, + pc->type, + pc->expiration_time, + key, + ppl, pc->put_path, + gpl, pc->get_path, + pc->data, pc->data_size); break; case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: @@ -275,9 +280,9 @@ process (void *cls, * @param type type of the block * @param expiration_time when does the content expire * @param key key for the content - * @param put_path_length number of entries in put_path + * @param put_path_length number of entries in @a put_path * @param put_path peers the original PUT traversed (if tracked) - * @param get_path_length number of entries in get_path + * @param get_path_length number of entries in @a get_path * @param get_path peers this reply has traversed so far (if tracked) * @param data payload of the reply * @param data_size number of bytes in data -- 2.25.1