From: Nathan S. Evans Date: Wed, 8 Sep 2010 13:30:01 +0000 (+0000) Subject: possible fix for buildbot failure on NAT test case; once a 'NAT' address is used... X-Git-Tag: initial-import-from-subversion-38251~20391 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8fa400813bab11e04beab9d72f4c41b54b7dc29f;p=oweals%2Fgnunet.git possible fix for buildbot failure on NAT test case; once a 'NAT' address is used and a connection established, the new connection doesn't have a 'NAT' address (port 0) any longer, because it was built off of an inbound connection from the NAT'd peer. However, since we initiated the connection we expect that whatever address transport gives us should match. --- diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 65aea96e0..7d104f371 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -304,6 +304,11 @@ struct Session */ int inbound; + /** + * Was this session created using NAT traversal? + */ + int is_nat; + }; @@ -592,6 +597,7 @@ create_session (struct Plugin *plugin, ret = GNUNET_malloc (sizeof (struct Session)); ret->last_activity = GNUNET_TIME_absolute_get (); ret->plugin = plugin; + ret->is_nat = is_nat; if (is_nat != GNUNET_YES) /* If not a NAT WAIT conn, add it to global list */ { ret->next = plugin->sessions; @@ -1078,11 +1084,11 @@ tcp_plugin_send (void *cls, } if (session->inbound == GNUNET_YES) continue; - if (addrlen != session->connect_alen) + if ((addrlen != session->connect_alen) && (session->is_nat == GNUNET_NO)) continue; - if (0 != memcmp (session->connect_addr, + if ((0 != memcmp (session->connect_addr, addr, - addrlen)) + addrlen)) && (session->is_nat == GNUNET_NO)) continue; cand_session = select_better_session (cand_session, session); @@ -1152,7 +1158,7 @@ tcp_plugin_send (void *cls, return -1; /* NAT client only works with IPv4 addresses */ - if ( (plugin->allow_nat == GNUNET_YES) && (is_natd == GNUNET_YES) && + if ((plugin->allow_nat == GNUNET_YES) && (is_natd == GNUNET_YES) && (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(plugin->nat_wait_conns, &target->hashPubKey))) { #if DEBUG_TCP_NAT