diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-20 17:19:47 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-20 17:19:47 +0100 |
commit | f6f7fbbe98c110867febbcca647da8308be123c7 (patch) | |
tree | af69447cf4f08c417197685855c097c132aea8a1 /src/dht | |
parent | a3882b58f1c5976677aa65b0af8a48e8e946b06e (diff) | |
download | gnunet-f6f7fbbe98c110867febbcca647da8308be123c7.tar.gz gnunet-f6f7fbbe98c110867febbcca647da8308be123c7.zip |
completed big block refactoring in preparation for SET-BLOCK integration
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/Makefile.am | 3 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_clients.c | 30 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_datacache.c | 39 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_datacache.h | 6 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 196 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.h | 14 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_routing.c | 56 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_routing.h | 11 | ||||
-rw-r--r-- | src/dht/plugin_block_dht.c | 34 |
9 files changed, 167 insertions, 222 deletions
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index 93dae9f6e..4216af400 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am | |||
@@ -82,6 +82,7 @@ gnunet_service_dht_LDADD = \ | |||
82 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 82 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ |
83 | $(top_builddir)/src/hello/libgnunethello.la \ | 83 | $(top_builddir)/src/hello/libgnunethello.la \ |
84 | $(top_builddir)/src/block/libgnunetblock.la \ | 84 | $(top_builddir)/src/block/libgnunetblock.la \ |
85 | $(top_builddir)/src/block/libgnunetblockgroup.la \ | ||
85 | $(top_builddir)/src/datacache/libgnunetdatacache.la \ | 86 | $(top_builddir)/src/datacache/libgnunetdatacache.la \ |
86 | $(top_builddir)/src/util/libgnunetutil.la \ | 87 | $(top_builddir)/src/util/libgnunetutil.la \ |
87 | -lm | 88 | -lm |
@@ -102,6 +103,7 @@ gnunet_service_dht_xvine_LDADD = \ | |||
102 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 103 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ |
103 | $(top_builddir)/src/hello/libgnunethello.la \ | 104 | $(top_builddir)/src/hello/libgnunethello.la \ |
104 | $(top_builddir)/src/block/libgnunetblock.la \ | 105 | $(top_builddir)/src/block/libgnunetblock.la \ |
106 | $(top_builddir)/src/block/libgnunetblockgroup.la \ | ||
105 | $(top_builddir)/src/datacache/libgnunetdatacache.la \ | 107 | $(top_builddir)/src/datacache/libgnunetdatacache.la \ |
106 | $(top_builddir)/src/util/libgnunetutil.la \ | 108 | $(top_builddir)/src/util/libgnunetutil.la \ |
107 | -lm | 109 | -lm |
@@ -120,6 +122,7 @@ gnunet_service_dht_whanau_LDADD = \ | |||
120 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 122 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ |
121 | $(top_builddir)/src/hello/libgnunethello.la \ | 123 | $(top_builddir)/src/hello/libgnunethello.la \ |
122 | $(top_builddir)/src/block/libgnunetblock.la \ | 124 | $(top_builddir)/src/block/libgnunetblock.la \ |
125 | $(top_builddir)/src/block/libgnunetblockgroup.la \ | ||
123 | $(top_builddir)/src/datacache/libgnunetdatacache.la \ | 126 | $(top_builddir)/src/datacache/libgnunetdatacache.la \ |
124 | $(top_builddir)/src/util/libgnunetutil.la \ | 127 | $(top_builddir)/src/util/libgnunetutil.la \ |
125 | -lm | 128 | -lm |
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index 5ba4e5820..a42356e5f 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2011, 2016, 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -362,21 +362,22 @@ client_disconnect_cb (void *cls, | |||
362 | static void | 362 | static void |
363 | transmit_request (struct ClientQueryRecord *cqr) | 363 | transmit_request (struct ClientQueryRecord *cqr) |
364 | { | 364 | { |
365 | int32_t reply_bf_mutator; | 365 | struct GNUNET_BLOCK_Group *bg; |
366 | struct GNUNET_CONTAINER_BloomFilter *reply_bf; | ||
367 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; | 366 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; |
368 | 367 | ||
369 | GNUNET_STATISTICS_update (GDS_stats, | 368 | GNUNET_STATISTICS_update (GDS_stats, |
370 | gettext_noop ("# GET requests from clients injected"), | 369 | gettext_noop ("# GET requests from clients injected"), |
371 | 1, | 370 | 1, |
372 | GNUNET_NO); | 371 | GNUNET_NO); |
373 | reply_bf_mutator = | 372 | bg = GNUNET_BLOCK_group_create (GDS_block_context, |
374 | (int32_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 373 | cqr->type, |
375 | UINT32_MAX); | 374 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
376 | reply_bf | 375 | UINT32_MAX), |
377 | = GNUNET_BLOCK_construct_bloomfilter (reply_bf_mutator, | 376 | NULL, |
378 | cqr->seen_replies, | 377 | 0); |
379 | cqr->seen_replies_count); | 378 | GNUNET_BLOCK_group_set_seen (bg, |
379 | cqr->seen_replies, | ||
380 | cqr->seen_replies_count); | ||
380 | peer_bf | 381 | peer_bf |
381 | = GNUNET_CONTAINER_bloomfilter_init (NULL, | 382 | = GNUNET_CONTAINER_bloomfilter_init (NULL, |
382 | DHT_BLOOM_SIZE, | 383 | DHT_BLOOM_SIZE, |
@@ -393,10 +394,9 @@ transmit_request (struct ClientQueryRecord *cqr) | |||
393 | &cqr->key, | 394 | &cqr->key, |
394 | cqr->xquery, | 395 | cqr->xquery, |
395 | cqr->xquery_size, | 396 | cqr->xquery_size, |
396 | reply_bf, | 397 | bg, |
397 | reply_bf_mutator, | ||
398 | peer_bf); | 398 | peer_bf); |
399 | GNUNET_CONTAINER_bloomfilter_free (reply_bf); | 399 | GNUNET_BLOCK_group_destroy (bg); |
400 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); | 400 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); |
401 | 401 | ||
402 | /* exponential back-off for retries. | 402 | /* exponential back-off for retries. |
@@ -668,7 +668,6 @@ handle_dht_local_get (void *cls, | |||
668 | cqr->xquery, | 668 | cqr->xquery, |
669 | xquery_size, | 669 | xquery_size, |
670 | NULL, | 670 | NULL, |
671 | 0, | ||
672 | &handle_local_result, | 671 | &handle_local_result, |
673 | ch); | 672 | ch); |
674 | GNUNET_SERVICE_client_continue (ch->client); | 673 | GNUNET_SERVICE_client_continue (ch->client); |
@@ -1052,10 +1051,9 @@ forward_reply (void *cls, | |||
1052 | eval | 1051 | eval |
1053 | = GNUNET_BLOCK_evaluate (GDS_block_context, | 1052 | = GNUNET_BLOCK_evaluate (GDS_block_context, |
1054 | record->type, | 1053 | record->type, |
1054 | NULL, | ||
1055 | GNUNET_BLOCK_EO_NONE, | 1055 | GNUNET_BLOCK_EO_NONE, |
1056 | key, | 1056 | key, |
1057 | NULL, | ||
1058 | 0, | ||
1059 | record->xquery, | 1057 | record->xquery, |
1060 | record->xquery_size, | 1058 | record->xquery_size, |
1061 | frc->data, | 1059 | frc->data, |
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c index 74fa1cc29..fef637cad 100644 --- a/src/dht/gnunet-service-dht_datacache.c +++ b/src/dht/gnunet-service-dht_datacache.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2011, 2015 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2011, 2015, 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -109,39 +109,34 @@ struct GetRequestContext | |||
109 | const void *xquery; | 109 | const void *xquery; |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * Bloomfilter to filter out duplicate replies (updated) | ||
113 | */ | ||
114 | struct GNUNET_CONTAINER_BloomFilter **reply_bf; | ||
115 | |||
116 | /** | ||
117 | * The key this request was about | 112 | * The key this request was about |
118 | */ | 113 | */ |
119 | struct GNUNET_HashCode key; | 114 | struct GNUNET_HashCode key; |
120 | 115 | ||
121 | /** | 116 | /** |
122 | * Number of bytes in xquery. | 117 | * Block group to use to evaluate replies (updated) |
123 | */ | 118 | */ |
124 | size_t xquery_size; | 119 | struct GNUNET_BLOCK_Group *bg; |
125 | 120 | ||
126 | /** | 121 | /** |
127 | * Mutator value for the @e reply_bf, see gnunet_block_lib.h | 122 | * Function to call on results. |
128 | */ | 123 | */ |
129 | uint32_t reply_bf_mutator; | 124 | GDS_DATACACHE_GetCallback gc; |
130 | 125 | ||
131 | /** | 126 | /** |
132 | * Return value to give back. | 127 | * Closure for @e gc. |
133 | */ | 128 | */ |
134 | enum GNUNET_BLOCK_EvaluationResult eval; | 129 | void *gc_cls; |
135 | 130 | ||
136 | /** | 131 | /** |
137 | * Function to call on results. | 132 | * Number of bytes in xquery. |
138 | */ | 133 | */ |
139 | GDS_DATACACHE_GetCallback gc; | 134 | size_t xquery_size; |
140 | 135 | ||
141 | /** | 136 | /** |
142 | * Closure for @e gc. | 137 | * Return value to give back. |
143 | */ | 138 | */ |
144 | void *gc_cls; | 139 | enum GNUNET_BLOCK_EvaluationResult eval; |
145 | 140 | ||
146 | }; | 141 | }; |
147 | 142 | ||
@@ -181,10 +176,9 @@ datacache_get_iterator (void *cls, | |||
181 | eval | 176 | eval |
182 | = GNUNET_BLOCK_evaluate (GDS_block_context, | 177 | = GNUNET_BLOCK_evaluate (GDS_block_context, |
183 | type, | 178 | type, |
179 | ctx->bg, | ||
184 | GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO, | 180 | GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO, |
185 | key, | 181 | key, |
186 | ctx->reply_bf, | ||
187 | ctx->reply_bf_mutator, | ||
188 | ctx->xquery, | 182 | ctx->xquery, |
189 | ctx->xquery_size, | 183 | ctx->xquery_size, |
190 | data, | 184 | data, |
@@ -256,8 +250,7 @@ datacache_get_iterator (void *cls, | |||
256 | * @param type requested data type | 250 | * @param type requested data type |
257 | * @param xquery extended query | 251 | * @param xquery extended query |
258 | * @param xquery_size number of bytes in @a xquery | 252 | * @param xquery_size number of bytes in @a xquery |
259 | * @param reply_bf where the reply bf is (to be) stored, possibly updated, can be NULL | 253 | * @param bg block group to use for reply evaluation |
260 | * @param reply_bf_mutator mutation value for @a reply_bf | ||
261 | * @param gc function to call on the results | 254 | * @param gc function to call on the results |
262 | * @param gc_cls closure for @a gc | 255 | * @param gc_cls closure for @a gc |
263 | * @return evaluation result for the local replies | 256 | * @return evaluation result for the local replies |
@@ -267,8 +260,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, | |||
267 | enum GNUNET_BLOCK_Type type, | 260 | enum GNUNET_BLOCK_Type type, |
268 | const void *xquery, | 261 | const void *xquery, |
269 | size_t xquery_size, | 262 | size_t xquery_size, |
270 | struct GNUNET_CONTAINER_BloomFilter **reply_bf, | 263 | struct GNUNET_BLOCK_Group *bg, |
271 | uint32_t reply_bf_mutator, | ||
272 | GDS_DATACACHE_GetCallback gc, | 264 | GDS_DATACACHE_GetCallback gc, |
273 | void *gc_cls) | 265 | void *gc_cls) |
274 | { | 266 | { |
@@ -285,8 +277,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, | |||
285 | ctx.key = *key; | 277 | ctx.key = *key; |
286 | ctx.xquery = xquery; | 278 | ctx.xquery = xquery; |
287 | ctx.xquery_size = xquery_size; | 279 | ctx.xquery_size = xquery_size; |
288 | ctx.reply_bf = reply_bf; | 280 | ctx.bg = bg; |
289 | ctx.reply_bf_mutator = reply_bf_mutator; | ||
290 | ctx.gc = gc; | 281 | ctx.gc = gc; |
291 | ctx.gc_cls = gc_cls; | 282 | ctx.gc_cls = gc_cls; |
292 | r = GNUNET_DATACACHE_get (datacache, | 283 | r = GNUNET_DATACACHE_get (datacache, |
diff --git a/src/dht/gnunet-service-dht_datacache.h b/src/dht/gnunet-service-dht_datacache.h index 5069883c7..ff6ae23da 100644 --- a/src/dht/gnunet-service-dht_datacache.h +++ b/src/dht/gnunet-service-dht_datacache.h | |||
@@ -87,8 +87,7 @@ typedef void | |||
87 | * @param type requested data type | 87 | * @param type requested data type |
88 | * @param xquery extended query | 88 | * @param xquery extended query |
89 | * @param xquery_size number of bytes in xquery | 89 | * @param xquery_size number of bytes in xquery |
90 | * @param reply_bf where the reply bf is (to be) stored, possibly updated!, can be NULL | 90 | * @param bg block group to use for evaluation of replies |
91 | * @param reply_bf_mutator mutation value for reply_bf | ||
92 | * @param gc function to call on the results | 91 | * @param gc function to call on the results |
93 | * @param gc_cls closure for @a gc | 92 | * @param gc_cls closure for @a gc |
94 | * @return evaluation result for the local replies | 93 | * @return evaluation result for the local replies |
@@ -98,8 +97,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, | |||
98 | enum GNUNET_BLOCK_Type type, | 97 | enum GNUNET_BLOCK_Type type, |
99 | const void *xquery, | 98 | const void *xquery, |
100 | size_t xquery_size, | 99 | size_t xquery_size, |
101 | struct GNUNET_CONTAINER_BloomFilter **reply_bf, | 100 | struct GNUNET_BLOCK_Group *bg, |
102 | uint32_t reply_bf_mutator, | ||
103 | GDS_DATACACHE_GetCallback gc, | 101 | GDS_DATACACHE_GetCallback gc, |
104 | void *gc_cls); | 102 | void *gc_cls); |
105 | 103 | ||
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 7f3a44588..1bbc95a06 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009-2016 GNUnet e.V. | 3 | Copyright (C) 2009-2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -27,6 +27,7 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_block_lib.h" | 29 | #include "gnunet_block_lib.h" |
30 | #include "gnunet_block_group_lib.h" | ||
30 | #include "gnunet_hello_lib.h" | 31 | #include "gnunet_hello_lib.h" |
31 | #include "gnunet_constants.h" | 32 | #include "gnunet_constants.h" |
32 | #include "gnunet_protocols.h" | 33 | #include "gnunet_protocols.h" |
@@ -50,7 +51,7 @@ | |||
50 | 51 | ||
51 | /** | 52 | /** |
52 | * Enable slow sanity checks to debug issues. | 53 | * Enable slow sanity checks to debug issues. |
53 | */ | 54 | */ |
54 | #define SANITY_CHECKS 1 | 55 | #define SANITY_CHECKS 1 |
55 | 56 | ||
56 | /** | 57 | /** |
@@ -602,27 +603,10 @@ update_connect_preferences () | |||
602 | 603 | ||
603 | 604 | ||
604 | /** | 605 | /** |
605 | * Closure for #add_known_to_bloom(). | ||
606 | */ | ||
607 | struct BloomConstructorContext | ||
608 | { | ||
609 | /** | ||
610 | * Bloom filter under construction. | ||
611 | */ | ||
612 | struct GNUNET_CONTAINER_BloomFilter *bloom; | ||
613 | |||
614 | /** | ||
615 | * Mutator to use. | ||
616 | */ | ||
617 | uint32_t bf_mutator; | ||
618 | }; | ||
619 | |||
620 | |||
621 | /** | ||
622 | * Add each of the peers we already know to the bloom filter of | 606 | * Add each of the peers we already know to the bloom filter of |
623 | * the request so that we don't get duplicate HELLOs. | 607 | * the request so that we don't get duplicate HELLOs. |
624 | * | 608 | * |
625 | * @param cls the 'struct BloomConstructorContext'. | 609 | * @param cls the `struct GNUNET_BLOCK_Group` |
626 | * @param key peer identity to add to the bloom filter | 610 | * @param key peer identity to add to the bloom filter |
627 | * @param value value the peer information (unused) | 611 | * @param value value the peer information (unused) |
628 | * @return #GNUNET_YES (we should continue to iterate) | 612 | * @return #GNUNET_YES (we should continue to iterate) |
@@ -632,22 +616,17 @@ add_known_to_bloom (void *cls, | |||
632 | const struct GNUNET_PeerIdentity *key, | 616 | const struct GNUNET_PeerIdentity *key, |
633 | void *value) | 617 | void *value) |
634 | { | 618 | { |
635 | struct BloomConstructorContext *ctx = cls; | 619 | struct GNUNET_BLOCK_Group *bg = cls; |
636 | struct GNUNET_HashCode key_hash; | 620 | struct GNUNET_HashCode key_hash; |
637 | struct GNUNET_HashCode mh; | ||
638 | 621 | ||
639 | GNUNET_CRYPTO_hash (key, | 622 | GNUNET_CRYPTO_hash (key, |
640 | sizeof (struct GNUNET_PeerIdentity), | 623 | sizeof (struct GNUNET_PeerIdentity), |
641 | &key_hash); | 624 | &key_hash); |
642 | GNUNET_BLOCK_mingle_hash (&key_hash, | 625 | GNUNET_BLOCK_GROUP_bf_test_and_set (bg, |
643 | ctx->bf_mutator, | 626 | &key_hash); |
644 | &mh); | ||
645 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
646 | "Adding known peer (%s) to bloomfilter for FIND PEER with mutation %u\n", | 628 | "Adding known peer (%s) to bloomfilter for FIND PEER\n", |
647 | GNUNET_i2s (key), | 629 | GNUNET_i2s (key)); |
648 | ctx->bf_mutator); | ||
649 | GNUNET_CONTAINER_bloomfilter_add (ctx->bloom, | ||
650 | &mh); | ||
651 | return GNUNET_YES; | 630 | return GNUNET_YES; |
652 | } | 631 | } |
653 | 632 | ||
@@ -663,7 +642,7 @@ static void | |||
663 | send_find_peer_message (void *cls) | 642 | send_find_peer_message (void *cls) |
664 | { | 643 | { |
665 | struct GNUNET_TIME_Relative next_send_time; | 644 | struct GNUNET_TIME_Relative next_send_time; |
666 | struct BloomConstructorContext bcc; | 645 | struct GNUNET_BLOCK_Group *bg; |
667 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; | 646 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; |
668 | 647 | ||
669 | find_peer_task = NULL; | 648 | find_peer_task = NULL; |
@@ -677,30 +656,37 @@ send_find_peer_message (void *cls) | |||
677 | newly_found_peers = 0; | 656 | newly_found_peers = 0; |
678 | return; | 657 | return; |
679 | } | 658 | } |
680 | bcc.bf_mutator = | 659 | bg = GNUNET_BLOCK_GROUP_bf_create (NULL, |
681 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 660 | DHT_BLOOM_SIZE, |
682 | UINT32_MAX); | 661 | GNUNET_CONSTANTS_BLOOMFILTER_K, |
683 | bcc.bloom = | 662 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
684 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, | 663 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
685 | GNUNET_CONSTANTS_BLOOMFILTER_K); | 664 | UINT32_MAX), |
665 | NULL, | ||
666 | 0); | ||
686 | GNUNET_CONTAINER_multipeermap_iterate (all_connected_peers, | 667 | GNUNET_CONTAINER_multipeermap_iterate (all_connected_peers, |
687 | &add_known_to_bloom, | 668 | &add_known_to_bloom, |
688 | &bcc); | 669 | bg); |
689 | GNUNET_STATISTICS_update (GDS_stats, | 670 | GNUNET_STATISTICS_update (GDS_stats, |
690 | gettext_noop ("# FIND PEER messages initiated"), | 671 | gettext_noop ("# FIND PEER messages initiated"), |
691 | 1, | 672 | 1, |
692 | GNUNET_NO); | 673 | GNUNET_NO); |
693 | peer_bf = | 674 | peer_bf |
694 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, | 675 | = GNUNET_CONTAINER_bloomfilter_init (NULL, |
676 | DHT_BLOOM_SIZE, | ||
695 | GNUNET_CONSTANTS_BLOOMFILTER_K); | 677 | GNUNET_CONSTANTS_BLOOMFILTER_K); |
696 | // FIXME: pass priority!? | 678 | // FIXME: pass priority!? |
697 | GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_HELLO, | 679 | GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_HELLO, |
698 | GNUNET_DHT_RO_FIND_PEER, | 680 | GNUNET_DHT_RO_FIND_PEER, |
699 | FIND_PEER_REPLICATION_LEVEL, 0, | 681 | FIND_PEER_REPLICATION_LEVEL, |
700 | &my_identity_hash, NULL, 0, bcc.bloom, | 682 | 0, |
701 | bcc.bf_mutator, peer_bf); | 683 | &my_identity_hash, |
684 | NULL, | ||
685 | 0, | ||
686 | bg, | ||
687 | peer_bf); | ||
702 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); | 688 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); |
703 | GNUNET_CONTAINER_bloomfilter_free (bcc.bloom); | 689 | GNUNET_BLOCK_group_destroy (bg); |
704 | /* schedule next round */ | 690 | /* schedule next round */ |
705 | next_send_time.rel_value_us = | 691 | next_send_time.rel_value_us = |
706 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value_us + | 692 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value_us + |
@@ -1357,8 +1343,7 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type, | |||
1357 | * @param key key for the content | 1343 | * @param key key for the content |
1358 | * @param xquery extended query | 1344 | * @param xquery extended query |
1359 | * @param xquery_size number of bytes in @a xquery | 1345 | * @param xquery_size number of bytes in @a xquery |
1360 | * @param reply_bf bloomfilter to filter duplicates | 1346 | * @param bg group to use for filtering replies |
1361 | * @param reply_bf_mutator mutator for @a reply_bf | ||
1362 | * @param peer_bf filter for peers not to select (again) | 1347 | * @param peer_bf filter for peers not to select (again) |
1363 | * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not | 1348 | * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not |
1364 | */ | 1349 | */ |
@@ -1366,14 +1351,14 @@ int | |||
1366 | GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | 1351 | GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, |
1367 | enum GNUNET_DHT_RouteOption options, | 1352 | enum GNUNET_DHT_RouteOption options, |
1368 | uint32_t desired_replication_level, | 1353 | uint32_t desired_replication_level, |
1369 | uint32_t hop_count, const struct GNUNET_HashCode * key, | 1354 | uint32_t hop_count, |
1370 | const void *xquery, size_t xquery_size, | 1355 | const struct GNUNET_HashCode *key, |
1371 | const struct GNUNET_CONTAINER_BloomFilter *reply_bf, | 1356 | const void *xquery, |
1372 | uint32_t reply_bf_mutator, | 1357 | size_t xquery_size, |
1358 | struct GNUNET_BLOCK_Group *bg, | ||
1373 | struct GNUNET_CONTAINER_BloomFilter *peer_bf) | 1359 | struct GNUNET_CONTAINER_BloomFilter *peer_bf) |
1374 | { | 1360 | { |
1375 | unsigned int target_count; | 1361 | unsigned int target_count; |
1376 | unsigned int i; | ||
1377 | struct PeerInfo **targets; | 1362 | struct PeerInfo **targets; |
1378 | struct PeerInfo *target; | 1363 | struct PeerInfo *target; |
1379 | struct GNUNET_MQ_Envelope *env; | 1364 | struct GNUNET_MQ_Envelope *env; |
@@ -1381,7 +1366,9 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | |||
1381 | struct PeerGetMessage *pgm; | 1366 | struct PeerGetMessage *pgm; |
1382 | char *xq; | 1367 | char *xq; |
1383 | size_t reply_bf_size; | 1368 | size_t reply_bf_size; |
1369 | void *reply_bf; | ||
1384 | unsigned int skip_count; | 1370 | unsigned int skip_count; |
1371 | uint32_t bf_nonce; | ||
1385 | 1372 | ||
1386 | GNUNET_assert (NULL != peer_bf); | 1373 | GNUNET_assert (NULL != peer_bf); |
1387 | GNUNET_STATISTICS_update (GDS_stats, | 1374 | GNUNET_STATISTICS_update (GDS_stats, |
@@ -1408,11 +1395,22 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | |||
1408 | GNUNET_i2s (&my_identity)); | 1395 | GNUNET_i2s (&my_identity)); |
1409 | return GNUNET_NO; | 1396 | return GNUNET_NO; |
1410 | } | 1397 | } |
1411 | reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf); | 1398 | if (GNUNET_OK != |
1399 | GNUNET_BLOCK_group_serialize (bg, | ||
1400 | &bf_nonce, | ||
1401 | &reply_bf, | ||
1402 | &reply_bf_size)) | ||
1403 | { | ||
1404 | reply_bf = NULL; | ||
1405 | reply_bf_size = 0; | ||
1406 | bf_nonce = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1407 | UINT32_MAX); | ||
1408 | } | ||
1412 | msize = xquery_size + reply_bf_size; | 1409 | msize = xquery_size + reply_bf_size; |
1413 | if (msize + sizeof (struct PeerGetMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1410 | if (msize + sizeof (struct PeerGetMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
1414 | { | 1411 | { |
1415 | GNUNET_break (0); | 1412 | GNUNET_break (0); |
1413 | GNUNET_free_non_null (reply_bf); | ||
1416 | GNUNET_free (targets); | 1414 | GNUNET_free (targets); |
1417 | return GNUNET_NO; | 1415 | return GNUNET_NO; |
1418 | } | 1416 | } |
@@ -1422,7 +1420,7 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | |||
1422 | GNUNET_NO); | 1420 | GNUNET_NO); |
1423 | /* forward request */ | 1421 | /* forward request */ |
1424 | skip_count = 0; | 1422 | skip_count = 0; |
1425 | for (i = 0; i < target_count; i++) | 1423 | for (unsigned int i = 0; i < target_count; i++) |
1426 | { | 1424 | { |
1427 | target = targets[i]; | 1425 | target = targets[i]; |
1428 | if (GNUNET_MQ_get_length (target->mq) >= MAXIMUM_PENDING_PER_PEER) | 1426 | if (GNUNET_MQ_get_length (target->mq) >= MAXIMUM_PENDING_PER_PEER) |
@@ -1447,7 +1445,7 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | |||
1447 | pgm->hop_count = htonl (hop_count + 1); | 1445 | pgm->hop_count = htonl (hop_count + 1); |
1448 | pgm->desired_replication_level = htonl (desired_replication_level); | 1446 | pgm->desired_replication_level = htonl (desired_replication_level); |
1449 | pgm->xquery_size = htonl (xquery_size); | 1447 | pgm->xquery_size = htonl (xquery_size); |
1450 | pgm->bf_mutator = reply_bf_mutator; | 1448 | pgm->bf_mutator = bf_nonce; |
1451 | GNUNET_break (GNUNET_YES == | 1449 | GNUNET_break (GNUNET_YES == |
1452 | GNUNET_CONTAINER_bloomfilter_test (peer_bf, | 1450 | GNUNET_CONTAINER_bloomfilter_test (peer_bf, |
1453 | &target->phash)); | 1451 | &target->phash)); |
@@ -1460,16 +1458,14 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | |||
1460 | GNUNET_memcpy (xq, | 1458 | GNUNET_memcpy (xq, |
1461 | xquery, | 1459 | xquery, |
1462 | xquery_size); | 1460 | xquery_size); |
1463 | if (NULL != reply_bf) | 1461 | GNUNET_memcpy (&xq[xquery_size], |
1464 | GNUNET_assert (GNUNET_OK == | 1462 | reply_bf, |
1465 | GNUNET_CONTAINER_bloomfilter_get_raw_data (reply_bf, | 1463 | reply_bf_size); |
1466 | &xq | ||
1467 | [xquery_size], | ||
1468 | reply_bf_size)); | ||
1469 | GNUNET_MQ_send (target->mq, | 1464 | GNUNET_MQ_send (target->mq, |
1470 | env); | 1465 | env); |
1471 | } | 1466 | } |
1472 | GNUNET_free (targets); | 1467 | GNUNET_free (targets); |
1468 | GNUNET_free_non_null (reply_bf); | ||
1473 | return (skip_count < target_count) ? GNUNET_OK : GNUNET_NO; | 1469 | return (skip_count < target_count) ? GNUNET_OK : GNUNET_NO; |
1474 | } | 1470 | } |
1475 | 1471 | ||
@@ -1717,11 +1713,12 @@ handle_dht_p2p_put (void *cls, | |||
1717 | { | 1713 | { |
1718 | switch (GNUNET_BLOCK_evaluate (GDS_block_context, | 1714 | switch (GNUNET_BLOCK_evaluate (GDS_block_context, |
1719 | ntohl (put->type), | 1715 | ntohl (put->type), |
1716 | NULL, /* query group */ | ||
1720 | GNUNET_BLOCK_EO_NONE, | 1717 | GNUNET_BLOCK_EO_NONE, |
1721 | NULL, /* query */ | 1718 | NULL, /* query */ |
1722 | NULL, 0, /* bloom filer */ | ||
1723 | NULL, 0, /* xquery */ | 1719 | NULL, 0, /* xquery */ |
1724 | payload, payload_size)) | 1720 | payload, |
1721 | payload_size)) | ||
1725 | { | 1722 | { |
1726 | case GNUNET_BLOCK_EVALUATION_OK_MORE: | 1723 | case GNUNET_BLOCK_EVALUATION_OK_MORE: |
1727 | case GNUNET_BLOCK_EVALUATION_OK_LAST: | 1724 | case GNUNET_BLOCK_EVALUATION_OK_LAST: |
@@ -1762,7 +1759,7 @@ handle_dht_p2p_put (void *cls, | |||
1762 | } | 1759 | } |
1763 | GNUNET_break (0 != memcmp (&pp[i], | 1760 | GNUNET_break (0 != memcmp (&pp[i], |
1764 | peer->id, | 1761 | peer->id, |
1765 | sizeof (struct GNUNET_PeerIdentity))); | 1762 | sizeof (struct GNUNET_PeerIdentity))); |
1766 | } | 1763 | } |
1767 | #endif | 1764 | #endif |
1768 | GNUNET_memcpy (pp, | 1765 | GNUNET_memcpy (pp, |
@@ -1830,30 +1827,25 @@ handle_dht_p2p_put (void *cls, | |||
1830 | * | 1827 | * |
1831 | * @param sender sender of the FIND PEER request | 1828 | * @param sender sender of the FIND PEER request |
1832 | * @param key peers close to this key are desired | 1829 | * @param key peers close to this key are desired |
1833 | * @param bf peers matching this bf are excluded | 1830 | * @param bg group for filtering peers |
1834 | * @param bf_mutator mutator for bf | ||
1835 | */ | 1831 | */ |
1836 | static void | 1832 | static void |
1837 | handle_find_peer (const struct GNUNET_PeerIdentity *sender, | 1833 | handle_find_peer (const struct GNUNET_PeerIdentity *sender, |
1838 | const struct GNUNET_HashCode *key, | 1834 | const struct GNUNET_HashCode *key, |
1839 | struct GNUNET_CONTAINER_BloomFilter *bf, | 1835 | struct GNUNET_BLOCK_Group *bg) |
1840 | uint32_t bf_mutator) | ||
1841 | { | 1836 | { |
1842 | int bucket_idx; | 1837 | int bucket_idx; |
1843 | struct PeerBucket *bucket; | 1838 | struct PeerBucket *bucket; |
1844 | struct PeerInfo *peer; | 1839 | struct PeerInfo *peer; |
1845 | unsigned int choice; | 1840 | unsigned int choice; |
1846 | struct GNUNET_HashCode mhash; | ||
1847 | const struct GNUNET_HELLO_Message *hello; | 1841 | const struct GNUNET_HELLO_Message *hello; |
1848 | 1842 | ||
1849 | /* first, check about our own HELLO */ | 1843 | /* first, check about our own HELLO */ |
1850 | if (NULL != GDS_my_hello) | 1844 | if (NULL != GDS_my_hello) |
1851 | { | 1845 | { |
1852 | GNUNET_BLOCK_mingle_hash (&my_identity_hash, | 1846 | if (GNUNET_YES != |
1853 | bf_mutator, | 1847 | GNUNET_BLOCK_GROUP_bf_test_and_set (bg, |
1854 | &mhash); | 1848 | &my_identity_hash)) |
1855 | if ((NULL == bf) || | ||
1856 | (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (bf, &mhash))) | ||
1857 | { | 1849 | { |
1858 | size_t hello_size; | 1850 | size_t hello_size; |
1859 | 1851 | ||
@@ -1913,18 +1905,15 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender, | |||
1913 | do | 1905 | do |
1914 | { | 1906 | { |
1915 | peer = peer->next; | 1907 | peer = peer->next; |
1916 | if (choice-- == 0) | 1908 | if (0 == choice--) |
1917 | return; /* no non-masked peer available */ | 1909 | return; /* no non-masked peer available */ |
1918 | if (NULL == peer) | 1910 | if (NULL == peer) |
1919 | peer = bucket->head; | 1911 | peer = bucket->head; |
1920 | GNUNET_BLOCK_mingle_hash (&peer->phash, | ||
1921 | bf_mutator, | ||
1922 | &mhash); | ||
1923 | hello = GDS_HELLO_get (peer->id); | 1912 | hello = GDS_HELLO_get (peer->id); |
1924 | } while ( (hello == NULL) || | 1913 | } while ( (NULL == hello) || |
1925 | (GNUNET_YES == | 1914 | (GNUNET_YES == |
1926 | GNUNET_CONTAINER_bloomfilter_test (bf, | 1915 | GNUNET_BLOCK_GROUP_bf_test_and_set (bg, |
1927 | &mhash)) ); | 1916 | &peer->phash)) ); |
1928 | GDS_NEIGHBOURS_handle_reply (sender, | 1917 | GDS_NEIGHBOURS_handle_reply (sender, |
1929 | GNUNET_BLOCK_TYPE_DHT_HELLO, | 1918 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
1930 | GNUNET_TIME_relative_to_absolute | 1919 | GNUNET_TIME_relative_to_absolute |
@@ -2019,7 +2008,7 @@ handle_dht_p2p_get (void *cls, | |||
2019 | enum GNUNET_BLOCK_Type type; | 2008 | enum GNUNET_BLOCK_Type type; |
2020 | enum GNUNET_DHT_RouteOption options; | 2009 | enum GNUNET_DHT_RouteOption options; |
2021 | enum GNUNET_BLOCK_EvaluationResult eval; | 2010 | enum GNUNET_BLOCK_EvaluationResult eval; |
2022 | struct GNUNET_CONTAINER_BloomFilter *reply_bf; | 2011 | struct GNUNET_BLOCK_Group *bg; |
2023 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; | 2012 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; |
2024 | const char *xquery; | 2013 | const char *xquery; |
2025 | int forwarded; | 2014 | int forwarded; |
@@ -2036,7 +2025,6 @@ handle_dht_p2p_get (void *cls, | |||
2036 | type = ntohl (get->type); | 2025 | type = ntohl (get->type); |
2037 | options = ntohl (get->options); | 2026 | options = ntohl (get->options); |
2038 | xquery = (const char *) &get[1]; | 2027 | xquery = (const char *) &get[1]; |
2039 | reply_bf = NULL; | ||
2040 | GNUNET_STATISTICS_update (GDS_stats, | 2028 | GNUNET_STATISTICS_update (GDS_stats, |
2041 | gettext_noop ("# P2P GET requests received"), | 2029 | gettext_noop ("# P2P GET requests received"), |
2042 | 1, | 2030 | 1, |
@@ -2064,19 +2052,17 @@ handle_dht_p2p_get (void *cls, | |||
2064 | xquery); | 2052 | xquery); |
2065 | GNUNET_free (tmp); | 2053 | GNUNET_free (tmp); |
2066 | } | 2054 | } |
2067 | 2055 | bg = GNUNET_BLOCK_group_create (GDS_block_context, | |
2068 | if (reply_bf_size > 0) | 2056 | type, |
2069 | reply_bf = | 2057 | get->bf_mutator, |
2070 | GNUNET_CONTAINER_bloomfilter_init (&xquery[xquery_size], | 2058 | &xquery[xquery_size], |
2071 | reply_bf_size, | 2059 | reply_bf_size); |
2072 | GNUNET_CONSTANTS_BLOOMFILTER_K); | 2060 | eval |
2073 | eval = | 2061 | = GNUNET_BLOCK_evaluate (GDS_block_context, |
2074 | GNUNET_BLOCK_evaluate (GDS_block_context, | ||
2075 | type, | 2062 | type, |
2063 | bg, | ||
2076 | GNUNET_BLOCK_EO_NONE, | 2064 | GNUNET_BLOCK_EO_NONE, |
2077 | &get->key, | 2065 | &get->key, |
2078 | &reply_bf, | ||
2079 | get->bf_mutator, | ||
2080 | xquery, | 2066 | xquery, |
2081 | xquery_size, | 2067 | xquery_size, |
2082 | NULL, | 2068 | NULL, |
@@ -2085,8 +2071,7 @@ handle_dht_p2p_get (void *cls, | |||
2085 | { | 2071 | { |
2086 | /* request invalid or block type not supported */ | 2072 | /* request invalid or block type not supported */ |
2087 | GNUNET_break_op (eval == GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED); | 2073 | GNUNET_break_op (eval == GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED); |
2088 | if (NULL != reply_bf) | 2074 | GNUNET_BLOCK_group_destroy (bg); |
2089 | GNUNET_CONTAINER_bloomfilter_free (reply_bf); | ||
2090 | return; | 2075 | return; |
2091 | } | 2076 | } |
2092 | peer_bf = GNUNET_CONTAINER_bloomfilter_init (get->bloomfilter, | 2077 | peer_bf = GNUNET_CONTAINER_bloomfilter_init (get->bloomfilter, |
@@ -2098,12 +2083,11 @@ handle_dht_p2p_get (void *cls, | |||
2098 | /* remember request for routing replies */ | 2083 | /* remember request for routing replies */ |
2099 | GDS_ROUTING_add (peer->id, | 2084 | GDS_ROUTING_add (peer->id, |
2100 | type, | 2085 | type, |
2086 | bg, /* bg now owned by routing, but valid at least until end of this function! */ | ||
2101 | options, | 2087 | options, |
2102 | &get->key, | 2088 | &get->key, |
2103 | xquery, | 2089 | xquery, |
2104 | xquery_size, | 2090 | xquery_size); |
2105 | reply_bf, | ||
2106 | get->bf_mutator); | ||
2107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2091 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2108 | "GET for %s at %s after %u hops\n", | 2092 | "GET for %s at %s after %u hops\n", |
2109 | GNUNET_h2s (&get->key), | 2093 | GNUNET_h2s (&get->key), |
@@ -2122,8 +2106,7 @@ handle_dht_p2p_get (void *cls, | |||
2122 | GNUNET_NO); | 2106 | GNUNET_NO); |
2123 | handle_find_peer (peer->id, | 2107 | handle_find_peer (peer->id, |
2124 | &get->key, | 2108 | &get->key, |
2125 | reply_bf, | 2109 | bg); |
2126 | get->bf_mutator); | ||
2127 | } | 2110 | } |
2128 | else | 2111 | else |
2129 | { | 2112 | { |
@@ -2131,8 +2114,7 @@ handle_dht_p2p_get (void *cls, | |||
2131 | type, | 2114 | type, |
2132 | xquery, | 2115 | xquery, |
2133 | xquery_size, | 2116 | xquery_size, |
2134 | &reply_bf, | 2117 | bg, |
2135 | get->bf_mutator, | ||
2136 | &handle_local_result, | 2118 | &handle_local_result, |
2137 | NULL); | 2119 | NULL); |
2138 | } | 2120 | } |
@@ -2155,8 +2137,7 @@ handle_dht_p2p_get (void *cls, | |||
2155 | &get->key, | 2137 | &get->key, |
2156 | xquery, | 2138 | xquery, |
2157 | xquery_size, | 2139 | xquery_size, |
2158 | reply_bf, | 2140 | bg, |
2159 | get->bf_mutator, | ||
2160 | peer_bf); | 2141 | peer_bf); |
2161 | GDS_CLIENTS_process_get (options | 2142 | GDS_CLIENTS_process_get (options |
2162 | | (GNUNET_OK == forwarded) | 2143 | | (GNUNET_OK == forwarded) |
@@ -2168,10 +2149,7 @@ handle_dht_p2p_get (void *cls, | |||
2168 | NULL, | 2149 | NULL, |
2169 | &get->key); | 2150 | &get->key); |
2170 | 2151 | ||
2171 | 2152 | /* clean up; note that 'bg' is owned by routing now! */ | |
2172 | /* clean up */ | ||
2173 | if (NULL != reply_bf) | ||
2174 | GNUNET_CONTAINER_bloomfilter_free (reply_bf); | ||
2175 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); | 2153 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); |
2176 | } | 2154 | } |
2177 | 2155 | ||
@@ -2310,7 +2288,7 @@ handle_dht_p2p_result (void *cls, | |||
2310 | } | 2288 | } |
2311 | GNUNET_break (0 != memcmp (&get_path[i], | 2289 | GNUNET_break (0 != memcmp (&get_path[i], |
2312 | peer->id, | 2290 | peer->id, |
2313 | sizeof (struct GNUNET_PeerIdentity))); | 2291 | sizeof (struct GNUNET_PeerIdentity))); |
2314 | } | 2292 | } |
2315 | #endif | 2293 | #endif |
2316 | GNUNET_memcpy (xget_path, | 2294 | GNUNET_memcpy (xget_path, |
diff --git a/src/dht/gnunet-service-dht_neighbours.h b/src/dht/gnunet-service-dht_neighbours.h index d89e5c54f..34b76ee8a 100644 --- a/src/dht/gnunet-service-dht_neighbours.h +++ b/src/dht/gnunet-service-dht_neighbours.h | |||
@@ -77,8 +77,7 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type, | |||
77 | * @param key key for the content | 77 | * @param key key for the content |
78 | * @param xquery extended query | 78 | * @param xquery extended query |
79 | * @param xquery_size number of bytes in @a xquery | 79 | * @param xquery_size number of bytes in @a xquery |
80 | * @param reply_bf bloomfilter to filter duplicates | 80 | * @param bg block group to filter replies |
81 | * @param reply_bf_mutator mutator for @a reply_bf | ||
82 | * @param peer_bf filter for peers not to select (again, updated) | 81 | * @param peer_bf filter for peers not to select (again, updated) |
83 | * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not | 82 | * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not |
84 | */ | 83 | */ |
@@ -88,9 +87,9 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | |||
88 | uint32_t desired_replication_level, | 87 | uint32_t desired_replication_level, |
89 | uint32_t hop_count, | 88 | uint32_t hop_count, |
90 | const struct GNUNET_HashCode *key, | 89 | const struct GNUNET_HashCode *key, |
91 | const void *xquery, size_t xquery_size, | 90 | const void *xquery, |
92 | const struct GNUNET_CONTAINER_BloomFilter *reply_bf, | 91 | size_t xquery_size, |
93 | uint32_t reply_bf_mutator, | 92 | struct GNUNET_BLOCK_Group *bg, |
94 | struct GNUNET_CONTAINER_BloomFilter *peer_bf); | 93 | struct GNUNET_CONTAINER_BloomFilter *peer_bf); |
95 | 94 | ||
96 | 95 | ||
@@ -114,12 +113,13 @@ void | |||
114 | GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target, | 113 | GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target, |
115 | enum GNUNET_BLOCK_Type type, | 114 | enum GNUNET_BLOCK_Type type, |
116 | struct GNUNET_TIME_Absolute expiration_time, | 115 | struct GNUNET_TIME_Absolute expiration_time, |
117 | const struct GNUNET_HashCode * key, | 116 | const struct GNUNET_HashCode *key, |
118 | unsigned int put_path_length, | 117 | unsigned int put_path_length, |
119 | const struct GNUNET_PeerIdentity *put_path, | 118 | const struct GNUNET_PeerIdentity *put_path, |
120 | unsigned int get_path_length, | 119 | unsigned int get_path_length, |
121 | const struct GNUNET_PeerIdentity *get_path, | 120 | const struct GNUNET_PeerIdentity *get_path, |
122 | const void *data, size_t data_size); | 121 | const void *data, |
122 | size_t data_size); | ||
123 | 123 | ||
124 | 124 | ||
125 | /** | 125 | /** |
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c index 71240a503..252995737 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; |
@@ -207,10 +202,9 @@ 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, |
@@ -343,7 +337,7 @@ expire_oldest_entry () | |||
343 | recent_req = GNUNET_CONTAINER_heap_peek (recent_heap); | 337 | recent_req = GNUNET_CONTAINER_heap_peek (recent_heap); |
344 | GNUNET_assert (recent_req != NULL); | 338 | GNUNET_assert (recent_req != NULL); |
345 | GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node); | 339 | GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node); |
346 | GNUNET_CONTAINER_bloomfilter_free (recent_req->reply_bf); | 340 | GNUNET_BLOCK_group_destroy (recent_req->bg); |
347 | GNUNET_assert (GNUNET_YES == | 341 | GNUNET_assert (GNUNET_YES == |
348 | GNUNET_CONTAINER_multihashmap_remove (recent_map, | 342 | GNUNET_CONTAINER_multihashmap_remove (recent_map, |
349 | &recent_req->key, | 343 | &recent_req->key, |
@@ -379,18 +373,10 @@ try_combine_recent (void *cls, | |||
379 | rr->xquery, | 373 | rr->xquery, |
380 | in->xquery_size)) ) | 374 | in->xquery_size)) ) |
381 | return GNUNET_OK; | 375 | return GNUNET_OK; |
382 | if (in->reply_bf_mutator != rr->reply_bf_mutator) | 376 | GNUNET_break (GNUNET_SYSERR != |
383 | { | 377 | GNUNET_BLOCK_group_merge (in->bg, |
384 | rr->reply_bf_mutator = in->reply_bf_mutator; | 378 | rr->bg)); |
385 | GNUNET_CONTAINER_bloomfilter_free (rr->reply_bf); | 379 | rr->bg = in->bg; |
386 | rr->reply_bf = in->reply_bf; | ||
387 | } | ||
388 | else | ||
389 | { | ||
390 | GNUNET_CONTAINER_bloomfilter_or2 (rr->reply_bf, | ||
391 | in->reply_bf); | ||
392 | GNUNET_CONTAINER_bloomfilter_free (in->reply_bf); | ||
393 | } | ||
394 | GNUNET_free (in); | 380 | GNUNET_free (in); |
395 | return GNUNET_SYSERR; | 381 | return GNUNET_SYSERR; |
396 | } | 382 | } |
@@ -411,12 +397,11 @@ try_combine_recent (void *cls, | |||
411 | void | 397 | void |
412 | GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, | 398 | GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, |
413 | enum GNUNET_BLOCK_Type type, | 399 | enum GNUNET_BLOCK_Type type, |
400 | struct GNUNET_BLOCK_Group *bg, | ||
414 | enum GNUNET_DHT_RouteOption options, | 401 | enum GNUNET_DHT_RouteOption options, |
415 | const struct GNUNET_HashCode *key, | 402 | const struct GNUNET_HashCode *key, |
416 | const void *xquery, | 403 | const void *xquery, |
417 | size_t xquery_size, | 404 | size_t xquery_size) |
418 | const struct GNUNET_CONTAINER_BloomFilter *reply_bf, | ||
419 | uint32_t reply_bf_mutator) | ||
420 | { | 405 | { |
421 | struct RecentRequest *recent_req; | 406 | struct RecentRequest *recent_req; |
422 | 407 | ||
@@ -424,17 +409,19 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, | |||
424 | expire_oldest_entry (); | 409 | expire_oldest_entry (); |
425 | GNUNET_STATISTICS_update (GDS_stats, | 410 | GNUNET_STATISTICS_update (GDS_stats, |
426 | gettext_noop ("# Entries added to routing table"), | 411 | gettext_noop ("# Entries added to routing table"), |
427 | 1, GNUNET_NO); | 412 | 1, |
413 | GNUNET_NO); | ||
428 | recent_req = GNUNET_malloc (sizeof (struct RecentRequest) + xquery_size); | 414 | recent_req = GNUNET_malloc (sizeof (struct RecentRequest) + xquery_size); |
429 | recent_req->peer = *sender; | 415 | recent_req->peer = *sender; |
430 | recent_req->key = *key; | 416 | recent_req->key = *key; |
431 | recent_req->reply_bf = GNUNET_CONTAINER_bloomfilter_copy (reply_bf); | 417 | recent_req->bg = bg; |
432 | recent_req->type = type; | 418 | recent_req->type = type; |
433 | recent_req->options = options; | 419 | recent_req->options = options; |
434 | recent_req->xquery = &recent_req[1]; | 420 | recent_req->xquery = &recent_req[1]; |
435 | GNUNET_memcpy (&recent_req[1], xquery, xquery_size); | 421 | GNUNET_memcpy (&recent_req[1], |
422 | xquery, | ||
423 | xquery_size); | ||
436 | recent_req->xquery_size = xquery_size; | 424 | recent_req->xquery_size = xquery_size; |
437 | recent_req->reply_bf_mutator = reply_bf_mutator; | ||
438 | if (GNUNET_SYSERR == | 425 | if (GNUNET_SYSERR == |
439 | GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, | 426 | GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, |
440 | key, | 427 | key, |
@@ -447,13 +434,14 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, | |||
447 | 1, GNUNET_NO); | 434 | 1, GNUNET_NO); |
448 | return; | 435 | return; |
449 | } | 436 | } |
450 | recent_req->heap_node = | 437 | recent_req->heap_node |
451 | GNUNET_CONTAINER_heap_insert (recent_heap, recent_req, | 438 | = GNUNET_CONTAINER_heap_insert (recent_heap, |
439 | recent_req, | ||
452 | GNUNET_TIME_absolute_get ().abs_value_us); | 440 | GNUNET_TIME_absolute_get ().abs_value_us); |
453 | GNUNET_CONTAINER_multihashmap_put (recent_map, key, recent_req, | 441 | GNUNET_CONTAINER_multihashmap_put (recent_map, |
442 | key, | ||
443 | recent_req, | ||
454 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 444 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
455 | |||
456 | |||
457 | } | 445 | } |
458 | 446 | ||
459 | 447 | ||
diff --git a/src/dht/gnunet-service-dht_routing.h b/src/dht/gnunet-service-dht_routing.h index 7c57361dc..1d9284164 100644 --- a/src/dht/gnunet-service-dht_routing.h +++ b/src/dht/gnunet-service-dht_routing.h | |||
@@ -67,21 +67,20 @@ GDS_ROUTING_process (void *cls, | |||
67 | * | 67 | * |
68 | * @param sender peer that originated the request | 68 | * @param sender peer that originated the request |
69 | * @param type type of the block | 69 | * @param type type of the block |
70 | * @param bg block group to evaluate replies, henceforth owned by routing | ||
70 | * @param options options for processing | 71 | * @param options options for processing |
71 | * @param key key for the content | 72 | * @param key key for the content |
72 | * @param xquery extended query | 73 | * @param xquery extended query |
73 | * @param xquery_size number of bytes in @a xquery | 74 | * @param xquery_size number of bytes in @a xquery |
74 | * @param reply_bf bloomfilter to filter duplicates | ||
75 | * @param reply_bf_mutator mutator for @a reply_bf | ||
76 | */ | 75 | */ |
77 | void | 76 | void |
78 | GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, | 77 | GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, |
79 | enum GNUNET_BLOCK_Type type, | 78 | enum GNUNET_BLOCK_Type type, |
79 | struct GNUNET_BLOCK_Group *bg, | ||
80 | enum GNUNET_DHT_RouteOption options, | 80 | enum GNUNET_DHT_RouteOption options, |
81 | const struct GNUNET_HashCode * key, const void *xquery, | 81 | const struct GNUNET_HashCode * key, |
82 | size_t xquery_size, | 82 | const void *xquery, |
83 | const struct GNUNET_CONTAINER_BloomFilter *reply_bf, | 83 | size_t xquery_size); |
84 | uint32_t reply_bf_mutator); | ||
85 | 84 | ||
86 | 85 | ||
87 | /** | 86 | /** |
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c index 4c5f122a4..0304dad87 100644 --- a/src/dht/plugin_block_dht.c +++ b/src/dht/plugin_block_dht.c | |||
@@ -47,6 +47,7 @@ | |||
47 | * @param nonce random value used to seed the group creation | 47 | * @param nonce random value used to seed the group creation |
48 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh | 48 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh |
49 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh | 49 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh |
50 | * @param va variable arguments specific to @a type | ||
50 | * @return block group handle, NULL if block groups are not supported | 51 | * @return block group handle, NULL if block groups are not supported |
51 | * by this @a type of block (this is not an error) | 52 | * by this @a type of block (this is not an error) |
52 | */ | 53 | */ |
@@ -55,7 +56,8 @@ block_plugin_dht_create_group (void *cls, | |||
55 | enum GNUNET_BLOCK_Type type, | 56 | enum GNUNET_BLOCK_Type type, |
56 | uint32_t nonce, | 57 | uint32_t nonce, |
57 | const void *raw_data, | 58 | const void *raw_data, |
58 | size_t raw_data_size) | 59 | size_t raw_data_size, |
60 | va_list va) | ||
59 | { | 61 | { |
60 | return GNUNET_BLOCK_GROUP_bf_create (cls, | 62 | return GNUNET_BLOCK_GROUP_bf_create (cls, |
61 | DHT_BF_SIZE, | 63 | DHT_BF_SIZE, |
@@ -73,10 +75,9 @@ block_plugin_dht_create_group (void *cls, | |||
73 | * | 75 | * |
74 | * @param cls closure | 76 | * @param cls closure |
75 | * @param type block type | 77 | * @param type block type |
78 | * @param group block group to check against | ||
76 | * @param eo control flags | 79 | * @param eo control flags |
77 | * @param query original query (hash) | 80 | * @param query original query (hash) |
78 | * @param bf pointer to bloom filter associated with query; possibly updated (!) | ||
79 | * @param bf_mutator mutation value for @a bf | ||
80 | * @param xquery extended query data (can be NULL, depending on type) | 81 | * @param xquery extended query data (can be NULL, depending on type) |
81 | * @param xquery_size number of bytes in @a xquery | 82 | * @param xquery_size number of bytes in @a xquery |
82 | * @param reply_block response to validate | 83 | * @param reply_block response to validate |
@@ -86,16 +87,14 @@ block_plugin_dht_create_group (void *cls, | |||
86 | static enum GNUNET_BLOCK_EvaluationResult | 87 | static enum GNUNET_BLOCK_EvaluationResult |
87 | block_plugin_dht_evaluate (void *cls, | 88 | block_plugin_dht_evaluate (void *cls, |
88 | enum GNUNET_BLOCK_Type type, | 89 | enum GNUNET_BLOCK_Type type, |
90 | struct GNUNET_BLOCK_Group *group, | ||
89 | enum GNUNET_BLOCK_EvaluationOptions eo, | 91 | enum GNUNET_BLOCK_EvaluationOptions eo, |
90 | const struct GNUNET_HashCode *query, | 92 | const struct GNUNET_HashCode *query, |
91 | struct GNUNET_CONTAINER_BloomFilter **bf, | ||
92 | int32_t bf_mutator, | ||
93 | const void *xquery, | 93 | const void *xquery, |
94 | size_t xquery_size, | 94 | size_t xquery_size, |
95 | const void *reply_block, | 95 | const void *reply_block, |
96 | size_t reply_block_size) | 96 | size_t reply_block_size) |
97 | { | 97 | { |
98 | struct GNUNET_HashCode mhash; | ||
99 | const struct GNUNET_HELLO_Message *hello; | 98 | const struct GNUNET_HELLO_Message *hello; |
100 | struct GNUNET_PeerIdentity pid; | 99 | struct GNUNET_PeerIdentity pid; |
101 | const struct GNUNET_MessageHeader *msg; | 100 | const struct GNUNET_MessageHeader *msg; |
@@ -127,22 +126,13 @@ block_plugin_dht_evaluate (void *cls, | |||
127 | GNUNET_break_op (0); | 126 | GNUNET_break_op (0); |
128 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 127 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
129 | } | 128 | } |
130 | if (NULL != bf) | 129 | GNUNET_CRYPTO_hash (&pid, |
131 | { | 130 | sizeof (pid), |
132 | GNUNET_CRYPTO_hash (&pid, sizeof (pid), &phash); | 131 | &phash); |
133 | GNUNET_BLOCK_mingle_hash (&phash, bf_mutator, &mhash); | 132 | if (GNUNET_YES == |
134 | if (NULL != *bf) | 133 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, |
135 | { | 134 | &phash)) |
136 | if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash)) | 135 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; |
137 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, | ||
142 | GNUNET_CONSTANTS_BLOOMFILTER_K); | ||
143 | } | ||
144 | GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash); | ||
145 | } | ||
146 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | 136 | return GNUNET_BLOCK_EVALUATION_OK_MORE; |
147 | } | 137 | } |
148 | 138 | ||