ignore addresses of other peers that are equal to our own
authorChristian Grothoff <christian@grothoff.org>
Thu, 22 Apr 2010 09:34:46 +0000 (09:34 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 22 Apr 2010 09:34:46 +0000 (09:34 +0000)
TODO
src/transport/gnunet-service-transport.c
src/transport/plugin_transport_tcp.c

diff --git a/TODO b/TODO
index 6eccfe2f348a8ceb6dea95a8175a6629d59a4cf6..7f4e868263607df7c5441d885000e04e42aa18ed 100644 (file)
--- a/TODO
+++ b/TODO
@@ -158,11 +158,6 @@ Optimizations:
   - should use BIO instead of mmap
 * TRANSPORT:
   - need to periodically probe latency/transport cost changes & possibly switch transport
-  - instantly filter addresses from *other* peers that 
-    are *equal* to our own address + port (i.e., localhost:2086).  We 
-    no longer filter those for outgoing (helps with loopback testing
-    and keeps the code clean), but we should filter strictly *impossible*
-    incoming addresses!  This is for efficiency, not correctness.
   - should use hash map to look up Neighbours (service AND plugins!)
 * HOSTLIST:
   - 'server' uses 'GNUNET_PEERINFO_iterate', should probably switch to notification API
index 220879b3b18637a7bff9aa59246cf86eebfc3593..8af5c6d24b12825b67354a4b2f15fe27c78bf7af 100644 (file)
@@ -3475,6 +3475,7 @@ run_validation (void *cls,
   struct ValidationEntry *va;
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk;
   struct CheckAddressExistsClosure caec;
+  struct OwnAddressList *oal;
 
   GNUNET_assert (addr != NULL);
   GNUNET_STATISTICS_update (stats,
@@ -3490,11 +3491,29 @@ run_validation (void *cls,
                   ("Transport `%s' not loaded, will not try to validate peer address using this transport.\n"),
                   tname);
       GNUNET_STATISTICS_update (stats,
-                               gettext_noop ("# peer addresses not validated (no applicable transport plugin available)"),
+                               gettext_noop ("# peer addresses not validated (plugin not available)"),
                                1,
                                GNUNET_NO);      
       return GNUNET_OK;
     }
+  /* check if this is one of our own addresses */
+  oal = tp->addresses;
+  while (NULL != oal)
+    {
+      if ( (oal->addrlen == addrlen) &&
+          (0 == memcmp (oal->addr,
+                        addr,
+                        addrlen)) )
+       {
+         /* not plausible, this address is equivalent to our own address! */
+         GNUNET_STATISTICS_update (stats,
+                                   gettext_noop ("# peer addresses not validated (loopback)"),
+                                   1,
+                                   GNUNET_NO);      
+         return GNUNET_OK;
+       }
+      oal = oal->next;
+    }
   GNUNET_HELLO_get_key (chvc->hello, &pk);
   GNUNET_CRYPTO_hash (&pk,
                       sizeof (struct
index 34e13cc28314d0236d0bff2676d95c854c5747ba..e71e751f69682c670df8a4279514614dc0acb82d 100644 (file)
@@ -685,7 +685,7 @@ tcp_plugin_send (void *cls,
                            gettext_noop ("# bytes TCP was asked to transmit"),
                            msgbuf_size,
                            GNUNET_NO);      
-  /* FIXME: we could do this cheaper with a hash table
+  /* FIXME: we could do this cheaper with a hash table
      where we could restrict the iteration to entries that match
      the target peer... */
   if (session == NULL)
@@ -1253,6 +1253,12 @@ disconnect_notify (void *cls, struct GNUNET_SERVER_Client *client)
 /**
  * Add the IP of our network interface to the list of
  * our external IP addresses.
+ *
+ * @param cls the 'struct Plugin*'
+ * @param name name of the interface
+ * @param isDefault do we think this may be our default interface
+ * @param addr address of the interface
+ * @param addrlen number of bytes in addr
  */
 static int
 process_interfaces (void *cls,