have sanity checks for DHT path construction
authorChristian Grothoff <christian@grothoff.org>
Thu, 2 Feb 2017 09:17:38 +0000 (10:17 +0100)
committerChristian Grothoff <christian@grothoff.org>
Thu, 2 Feb 2017 09:17:38 +0000 (10:17 +0100)
src/dht/gnunet-service-dht_neighbours.c
src/dht/gnunet-service-dht_routing.c

index 20bdc0ce4d7ff8467a564d255519b0a1e0e6b604..7f3a445888f84cf20fae30858139cd4665c68d1a 100644 (file)
 
 #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;j<i;j++)
+       {
+         GNUNET_break (0 != memcmp (&pp[i],
+                                    &pp[j],
+                                    sizeof (struct GNUNET_PeerIdentity)));
+       }
+       GNUNET_break (0 != memcmp (&pp[i],
+                                  peer->id,
+                                  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;j<i;j++)
+      {
+       GNUNET_break (0 != memcmp (&get_path[i],
+                                  &get_path[j],
+                                  sizeof (struct GNUNET_PeerIdentity)));
+      }
+      GNUNET_break (0 != memcmp (&get_path[i],
+                                peer->id,
+                                sizeof (struct GNUNET_PeerIdentity))); 
+    }
+#endif
     GNUNET_memcpy (xget_path,
                   get_path,
                   get_path_length * sizeof (struct GNUNET_PeerIdentity));
index 978c46d73ae99a29e931e57f01cada975ce7495d..71240a503512c72dcae251bf89a57e5be47ac83c 100644 (file)
@@ -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