diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-02 10:17:38 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-02 10:17:38 +0100 |
commit | b1f8b32c7bf518e10f6c87bd0479b5110a7fec26 (patch) | |
tree | 6bd0063af77fd0d2f0c29d155e5b9a96541299a7 /src/dht | |
parent | b10aed674f795793f20162f45cd8a1707b308718 (diff) | |
download | gnunet-b1f8b32c7bf518e10f6c87bd0479b5110a7fec26.tar.gz gnunet-b1f8b32c7bf518e10f6c87bd0479b5110a7fec26.zip |
have sanity checks for DHT path construction
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 33 | ||||
-rw-r--r-- | 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 | |||
@@ -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)); |
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 | |||
128 | struct GNUNET_TIME_Absolute expiration_time; | 128 | struct GNUNET_TIME_Absolute expiration_time; |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * Number of entries in 'put_path'. | 131 | * Number of entries in @e put_path. |
132 | */ | 132 | */ |
133 | unsigned int put_path_length; | 133 | unsigned int put_path_length; |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * Number of entries in 'get_path'. | 136 | * Number of entries in @e get_path. |
137 | */ | 137 | */ |
138 | unsigned int get_path_length; | 138 | unsigned int get_path_length; |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * Number of bytes in 'data'. | 141 | * Number of bytes in @e data. |
142 | */ | 142 | */ |
143 | size_t data_size; | 143 | size_t data_size; |
144 | 144 | ||
@@ -223,8 +223,13 @@ process (void *cls, | |||
223 | gettext_noop | 223 | gettext_noop |
224 | ("# Good REPLIES matched against routing table"), | 224 | ("# Good REPLIES matched against routing table"), |
225 | 1, GNUNET_NO); | 225 | 1, GNUNET_NO); |
226 | GDS_NEIGHBOURS_handle_reply (&rr->peer, pc->type, pc->expiration_time, key, | 226 | GDS_NEIGHBOURS_handle_reply (&rr->peer, |
227 | ppl, pc->put_path, gpl, pc->get_path, pc->data, | 227 | pc->type, |
228 | pc->expiration_time, | ||
229 | key, | ||
230 | ppl, pc->put_path, | ||
231 | gpl, pc->get_path, | ||
232 | pc->data, | ||
228 | pc->data_size); | 233 | pc->data_size); |
229 | break; | 234 | break; |
230 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: | 235 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: |
@@ -275,9 +280,9 @@ process (void *cls, | |||
275 | * @param type type of the block | 280 | * @param type type of the block |
276 | * @param expiration_time when does the content expire | 281 | * @param expiration_time when does the content expire |
277 | * @param key key for the content | 282 | * @param key key for the content |
278 | * @param put_path_length number of entries in put_path | 283 | * @param put_path_length number of entries in @a put_path |
279 | * @param put_path peers the original PUT traversed (if tracked) | 284 | * @param put_path peers the original PUT traversed (if tracked) |
280 | * @param get_path_length number of entries in get_path | 285 | * @param get_path_length number of entries in @a get_path |
281 | * @param get_path peers this reply has traversed so far (if tracked) | 286 | * @param get_path peers this reply has traversed so far (if tracked) |
282 | * @param data payload of the reply | 287 | * @param data payload of the reply |
283 | * @param data_size number of bytes in data | 288 | * @param data_size number of bytes in data |