*/
#include "platform.h"
+#include "gnunet_constants.h"
#include "gnunet_protocols.h"
#include "gnunet_statistics_service.h"
#include "gnunet-service-dht.h"
{
int32_t reply_bf_mutator;
struct GNUNET_CONTAINER_BloomFilter *reply_bf;
+ struct GNUNET_CONTAINER_BloomFilter *peer_bf;
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# GET requests from clients injected"), 1,
reply_bf = GNUNET_BLOCK_construct_bloomfilter (reply_bf_mutator,
cqr->seen_replies,
cqr->seen_replies_count);
+ peer_bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
+ DHT_BLOOM_SIZE,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
GDS_NEIGHBOURS_handle_get (cqr->type,
cqr->msg_options,
cqr->replication,
cqr->xquery_size,
reply_bf,
reply_bf_mutator,
- NULL /* no peers blocked initially */);
+ peer_bf);
GNUNET_CONTAINER_bloomfilter_free (reply_bf);
+ GNUNET_CONTAINER_bloomfilter_free (peer_bf);
/* exponential back-off for retries, max 1h */
cqr->retry_frequency =
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_DHT_ClientPutMessage *dht_msg;
+ struct GNUNET_CONTAINER_BloomFilter *peer_bf;
uint16_t size;
size = ntohs (message->size);
size - sizeof (struct GNUNET_DHT_ClientPutMessage),
&dht_msg[1]);
/* route to other peers */
+ peer_bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
+ DHT_BLOOM_SIZE,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
GDS_NEIGHBOURS_handle_put (ntohl (dht_msg->type),
ntohl (dht_msg->options),
ntohl (dht_msg->desired_replication_level),
GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
0 /* hop count */,
- NULL /* peer bloom filter */,
+ peer_bf,
&dht_msg->key,
0, NULL,
&dht_msg[1],
size - sizeof (struct GNUNET_DHT_ClientPutMessage));
+ GNUNET_CONTAINER_bloomfilter_free (peer_bf);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
if ( (record->type != GNUNET_BLOCK_TYPE_ANY) &&
(record->type != frc->type) )
- return GNUNET_YES; /* type mismatch */
+ {
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Key match, type mismatches in REPLY to CLIENT"), 1,
+ GNUNET_NO);
+ return GNUNET_YES; /* type mismatch */
+ }
GNUNET_CRYPTO_hash (frc->data,
frc->data_size,
&ch);
if (0 == memcmp (&record->seen_replies[i],
&ch,
sizeof (GNUNET_HashCode)))
- return GNUNET_YES; /* duplicate */
+ {
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Duplicate REPLIES to CLIENT request dropped"), 1,
+ GNUNET_NO);
+ return GNUNET_YES; /* duplicate */
+ }
eval =
GNUNET_BLOCK_evaluate (GDS_block_context,
record->type, key,
return GNUNET_NO;
case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unsupported block type (%u) in request!\n",
+ _("Unsupported block type (%u) in request!\n"),
record->type);
return GNUNET_NO;
}
if (NULL ==
GNUNET_CONTAINER_multihashmap_get (forward_map, key))
+ {
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# REPLIES ignored for CLIENTS (no match)"), 1,
+ GNUNET_NO);
return; /* no matching request, fast exit! */
+ }
msize = sizeof(struct GNUNET_DHT_ClientResultMessage) + data_size +
(get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity);
if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
#include "gnunet-service-dht_nse.h"
#include "gnunet-service-dht_routing.h"
#include <fenv.h>
+#include "dht.h"
/**
* How many buckets will we allow total.
*/
#define DEFAULT_BUCKET_SIZE 4
-/**
- * Size of the bloom filter the DHT uses to filter peers.
- */
-#define DHT_BLOOM_SIZE 128
-
/**
* Desired replication level for FIND PEER requests
*/
{
struct GNUNET_TIME_Relative next_send_time;
struct BloomConstructorContext bcc;
+ struct GNUNET_CONTAINER_BloomFilter *peer_bf;
find_peer_task = GNUNET_SCHEDULER_NO_TASK;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# FIND PEER messages initiated"), 1,
GNUNET_NO);
+ peer_bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
+ DHT_BLOOM_SIZE,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
// FIXME: pass priority!?
GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_HELLO,
GNUNET_DHT_RO_FIND_PEER,
0,
&my_identity.hashPubKey,
NULL, 0,
- bcc.bloom, bcc.bf_mutator, NULL);
+ bcc.bloom, bcc.bf_mutator,
+ peer_bf);
+ GNUNET_CONTAINER_bloomfilter_free (peer_bf);
GNUNET_CONTAINER_bloomfilter_free (bcc.bloom);
/* schedule next round */
newly_found_peers = 0;
GNUNET_free (pending);
}
if (peer->head != NULL)
- peer->th
- = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
- pending->importance,
- GNUNET_TIME_absolute_get_remaining (pending->timeout),
- &peer->id, msize,
- &core_transmit_notify, peer);
+ {
+ peer->th
+ = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
+ pending->importance,
+ GNUNET_TIME_absolute_get_remaining (pending->timeout),
+ &peer->id, msize,
+ &core_transmit_notify, peer);
+ }
return off;
}
struct PeerInfo **rtargets;
struct PeerInfo *nxt;
+ GNUNET_assert (NULL != bloom);
ret = get_forward_count (hop_count, target_replication);
if (ret == 0)
{
if (nxt == NULL)
break;
rtargets[off++] = nxt;
+ GNUNET_break (GNUNET_NO ==
+ GNUNET_CONTAINER_bloomfilter_test (bloom, &nxt->id.hashPubKey));
GNUNET_CONTAINER_bloomfilter_add (bloom, &nxt->id.hashPubKey);
}
if (0 == off)
struct PeerPutMessage *ppm;
struct GNUNET_PeerIdentity *pp;
+ GNUNET_assert (NULL != bf);
+ GNUNET_CONTAINER_bloomfilter_add (bf, &my_identity.hashPubKey);
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# PUT requests routed"), 1,
GNUNET_NO);
ppm->desired_replication_level = htonl (desired_replication_level);
ppm->put_path_length = htonl (put_path_length);
ppm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time);
- if (NULL != bf)
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_bloomfilter_get_raw_data (bf,
- ppm->bloomfilter,
- DHT_BLOOM_SIZE));
+ GNUNET_break (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bf, &target->id.hashPubKey));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_bloomfilter_get_raw_data (bf,
+ ppm->bloomfilter,
+ DHT_BLOOM_SIZE));
ppm->key = *key;
pp = (struct GNUNET_PeerIdentity*) &ppm[1];
memcpy (pp, put_path, sizeof (struct GNUNET_PeerIdentity) * put_path_length);
struct PeerGetMessage *pgm;
char *xq;
size_t reply_bf_size;
-
+
+ GNUNET_assert (NULL != peer_bf);
+ GNUNET_CONTAINER_bloomfilter_add (peer_bf, &my_identity.hashPubKey);
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# GET requests routed"), 1,
GNUNET_NO);
pgm->desired_replication_level = htonl (desired_replication_level);
pgm->xquery_size = htonl (xquery_size);
pgm->bf_mutator = reply_bf_mutator;
- if (NULL != peer_bf)
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_bloomfilter_get_raw_data (peer_bf,
- pgm->bloomfilter,
- DHT_BLOOM_SIZE));
+ GNUNET_break (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (peer_bf, &target->id.hashPubKey));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_bloomfilter_get_raw_data (peer_bf,
+ pgm->bloomfilter,
+ DHT_BLOOM_SIZE));
pgm->key = *key;
xq = (char *) &pgm[1];
memcpy (xq, xquery, xquery_size);
bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter,
DHT_BLOOM_SIZE,
GNUNET_CONSTANTS_BLOOMFILTER_K);
+ GNUNET_break_op (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bf, &peer->hashPubKey));
{
struct GNUNET_PeerIdentity pp[putlen+1];
struct GNUNET_CONTAINER_BloomFilter *reply_bf;
struct GNUNET_CONTAINER_BloomFilter *peer_bf;
const char *xquery;
-
+
+ GNUNET_break (0 != memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity)));
/* parse and validate message */
msize = ntohs (message->size);
if (msize < sizeof (struct PeerGetMessage))
GNUNET_CONTAINER_bloomfilter_init (get->bloomfilter,
DHT_BLOOM_SIZE,
GNUNET_CONSTANTS_BLOOMFILTER_K);
-
+ GNUNET_break_op (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (peer_bf, &peer->hashPubKey));
/* remember request for routing replies */
GDS_ROUTING_add (peer,
type,