gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 19/20: -fix htons/htonl bug introduced by message format change


From: gnunet
Subject: [gnunet] 19/20: -fix htons/htonl bug introduced by message format change
Date: Sat, 19 Feb 2022 16:20:59 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit 95ffa9b9ac9711539aac3feb15eefcfebfc14825
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Feb 19 16:06:34 2022 +0100

    -fix htons/htonl bug introduced by message format change
---
 src/datacache/plugin_datacache_heap.c   |  46 +++++++++-----
 src/dht/gnunet-dht-get.c                |  24 +++++--
 src/dht/gnunet-service-dht_neighbours.c | 107 +++++++++++++++++---------------
 src/dht/gnunet-service-dht_neighbours.h |   8 +--
 src/dhtu/plugin_dhtu_ip.c               |  60 ++++++++++++++++--
 5 files changed, 168 insertions(+), 77 deletions(-)

diff --git a/src/datacache/plugin_datacache_heap.c 
b/src/datacache/plugin_datacache_heap.c
index 2756315fb..09e66d892 100644
--- a/src/datacache/plugin_datacache_heap.c
+++ b/src/datacache/plugin_datacache_heap.c
@@ -158,7 +158,7 @@ struct PutContext
  * @param value an existing value
  * @return #GNUNET_YES if not found (to continue to iterate)
  */
-static int
+static enum GNUNET_GenericReturnValue
 put_cb (void *cls,
         const struct GNUNET_HashCode *key,
         void *value)
@@ -224,15 +224,20 @@ heap_plugin_put (void *cls,
 {
   struct Plugin *plugin = cls;
   struct Value *val;
-  struct PutContext put_ctx;
-
-  put_ctx.found = GNUNET_NO;
-  put_ctx.data = data;
-  put_ctx.size = size;
-  put_ctx.path_info = path_info;
-  put_ctx.path_info_len = path_info_len;
-  put_ctx.discard_time = discard_time;
-  put_ctx.type = type;
+  struct PutContext put_ctx = {
+    .data = data,
+    .size = size,
+    .path_info = path_info,
+    .path_info_len = path_info_len,
+    .discard_time = discard_time,
+    .type = type
+  };
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Storing %u bytes under key %s with path length %u\n",
+              (unsigned int) size,
+              GNUNET_h2s (key),
+              path_info_len);
   GNUNET_CONTAINER_multihashmap_get_multiple (plugin->map,
                                               key,
                                               &put_cb,
@@ -313,12 +318,25 @@ get_cb (void *cls,
   struct Value *val = value;
   int ret;
 
-  if ((get_ctx->type != val->type) &&
-      (GNUNET_BLOCK_TYPE_ANY != get_ctx->type))
+  if ( (get_ctx->type != val->type) &&
+       (GNUNET_BLOCK_TYPE_ANY != get_ctx->type) )
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Result for key %s does not match block type %d\n",
+                GNUNET_h2s (key),
+                get_ctx->type);
     return GNUNET_OK;
-  if (0 ==
-      GNUNET_TIME_absolute_get_remaining (val->discard_time).rel_value_us)
+  }
+  if (GNUNET_TIME_absolute_is_past (val->discard_time))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Result for key %s is expired\n",
+                GNUNET_h2s (key));
     return GNUNET_OK;
+  }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Found result for key %s\n",
+              GNUNET_h2s (key));
   if (NULL != get_ctx->iter)
     ret = get_ctx->iter (get_ctx->iter_cls,
                          key,
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c
index f1076490b..42ffe75ba 100644
--- a/src/dht/gnunet-dht-get.c
+++ b/src/dht/gnunet-dht-get.c
@@ -57,6 +57,11 @@ static unsigned int verbose;
  */
 static int demultixplex_everywhere;
 
+/**
+ * Use #GNUNET_DHT_RO_RECORD_ROUTE.
+ */
+static int record_route;
+
 /**
  * Handle to the DHT
  */
@@ -160,9 +165,9 @@ get_result_iterator (void *cls,
            : _ ("Result %d, type %d:\n"),
            result_count,
            type,
-           (unsigned int) size,
+           (int) size,
            (char *) data);
-  if (verbose)
+  if (record_route && verbose)
   {
     fprintf (stdout,
              "  GET path: ");
@@ -200,6 +205,7 @@ run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   struct GNUNET_HashCode key;
+  enum GNUNET_DHT_RouteOption ro;
 
   cfg = c;
   if (NULL == query_key)
@@ -228,13 +234,16 @@ run (void *cls,
              GNUNET_h2s_full (&key));
   GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
   tt = GNUNET_SCHEDULER_add_delayed (timeout_request, &timeout_task, NULL);
+  ro = GNUNET_DHT_RO_NONE;
+  if (demultixplex_everywhere)
+    ro |= GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE;
+  if (record_route)
+    ro |= GNUNET_DHT_RO_RECORD_ROUTE;
   get_handle = GNUNET_DHT_get_start (dht_handle,
                                      query_type,
                                      &key,
                                      replication,
-                                     (demultixplex_everywhere)
-                                     ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
-                                     : GNUNET_DHT_RO_NONE,
+                                     ro,
                                      NULL,
                                      0,
                                      &get_result_iterator,
@@ -265,6 +274,11 @@ main (int argc, char *const *argv)
       "LEVEL",
       gettext_noop ("how many parallel requests (replicas) to create"),
       &replication),
+    GNUNET_GETOPT_option_flag (
+      'R',
+      "record",
+      gettext_noop ("use DHT's record route option"),
+      &record_route),
     GNUNET_GETOPT_option_uint (
       't',
       "type",
diff --git a/src/dht/gnunet-service-dht_neighbours.c 
b/src/dht/gnunet-service-dht_neighbours.c
index 68d431d17..fb965b569 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -71,6 +71,7 @@
 #define DHT_MINIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply ( \
     GNUNET_TIME_UNIT_MINUTES, 2)
 
+
 /**
  * How long to additionally wait on average per #bucket_size to send out the
  * FIND PEER requests if we did successfully connect (!) to a a new peer and
@@ -80,7 +81,7 @@
  * top).  Also the range in which we randomize, so the effective value
  * is half of the number given here.
  */
-#define DHT_AVG_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply ( \
+#define DHT_AVG_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply (    \
     GNUNET_TIME_UNIT_SECONDS, 6)
 
 /**
@@ -629,7 +630,7 @@ send_find_peer_message (void *cls)
         GNUNET_CRYPTO_QUALITY_WEAK,
         GNUNET_TIME_relative_multiply (
           DHT_AVG_FIND_PEER_INTERVAL,
-          100 * (1 + newly_found_peers) / bucket_size).rel_value_us);
+          1 + 100 * (1 + newly_found_peers) / bucket_size).rel_value_us);
     newly_found_peers = 0;
     GNUNET_assert (NULL == find_peer_task);
     find_peer_task =
@@ -712,7 +713,7 @@ update_hold (struct PeerBucket *bucket)
   {
     if (off > bucket_size)
       break;   /* We only hold up to #bucket_size peers per bucket */
-    bucket_size++;
+    off++;
     for (struct Target *tp = pos->t_head;
          NULL != tp;
          tp = tp->next)
@@ -878,8 +879,8 @@ GDS_u_disconnect (void *ctx)
  * @return Some number of peers to forward the message to
  */
 static unsigned int
-get_forward_count (uint32_t hop_count,
-                   uint32_t target_replication)
+get_forward_count (uint16_t hop_count,
+                   uint16_t target_replication)
 {
   uint32_t random_value;
   uint32_t forward_count;
@@ -1225,8 +1226,8 @@ select_peer (const struct GNUNET_HashCode *key,
 static unsigned int
 get_target_peers (const struct GNUNET_HashCode *key,
                   struct GNUNET_CONTAINER_BloomFilter *bloom,
-                  uint32_t hop_count,
-                  uint32_t target_replication,
+                  uint16_t hop_count,
+                  uint16_t target_replication,
                   struct PeerInfo ***targets)
 {
   unsigned int target;
@@ -1285,8 +1286,8 @@ get_target_peers (const struct GNUNET_HashCode *key,
 enum GNUNET_GenericReturnValue
 GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd,
                            enum GNUNET_DHT_RouteOption options,
-                           uint32_t desired_replication_level,
-                           uint32_t hop_count,
+                           uint16_t desired_replication_level,
+                           uint16_t hop_count,
                            struct GNUNET_CONTAINER_BloomFilter *bf)
 {
   unsigned int target_count;
@@ -1312,9 +1313,11 @@ GDS_NEIGHBOURS_handle_put (const struct 
GDS_DATACACHE_BlockData *bd,
   }
 #endif
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Adding myself (%s) to PUT bloomfilter for %s\n",
+              "Adding myself (%s) to PUT bloomfilter for %s with RO(%s/%s)\n",
               GNUNET_i2s (&GDS_my_identity),
-              GNUNET_h2s (&bd->key));
+              GNUNET_h2s (&bd->key),
+              (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-",
+              (options & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-");
   GNUNET_CONTAINER_bloomfilter_add (bf,
                                     &GDS_my_identity_hash);
   GNUNET_STATISTICS_update (GDS_stats,
@@ -1367,11 +1370,11 @@ GDS_NEIGHBOURS_handle_put (const struct 
GDS_DATACACHE_BlockData *bd,
     ppm = (struct PeerPutMessage *) buf;
     ppm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_PUT);
     ppm->header.size = htons (sizeof (buf));
-    ppm->options = htonl (options);
     ppm->type = htonl (bd->type);
-    ppm->hop_count = htonl (hop_count + 1);
-    ppm->desired_replication_level = htonl (desired_replication_level);
-    ppm->put_path_length = htonl (put_path_length);
+    ppm->options = htons (options);
+    ppm->hop_count = htons (hop_count + 1);
+    ppm->desired_replication_level = htons (desired_replication_level);
+    ppm->put_path_length = htons (put_path_length);
     ppm->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time);
     GNUNET_break (GNUNET_YES ==
                   GNUNET_CONTAINER_bloomfilter_test (bf,
@@ -1417,8 +1420,8 @@ GDS_NEIGHBOURS_handle_put (const struct 
GDS_DATACACHE_BlockData *bd,
 enum GNUNET_GenericReturnValue
 GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
                            enum GNUNET_DHT_RouteOption options,
-                           uint32_t desired_replication_level,
-                           uint32_t hop_count,
+                           uint16_t desired_replication_level,
+                           uint16_t hop_count,
                            const struct GNUNET_HashCode *key,
                            const void *xquery,
                            size_t xquery_size,
@@ -1444,9 +1447,12 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
                                    desired_replication_level,
                                    &targets);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Adding myself (%s) to GET bloomfilter for %s\n",
+              "Adding myself (%s) to GET bloomfilter for %s with RO(%s/%s)\n",
               GNUNET_i2s (&GDS_my_identity),
-              GNUNET_h2s (key));
+              GNUNET_h2s (key),
+              (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-",
+              (options & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-");
+
   GNUNET_CONTAINER_bloomfilter_add (peer_bf,
                                     &GDS_my_identity_hash);
   if (0 == target_count)
@@ -1494,10 +1500,10 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
     pgm = (struct PeerGetMessage *) buf;
     pgm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_GET);
     pgm->header.size = htons (sizeof (buf));
-    pgm->options = htonl (options);
     pgm->type = htonl (type);
-    pgm->hop_count = htonl (hop_count + 1);
-    pgm->desired_replication_level = htonl (desired_replication_level);
+    pgm->options = htons (options);
+    pgm->hop_count = htons (hop_count + 1);
+    pgm->desired_replication_level = htons (desired_replication_level);
     pgm->xquery_size = htonl (xquery_size);
     pgm->bf_mutator = bf_nonce;
     GNUNET_break (GNUNET_YES ==
@@ -1605,8 +1611,8 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi,
     prm->header.size = htons (sizeof (buf));
     prm->type = htonl (bd->type);
     prm->reserved = htonl (0);
-    prm->put_path_length = htonl (ppl);
-    prm->get_path_length = htonl (get_path_length);
+    prm->put_path_length = htons (ppl);
+    prm->get_path_length = htons (get_path_length);
     prm->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time);
     prm->key = *query_hash;
     paths = (struct GNUNET_DHT_PathElement *) &prm[1];
@@ -1664,7 +1670,7 @@ check_dht_p2p_put (void *cls,
                    const struct PeerPutMessage *put)
 {
   uint16_t msize = ntohs (put->header.size);
-  uint32_t putlen = ntohl (put->put_path_length);
+  uint16_t putlen = ntohs (put->put_path_length);
 
   (void) cls;
   if ( (msize <
@@ -1694,7 +1700,7 @@ handle_dht_p2p_put (void *cls,
   struct PeerInfo *peer = t->pi;
   uint16_t msize = ntohs (put->header.size);
   enum GNUNET_DHT_RouteOption options
-    = (enum GNUNET_DHT_RouteOption) ntohl (put->options);
+    = (enum GNUNET_DHT_RouteOption) ntohs (put->options);
   struct GDS_DATACACHE_BlockData bd = {
     .key = put->key,
     .expiration_time = GNUNET_TIME_absolute_ntoh (put->expiration_time),
@@ -1702,16 +1708,18 @@ handle_dht_p2p_put (void *cls,
   };
   const struct GNUNET_DHT_PathElement *put_path
     = (const struct GNUNET_DHT_PathElement *) &put[1];
-  uint32_t putlen
-    = ntohl (put->put_path_length);
+  uint16_t putlen
+    = ntohs (put->put_path_length);
 
   bd.data_size = msize - (sizeof(*put)
                           + putlen * sizeof(struct GNUNET_DHT_PathElement));
   bd.data = &put_path[putlen];
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "PUT for `%s' from %s\n",
+              "PUT for `%s' from %s with RO (%s/%s)\n",
               GNUNET_h2s (&put->key),
-              GNUNET_i2s (&peer->id));
+              GNUNET_i2s (&peer->id),
+              (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-",
+              (options & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-");
   if (GNUNET_TIME_absolute_is_past (bd.expiration_time))
   {
     GNUNET_STATISTICS_update (GDS_stats,
@@ -1782,6 +1790,14 @@ handle_dht_p2p_put (void *cls,
     bd.put_path_length = putlen + 1;
     if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE))
     {
+      GNUNET_memcpy (pp,
+                     put_path,
+                     putlen * sizeof(struct GNUNET_DHT_PathElement));
+      pp[putlen].pred = peer->id;
+      /* zero-out signature, not valid until we actually do forward! */
+      memset (&pp[putlen].sig,
+              0,
+              sizeof (pp[putlen].sig));
 #if SANITY_CHECKS
       for (unsigned int i = 0; i <= putlen; i++)
       {
@@ -1809,15 +1825,6 @@ handle_dht_p2p_put (void *cls,
         putlen = 0;
       }
 #endif
-      GNUNET_memcpy (pp,
-                     put_path,
-                     putlen * sizeof(struct GNUNET_DHT_PathElement));
-      pp[putlen].pred = peer->id;
-      /* zero-out signature, not valid until we actually do forward! */
-      memset (&pp[putlen].sig,
-              0,
-              sizeof (pp[putlen].sig));
-      putlen++;
     }
     else
     {
@@ -1841,8 +1848,8 @@ handle_dht_p2p_put (void *cls,
       forwarded
         = GDS_NEIGHBOURS_handle_put (&bd,
                                      options,
-                                     ntohl (put->desired_replication_level),
-                                     ntohl (put->hop_count),
+                                     ntohs (put->desired_replication_level),
+                                     ntohs (put->hop_count),
                                      bf);
       /* notify monitoring clients */
       GDS_CLIENTS_process_put (options
@@ -1850,8 +1857,8 @@ handle_dht_p2p_put (void *cls,
                                 ? GNUNET_DHT_RO_LAST_HOP
                                 : 0),
                                &bd,
-                               ntohl (put->hop_count),
-                               ntohl (put->desired_replication_level));
+                               ntohs (put->hop_count),
+                               ntohs (put->desired_replication_level));
     }
     GNUNET_CONTAINER_bloomfilter_free (bf);
   }
@@ -2033,10 +2040,10 @@ handle_dht_p2p_get (void *cls,
   struct PeerInfo *peer = t->pi;
   uint16_t msize = ntohs (get->header.size);
   uint32_t xquery_size = ntohl (get->xquery_size);
-  uint32_t hop_count = ntohl (get->hop_count);
+  uint32_t hop_count = ntohs (get->hop_count);
   size_t reply_bf_size = msize - (sizeof(*get) + xquery_size);
   enum GNUNET_BLOCK_Type type = (enum GNUNET_BLOCK_Type) ntohl (get->type);
-  enum GNUNET_DHT_RouteOption options = (enum GNUNET_DHT_RouteOption)  ntohl (
+  enum GNUNET_DHT_RouteOption options = (enum GNUNET_DHT_RouteOption)  ntohs (
     get->options);
   enum GNUNET_BLOCK_ReplyEvaluationResult eval = GNUNET_BLOCK_REPLY_OK_MORE;
   const void *xquery = (const void *) &get[1];
@@ -2146,7 +2153,7 @@ handle_dht_p2p_get (void *cls,
     /* P2P forwarding */
     {
       bool forwarded = false;
-      uint32_t desired_replication_level = ntohl (
+      uint16_t desired_replication_level = ntohs (
         get->desired_replication_level);
 
       if (eval != GNUNET_BLOCK_REPLY_OK_LAST)
@@ -2235,8 +2242,8 @@ static enum GNUNET_GenericReturnValue
 check_dht_p2p_result (void *cls,
                       const struct PeerResultMessage *prm)
 {
-  uint32_t get_path_length = ntohl (prm->get_path_length);
-  uint32_t put_path_length = ntohl (prm->put_path_length);
+  uint16_t get_path_length = ntohs (prm->get_path_length);
+  uint16_t put_path_length = ntohs (prm->put_path_length);
   uint16_t msize = ntohs (prm->header.size);
 
   (void) cls;
@@ -2326,11 +2333,11 @@ handle_dht_p2p_result (void *cls,
   struct Target *t = cls;
   struct PeerInfo *peer = t->pi;
   uint16_t msize = ntohs (prm->header.size);
-  uint32_t get_path_length = ntohl (prm->get_path_length);
+  uint16_t get_path_length = ntohs (prm->get_path_length);
   struct GDS_DATACACHE_BlockData bd = {
     .expiration_time  = GNUNET_TIME_absolute_ntoh (prm->expiration_time),
     .put_path = (const struct GNUNET_DHT_PathElement *) &prm[1],
-    .put_path_length = ntohl (prm->put_path_length),
+    .put_path_length = ntohs (prm->put_path_length),
     .type = ntohl (prm->type)
   };
   const struct GNUNET_DHT_PathElement *get_path
diff --git a/src/dht/gnunet-service-dht_neighbours.h 
b/src/dht/gnunet-service-dht_neighbours.h
index 5c327e019..fdaf655bd 100644
--- a/src/dht/gnunet-service-dht_neighbours.h
+++ b/src/dht/gnunet-service-dht_neighbours.h
@@ -63,8 +63,8 @@ GDS_NEIGHBOURS_lookup_peer (const struct GNUNET_PeerIdentity 
*target);
 enum GNUNET_GenericReturnValue
 GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd,
                            enum GNUNET_DHT_RouteOption options,
-                           uint32_t desired_replication_level,
-                           uint32_t hop_count,
+                           uint16_t desired_replication_level,
+                           uint16_t hop_count,
                            struct GNUNET_CONTAINER_BloomFilter *bf);
 
 
@@ -88,8 +88,8 @@ GDS_NEIGHBOURS_handle_put (const struct 
GDS_DATACACHE_BlockData *bd,
 enum GNUNET_GenericReturnValue
 GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
                            enum GNUNET_DHT_RouteOption options,
-                           uint32_t desired_replication_level,
-                           uint32_t hop_count,
+                           uint16_t desired_replication_level,
+                           uint16_t hop_count,
                            const struct GNUNET_HashCode *key,
                            const void *xquery,
                            size_t xquery_size,
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c
index 2f6d6161e..612d2c119 100644
--- a/src/dhtu/plugin_dhtu_ip.c
+++ b/src/dhtu/plugin_dhtu_ip.c
@@ -566,6 +566,51 @@ create_source (struct Plugin *plugin,
 }
 
 
+/**
+ * Compare two addresses excluding the ports for equality. Only compares IP
+ * address. Must only be called on AF_INET or AF_INET6 addresses.
+ *
+ * @param a1 address to compare
+ * @param a2 address to compare
+ * @param alen number of bytes in @a a1 and @a a2
+ * @return 0 if @a a1 == @a a2.
+ */
+static int
+addrcmp_np (const struct sockaddr *a1,
+            const struct sockaddr *a2,
+            size_t alen)
+{
+  GNUNET_assert (a1->sa_family == a2->sa_family);
+  switch (a1->sa_family)
+  {
+  case AF_INET:
+    GNUNET_assert (sizeof (struct sockaddr_in) == alen);
+    {
+      const struct sockaddr_in *s1 = (const struct sockaddr_in *) a1;
+      const struct sockaddr_in *s2 = (const struct sockaddr_in *) a2;
+
+      if (s1->sin_addr.s_addr != s2->sin_addr.s_addr)
+        return 1;
+      break;
+    }
+  case AF_INET6:
+    GNUNET_assert (sizeof (struct sockaddr_in6) == alen);
+    {
+      const struct sockaddr_in6 *s1 = (const struct sockaddr_in6 *) a1;
+      const struct sockaddr_in6 *s2 = (const struct sockaddr_in6 *) a2;
+
+      if (0 != GNUNET_memcmp (&s1->sin6_addr,
+                              &s2->sin6_addr))
+        return 1;
+      break;
+    }
+  default:
+    GNUNET_assert (0);
+  }
+  return 0;
+}
+
+
 /**
  * Compare two addresses for equality. Only
  * compares IP address and port. Must only be
@@ -601,6 +646,7 @@ addrcmp (const struct sockaddr *a1,
     {
       const struct sockaddr_in6 *s1 = (const struct sockaddr_in6 *) a1;
       const struct sockaddr_in6 *s2 = (const struct sockaddr_in6 *) a2;
+
       if (s1->sin6_port != s2->sin6_port)
         return 1;
       if (0 != GNUNET_memcmp (&s1->sin6_addr,
@@ -644,9 +690,9 @@ process_ifcs (void *cls,
        src = src->next)
   {
     if ( (addrlen == src->addrlen) &&
-         (0 == addrcmp (addr,
-                        (const struct sockaddr *) &src->addr,
-                        addrlen)) )
+         (0 == addrcmp_np (addr,
+                           (const struct sockaddr *) &src->addr,
+                           addrlen)) )
     {
       src->scan_generation = plugin->scan_generation;
       return GNUNET_OK;
@@ -706,7 +752,7 @@ scan (void *cls)
        src = next)
   {
     next = src->next;
-    if (src->scan_generation == plugin->scan_generation)
+    if (src->scan_generation >= plugin->scan_generation)
       continue;
     GNUNET_CONTAINER_DLL_remove (plugin->src_head,
                                  plugin->src_tail,
@@ -831,6 +877,9 @@ read_cb (void *cls)
           src = find_source (plugin,
                              &sa,
                              sizeof (sa));
+          /* For sources we discovered by reading,
+             force the generation far into the future */
+          src->scan_generation = plugin->scan_generation + 60;
         }
         break;
       }
@@ -859,6 +908,9 @@ read_cb (void *cls)
           src = find_source (plugin,
                              &sa,
                              sizeof (sa));
+          /* For sources we discovered by reading,
+             force the generation far into the future */
+          src->scan_generation = plugin->scan_generation + 60;
           break;
         }
       }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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