From 01a4013c9f1bca74ae784b3508b67be32d9b33db Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 22 Apr 2010 09:34:46 +0000 Subject: [PATCH] ignore addresses of other peers that are equal to our own --- TODO | 5 ----- src/transport/gnunet-service-transport.c | 21 ++++++++++++++++++++- src/transport/plugin_transport_tcp.c | 8 +++++++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 6eccfe2f3..7f4e86826 100644 --- 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 diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 220879b3b..8af5c6d24 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -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 diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 34e13cc28..e71e751f6 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -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 a 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, -- 2.25.1