aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-03-12 08:15:28 +0100
committerChristian Grothoff <grothoff@gnunet.org>2022-03-12 08:15:28 +0100
commitaca54f89d9d95caf1b3535185208b83274d937a7 (patch)
tree102a406571368c8852f741da9b9c2d2105ddf4db /src/dht
parent3ecdd45a715c745fa3fd73bb67b808425e907b75 (diff)
downloadgnunet-aca54f89d9d95caf1b3535185208b83274d937a7.tar.gz
gnunet-aca54f89d9d95caf1b3535185208b83274d937a7.zip
consider HELLOs also from PUTs, remove exact duplicates even if block type is unknown
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/Makefile.am1
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c43
-rw-r--r--src/dht/gnunet-service-dht_routing.c18
3 files changed, 48 insertions, 14 deletions
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am
index 1f1451e83..68a17723d 100644
--- a/src/dht/Makefile.am
+++ b/src/dht/Makefile.am
@@ -71,6 +71,7 @@ gnunet_service_dht_LDADD = \
71 $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ 71 $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
72 $(top_builddir)/src/hello/libgnunethello.la \ 72 $(top_builddir)/src/hello/libgnunethello.la \
73 $(top_builddir)/src/block/libgnunetblock.la \ 73 $(top_builddir)/src/block/libgnunetblock.la \
74 $(top_builddir)/src/block/libgnunetblockgroup.la \
74 $(top_builddir)/src/datacache/libgnunetdatacache.la \ 75 $(top_builddir)/src/datacache/libgnunetdatacache.la \
75 $(top_builddir)/src/util/libgnunetutil.la \ 76 $(top_builddir)/src/util/libgnunetutil.la \
76 -lm 77 -lm
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 9d27d6a88..d9495ce14 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -1284,6 +1284,31 @@ get_target_peers (const struct GNUNET_HashCode *key,
1284} 1284}
1285 1285
1286 1286
1287/**
1288 * If we got a HELLO, consider it for our own routing table
1289 *
1290 * @param bd block data we got
1291 */
1292static void
1293hello_check (const struct GDS_DATACACHE_BlockData *bd)
1294{
1295 struct GNUNET_PeerIdentity pid;
1296 struct GNUNET_HELLO_Builder *b;
1297
1298 if (GNUNET_BLOCK_TYPE_DHT_URL_HELLO != bd->type)
1299 return;
1300
1301 b = GNUNET_HELLO_builder_from_block (bd->data,
1302 bd->data_size);
1303 if (GNUNET_YES != disable_try_connect)
1304 GNUNET_HELLO_builder_iterate (b,
1305 &pid,
1306 &GDS_try_connect,
1307 &pid);
1308 GNUNET_HELLO_builder_free (b);
1309}
1310
1311
1287enum GNUNET_GenericReturnValue 1312enum GNUNET_GenericReturnValue
1288GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd, 1313GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd,
1289 enum GNUNET_DHT_RouteOption options, 1314 enum GNUNET_DHT_RouteOption options,
@@ -1318,6 +1343,9 @@ GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd,
1318 GNUNET_h2s (&bd->key), 1343 GNUNET_h2s (&bd->key),
1319 (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-", 1344 (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-",
1320 (options & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-"); 1345 (options & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-");
1346
1347 /* if we got a HELLO, consider it for our own routing table */
1348 hello_check (bd);
1321 GNUNET_CONTAINER_bloomfilter_add (bf, 1349 GNUNET_CONTAINER_bloomfilter_add (bf,
1322 &GDS_my_identity_hash); 1350 &GDS_my_identity_hash);
1323 GNUNET_STATISTICS_update (GDS_stats, 1351 GNUNET_STATISTICS_update (GDS_stats,
@@ -2470,20 +2498,7 @@ handle_dht_p2p_result (void *cls,
2470 } 2498 }
2471 2499
2472 /* if we got a HELLO, consider it for our own routing table */ 2500 /* if we got a HELLO, consider it for our own routing table */
2473 if (GNUNET_BLOCK_TYPE_DHT_URL_HELLO == bd.type) 2501 hello_check (&bd);
2474 {
2475 struct GNUNET_PeerIdentity pid;
2476 struct GNUNET_HELLO_Builder *b;
2477
2478 b = GNUNET_HELLO_builder_from_block (bd.data,
2479 bd.data_size);
2480 if (GNUNET_YES != disable_try_connect)
2481 GNUNET_HELLO_builder_iterate (b,
2482 &pid,
2483 &GDS_try_connect,
2484 &pid);
2485 GNUNET_HELLO_builder_free (b);
2486 }
2487 2502
2488 /* First, check if 'peer' is already on the path, and if 2503 /* First, check if 'peer' is already on the path, and if
2489 so, truncate it instead of expanding. */ 2504 so, truncate it instead of expanding. */
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c
index 05902b941..6deb5fa16 100644
--- a/src/dht/gnunet-service-dht_routing.c
+++ b/src/dht/gnunet-service-dht_routing.c
@@ -27,6 +27,7 @@
27#include "gnunet-service-dht_neighbours.h" 27#include "gnunet-service-dht_neighbours.h"
28#include "gnunet-service-dht_routing.h" 28#include "gnunet-service-dht_routing.h"
29#include "gnunet-service-dht.h" 29#include "gnunet-service-dht.h"
30#include "gnunet_block_group_lib.h"
30 31
31 32
32/** 33/**
@@ -174,6 +175,22 @@ process (void *cls,
174 GNUNET_h2s (&bdx.key), 175 GNUNET_h2s (&bdx.key),
175 bdx.type, 176 bdx.type,
176 eval); 177 eval);
178 if (GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED == eval)
179 {
180 /* If we do not know the block type, we still filter
181 exact duplicates by the block content */
182 struct GNUNET_HashCode chash;
183
184 GNUNET_CRYPTO_hash (bdx.data,
185 bdx.data_size,
186 &chash);
187 if (GNUNET_YES ==
188 GNUNET_BLOCK_GROUP_bf_test_and_set (rr->bg,
189 &chash))
190 eval = GNUNET_BLOCK_REPLY_OK_DUPLICATE;
191 else
192 eval = GNUNET_BLOCK_REPLY_OK_MORE;
193 }
177 switch (eval) 194 switch (eval)
178 { 195 {
179 case GNUNET_BLOCK_REPLY_OK_MORE: 196 case GNUNET_BLOCK_REPLY_OK_MORE:
@@ -319,6 +336,7 @@ try_combine_recent (void *cls,
319 * 336 *
320 * @param sender peer that originated the request 337 * @param sender peer that originated the request
321 * @param type type of the block 338 * @param type type of the block
339 * @param[in] bg block group for filtering duplicate replies
322 * @param options options for processing 340 * @param options options for processing
323 * @param key key for the content 341 * @param key key for the content
324 * @param xquery extended query 342 * @param xquery extended query