diff options
Diffstat (limited to 'src/dht/gnunet-service-dht_routing.c')
-rw-r--r-- | src/dht/gnunet-service-dht_routing.c | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c index 978c46d73..098b6e895 100644 --- a/src/dht/gnunet-service-dht_routing.c +++ b/src/dht/gnunet-service-dht_routing.c | |||
@@ -58,9 +58,9 @@ struct RecentRequest | |||
58 | struct GNUNET_CONTAINER_HeapNode *heap_node; | 58 | struct GNUNET_CONTAINER_HeapNode *heap_node; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Bloomfilter for replies to drop. | 61 | * Block group for filtering replies. |
62 | */ | 62 | */ |
63 | struct GNUNET_CONTAINER_BloomFilter *reply_bf; | 63 | struct GNUNET_BLOCK_Group *bg; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Type of the requested block. | 66 | * Type of the requested block. |
@@ -79,11 +79,6 @@ struct RecentRequest | |||
79 | size_t xquery_size; | 79 | size_t xquery_size; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * Mutator value for the reply_bf, see gnunet_block_lib.h | ||
83 | */ | ||
84 | uint32_t reply_bf_mutator; | ||
85 | |||
86 | /** | ||
87 | * Request options. | 82 | * Request options. |
88 | */ | 83 | */ |
89 | enum GNUNET_DHT_RouteOption options; | 84 | enum GNUNET_DHT_RouteOption options; |
@@ -128,17 +123,17 @@ struct ProcessContext | |||
128 | struct GNUNET_TIME_Absolute expiration_time; | 123 | struct GNUNET_TIME_Absolute expiration_time; |
129 | 124 | ||
130 | /** | 125 | /** |
131 | * Number of entries in 'put_path'. | 126 | * Number of entries in @e put_path. |
132 | */ | 127 | */ |
133 | unsigned int put_path_length; | 128 | unsigned int put_path_length; |
134 | 129 | ||
135 | /** | 130 | /** |
136 | * Number of entries in 'get_path'. | 131 | * Number of entries in @e get_path. |
137 | */ | 132 | */ |
138 | unsigned int get_path_length; | 133 | unsigned int get_path_length; |
139 | 134 | ||
140 | /** | 135 | /** |
141 | * Number of bytes in 'data'. | 136 | * Number of bytes in @e data. |
142 | */ | 137 | */ |
143 | size_t data_size; | 138 | size_t data_size; |
144 | 139 | ||
@@ -207,14 +202,18 @@ process (void *cls, | |||
207 | eval | 202 | eval |
208 | = GNUNET_BLOCK_evaluate (GDS_block_context, | 203 | = GNUNET_BLOCK_evaluate (GDS_block_context, |
209 | pc->type, | 204 | pc->type, |
205 | rr->bg, | ||
210 | GNUNET_BLOCK_EO_NONE, | 206 | GNUNET_BLOCK_EO_NONE, |
211 | eval_key, | 207 | eval_key, |
212 | &rr->reply_bf, | ||
213 | rr->reply_bf_mutator, | ||
214 | rr->xquery, | 208 | rr->xquery, |
215 | rr->xquery_size, | 209 | rr->xquery_size, |
216 | pc->data, | 210 | pc->data, |
217 | pc->data_size); | 211 | pc->data_size); |
212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
213 | "Result for %s of type %d was evaluated as %d\n", | ||
214 | GNUNET_h2s (key), | ||
215 | pc->type, | ||
216 | eval); | ||
218 | switch (eval) | 217 | switch (eval) |
219 | { | 218 | { |
220 | case GNUNET_BLOCK_EVALUATION_OK_MORE: | 219 | case GNUNET_BLOCK_EVALUATION_OK_MORE: |
@@ -223,8 +222,13 @@ process (void *cls, | |||
223 | gettext_noop | 222 | gettext_noop |
224 | ("# Good REPLIES matched against routing table"), | 223 | ("# Good REPLIES matched against routing table"), |
225 | 1, GNUNET_NO); | 224 | 1, GNUNET_NO); |
226 | GDS_NEIGHBOURS_handle_reply (&rr->peer, pc->type, pc->expiration_time, key, | 225 | GDS_NEIGHBOURS_handle_reply (&rr->peer, |
227 | ppl, pc->put_path, gpl, pc->get_path, pc->data, | 226 | pc->type, |
227 | pc->expiration_time, | ||
228 | key, | ||
229 | ppl, pc->put_path, | ||
230 | gpl, pc->get_path, | ||
231 | pc->data, | ||
228 | pc->data_size); | 232 | pc->data_size); |
229 | break; | 233 | break; |
230 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: | 234 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: |
@@ -275,16 +279,15 @@ process (void *cls, | |||
275 | * @param type type of the block | 279 | * @param type type of the block |
276 | * @param expiration_time when does the content expire | 280 | * @param expiration_time when does the content expire |
277 | * @param key key for the content | 281 | * @param key key for the content |
278 | * @param put_path_length number of entries in put_path | 282 | * @param put_path_length number of entries in @a put_path |
279 | * @param put_path peers the original PUT traversed (if tracked) | 283 | * @param put_path peers the original PUT traversed (if tracked) |
280 | * @param get_path_length number of entries in get_path | 284 | * @param get_path_length number of entries in @a get_path |
281 | * @param get_path peers this reply has traversed so far (if tracked) | 285 | * @param get_path peers this reply has traversed so far (if tracked) |
282 | * @param data payload of the reply | 286 | * @param data payload of the reply |
283 | * @param data_size number of bytes in data | 287 | * @param data_size number of bytes in data |
284 | */ | 288 | */ |
285 | void | 289 | void |
286 | GDS_ROUTING_process (void *cls, | 290 | GDS_ROUTING_process (enum GNUNET_BLOCK_Type type, |
287 | enum GNUNET_BLOCK_Type type, | ||
288 | struct GNUNET_TIME_Absolute expiration_time, | 291 | struct GNUNET_TIME_Absolute expiration_time, |
289 | const struct GNUNET_HashCode *key, | 292 | const struct GNUNET_HashCode *key, |
290 | unsigned int put_path_length, | 293 | unsigned int put_path_length, |
@@ -338,7 +341,7 @@ expire_oldest_entry () | |||
338 | recent_req = GNUNET_CONTAINER_heap_peek (recent_heap); | 341 | recent_req = GNUNET_CONTAINER_heap_peek (recent_heap); |
339 | GNUNET_assert (recent_req != NULL); | 342 | GNUNET_assert (recent_req != NULL); |
340 | GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node); | 343 | GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node); |
341 | GNUNET_CONTAINER_bloomfilter_free (recent_req->reply_bf); | 344 | GNUNET_BLOCK_group_destroy (recent_req->bg); |
342 | GNUNET_assert (GNUNET_YES == | 345 | GNUNET_assert (GNUNET_YES == |
343 | GNUNET_CONTAINER_multihashmap_remove (recent_map, | 346 | GNUNET_CONTAINER_multihashmap_remove (recent_map, |
344 | &recent_req->key, | 347 | &recent_req->key, |
@@ -374,18 +377,10 @@ try_combine_recent (void *cls, | |||
374 | rr->xquery, | 377 | rr->xquery, |
375 | in->xquery_size)) ) | 378 | in->xquery_size)) ) |
376 | return GNUNET_OK; | 379 | return GNUNET_OK; |
377 | if (in->reply_bf_mutator != rr->reply_bf_mutator) | 380 | GNUNET_break (GNUNET_SYSERR != |
378 | { | 381 | GNUNET_BLOCK_group_merge (in->bg, |
379 | rr->reply_bf_mutator = in->reply_bf_mutator; | 382 | rr->bg)); |
380 | GNUNET_CONTAINER_bloomfilter_free (rr->reply_bf); | 383 | rr->bg = in->bg; |
381 | rr->reply_bf = in->reply_bf; | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | GNUNET_CONTAINER_bloomfilter_or2 (rr->reply_bf, | ||
386 | in->reply_bf); | ||
387 | GNUNET_CONTAINER_bloomfilter_free (in->reply_bf); | ||
388 | } | ||
389 | GNUNET_free (in); | 384 | GNUNET_free (in); |
390 | return GNUNET_SYSERR; | 385 | return GNUNET_SYSERR; |
391 | } | 386 | } |
@@ -406,12 +401,11 @@ try_combine_recent (void *cls, | |||
406 | void | 401 | void |
407 | GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, | 402 | GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, |
408 | enum GNUNET_BLOCK_Type type, | 403 | enum GNUNET_BLOCK_Type type, |
404 | struct GNUNET_BLOCK_Group *bg, | ||
409 | enum GNUNET_DHT_RouteOption options, | 405 | enum GNUNET_DHT_RouteOption options, |
410 | const struct GNUNET_HashCode *key, | 406 | const struct GNUNET_HashCode *key, |
411 | const void *xquery, | 407 | const void *xquery, |
412 | size_t xquery_size, | 408 | size_t xquery_size) |
413 | const struct GNUNET_CONTAINER_BloomFilter *reply_bf, | ||
414 | uint32_t reply_bf_mutator) | ||
415 | { | 409 | { |
416 | struct RecentRequest *recent_req; | 410 | struct RecentRequest *recent_req; |
417 | 411 | ||
@@ -419,17 +413,19 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, | |||
419 | expire_oldest_entry (); | 413 | expire_oldest_entry (); |
420 | GNUNET_STATISTICS_update (GDS_stats, | 414 | GNUNET_STATISTICS_update (GDS_stats, |
421 | gettext_noop ("# Entries added to routing table"), | 415 | gettext_noop ("# Entries added to routing table"), |
422 | 1, GNUNET_NO); | 416 | 1, |
417 | GNUNET_NO); | ||
423 | recent_req = GNUNET_malloc (sizeof (struct RecentRequest) + xquery_size); | 418 | recent_req = GNUNET_malloc (sizeof (struct RecentRequest) + xquery_size); |
424 | recent_req->peer = *sender; | 419 | recent_req->peer = *sender; |
425 | recent_req->key = *key; | 420 | recent_req->key = *key; |
426 | recent_req->reply_bf = GNUNET_CONTAINER_bloomfilter_copy (reply_bf); | 421 | recent_req->bg = bg; |
427 | recent_req->type = type; | 422 | recent_req->type = type; |
428 | recent_req->options = options; | 423 | recent_req->options = options; |
429 | recent_req->xquery = &recent_req[1]; | 424 | recent_req->xquery = &recent_req[1]; |
430 | GNUNET_memcpy (&recent_req[1], xquery, xquery_size); | 425 | GNUNET_memcpy (&recent_req[1], |
426 | xquery, | ||
427 | xquery_size); | ||
431 | recent_req->xquery_size = xquery_size; | 428 | recent_req->xquery_size = xquery_size; |
432 | recent_req->reply_bf_mutator = reply_bf_mutator; | ||
433 | if (GNUNET_SYSERR == | 429 | if (GNUNET_SYSERR == |
434 | GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, | 430 | GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, |
435 | key, | 431 | key, |
@@ -442,13 +438,14 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, | |||
442 | 1, GNUNET_NO); | 438 | 1, GNUNET_NO); |
443 | return; | 439 | return; |
444 | } | 440 | } |
445 | recent_req->heap_node = | 441 | recent_req->heap_node |
446 | GNUNET_CONTAINER_heap_insert (recent_heap, recent_req, | 442 | = GNUNET_CONTAINER_heap_insert (recent_heap, |
443 | recent_req, | ||
447 | GNUNET_TIME_absolute_get ().abs_value_us); | 444 | GNUNET_TIME_absolute_get ().abs_value_us); |
448 | GNUNET_CONTAINER_multihashmap_put (recent_map, key, recent_req, | 445 | GNUNET_CONTAINER_multihashmap_put (recent_map, |
446 | key, | ||
447 | recent_req, | ||
449 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 448 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
450 | |||
451 | |||
452 | } | 449 | } |
453 | 450 | ||
454 | 451 | ||