gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r17090 - gnunet/src/dht


From: gnunet
Subject: [GNUnet-SVN] r17090 - gnunet/src/dht
Date: Wed, 28 Sep 2011 11:56:18 +0200

Author: grothoff
Date: 2011-09-28 11:56:18 +0200 (Wed, 28 Sep 2011)
New Revision: 17090

Modified:
   gnunet/src/dht/dht.h
   gnunet/src/dht/gnunet-service-dht_clients.c
   gnunet/src/dht/gnunet-service-dht_neighbours.c
   gnunet/src/dht/test_dht_twopeer.c
Log:
fixes

Modified: gnunet/src/dht/dht.h
===================================================================
--- gnunet/src/dht/dht.h        2011-09-28 09:22:26 UTC (rev 17089)
+++ gnunet/src/dht/dht.h        2011-09-28 09:56:18 UTC (rev 17090)
@@ -24,11 +24,17 @@
  * @file dht/dht.h
  */
 
-#ifndef DHT_H_
-#define DHT_H_
+#ifndef DHT_H
+#define DHT_H
 
 
 /**
+ * Size of the bloom filter the DHT uses to filter peers.
+ */
+#define DHT_BLOOM_SIZE 128
+
+
+/**
  * Message which indicates the DHT should cancel outstanding
  * requests and discard any state.
  */

Modified: gnunet/src/dht/gnunet-service-dht_clients.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_clients.c 2011-09-28 09:22:26 UTC (rev 
17089)
+++ gnunet/src/dht/gnunet-service-dht_clients.c 2011-09-28 09:56:18 UTC (rev 
17090)
@@ -26,6 +26,7 @@
  */
 
 #include "platform.h"
+#include "gnunet_constants.h"
 #include "gnunet_protocols.h"
 #include "gnunet_statistics_service.h"
 #include "gnunet-service-dht.h"
@@ -303,6 +304,7 @@
 {
   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,
@@ -312,6 +314,9 @@
   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,
@@ -321,8 +326,9 @@
                             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 = 
@@ -380,6 +386,7 @@
                      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);
@@ -409,16 +416,20 @@
                            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);
 }
 
@@ -698,7 +709,12 @@
   
   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);
@@ -706,7 +722,12 @@
     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, 
@@ -741,7 +762,7 @@
     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;
   }
@@ -806,7 +827,12 @@
 
   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)

Modified: gnunet/src/dht/gnunet-service-dht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_neighbours.c      2011-09-28 09:22:26 UTC 
(rev 17089)
+++ gnunet/src/dht/gnunet-service-dht_neighbours.c      2011-09-28 09:56:18 UTC 
(rev 17090)
@@ -46,6 +46,7 @@
 #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.
@@ -58,11 +59,6 @@
 #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
  */
 #define FIND_PEER_REPLICATION_LEVEL 4
@@ -578,6 +574,7 @@
 {
   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)
@@ -599,6 +596,9 @@
   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,
@@ -606,7 +606,9 @@
                             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;
@@ -780,12 +782,14 @@
     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;
 }
 
@@ -1116,6 +1120,7 @@
   struct PeerInfo **rtargets;
   struct PeerInfo *nxt;
 
+  GNUNET_assert (NULL != bloom);
   ret = get_forward_count (hop_count, target_replication);
   if (ret == 0)
   {
@@ -1130,6 +1135,8 @@
     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)
@@ -1184,6 +1191,8 @@
   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);
@@ -1222,11 +1231,11 @@
     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);
@@ -1279,7 +1288,9 @@
   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);
@@ -1315,11 +1326,11 @@
     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);
@@ -1508,6 +1519,7 @@
   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];
   
@@ -1678,7 +1690,8 @@
   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))
@@ -1724,7 +1737,7 @@
     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,

Modified: gnunet/src/dht/test_dht_twopeer.c
===================================================================
--- gnunet/src/dht/test_dht_twopeer.c   2011-09-28 09:22:26 UTC (rev 17089)
+++ gnunet/src/dht/test_dht_twopeer.c   2011-09-28 09:56:18 UTC (rev 17090)
@@ -287,14 +287,13 @@
       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
                                     (GNUNET_TIME_UNIT_SECONDS, 10),
                                     &stop_retry_get, get_context);
-
   get_context->get_handle =
       GNUNET_DHT_get_start (get_context->dht_handle,
                             GNUNET_TIME_relative_multiply
                             (GNUNET_TIME_UNIT_SECONDS, 5),
                             GNUNET_BLOCK_TYPE_DHT_HELLO,
                             &get_context->peer->hashPubKey,
-                            1, GNUNET_DHT_RO_NONE, NULL,
+                            1, GNUNET_DHT_RO_FIND_PEER, NULL,
                             0, &get_result_iterator, get_context);
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]