aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_neighbours.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-02 10:17:38 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-02 10:17:38 +0100
commitb1f8b32c7bf518e10f6c87bd0479b5110a7fec26 (patch)
tree6bd0063af77fd0d2f0c29d155e5b9a96541299a7 /src/dht/gnunet-service-dht_neighbours.c
parentb10aed674f795793f20162f45cd8a1707b308718 (diff)
downloadgnunet-b1f8b32c7bf518e10f6c87bd0479b5110a7fec26.tar.gz
gnunet-b1f8b32c7bf518e10f6c87bd0479b5110a7fec26.zip
have sanity checks for DHT path construction
Diffstat (limited to 'src/dht/gnunet-service-dht_neighbours.c')
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c33
1 files changed, 33 insertions, 0 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
@@ -49,6 +49,11 @@
49#define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__) 49#define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__)
50 50
51/** 51/**
52 * Enable slow sanity checks to debug issues.
53 */
54#define SANITY_CHECKS 1
55
56/**
52 * How many buckets will we allow total. 57 * How many buckets will we allow total.
53 */ 58 */
54#define MAX_BUCKETS sizeof (struct GNUNET_HashCode) * 8 59#define MAX_BUCKETS sizeof (struct GNUNET_HashCode) * 8
@@ -1746,6 +1751,20 @@ handle_dht_p2p_put (void *cls,
1746 /* extend 'put path' by sender */ 1751 /* extend 'put path' by sender */
1747 if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE)) 1752 if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE))
1748 { 1753 {
1754#if SANITY_CHECKS
1755 for (unsigned int i=0;i<=putlen;i++)
1756 {
1757 for (unsigned int j=0;j<i;j++)
1758 {
1759 GNUNET_break (0 != memcmp (&pp[i],
1760 &pp[j],
1761 sizeof (struct GNUNET_PeerIdentity)));
1762 }
1763 GNUNET_break (0 != memcmp (&pp[i],
1764 peer->id,
1765 sizeof (struct GNUNET_PeerIdentity)));
1766 }
1767#endif
1749 GNUNET_memcpy (pp, 1768 GNUNET_memcpy (pp,
1750 put_path, 1769 put_path,
1751 putlen * sizeof (struct GNUNET_PeerIdentity)); 1770 putlen * sizeof (struct GNUNET_PeerIdentity));
@@ -2280,6 +2299,20 @@ handle_dht_p2p_result (void *cls,
2280 { 2299 {
2281 struct GNUNET_PeerIdentity xget_path[get_path_length + 1]; 2300 struct GNUNET_PeerIdentity xget_path[get_path_length + 1];
2282 2301
2302#if SANITY_CHECKS
2303 for (unsigned int i=0;i<=get_path_length;i++)
2304 {
2305 for (unsigned int j=0;j<i;j++)
2306 {
2307 GNUNET_break (0 != memcmp (&get_path[i],
2308 &get_path[j],
2309 sizeof (struct GNUNET_PeerIdentity)));
2310 }
2311 GNUNET_break (0 != memcmp (&get_path[i],
2312 peer->id,
2313 sizeof (struct GNUNET_PeerIdentity)));
2314 }
2315#endif
2283 GNUNET_memcpy (xget_path, 2316 GNUNET_memcpy (xget_path,
2284 get_path, 2317 get_path,
2285 get_path_length * sizeof (struct GNUNET_PeerIdentity)); 2318 get_path_length * sizeof (struct GNUNET_PeerIdentity));