From: Matthias Wachs Date: Fri, 15 Jun 2012 13:11:46 +0000 (+0000) Subject: - changed behavior when receiving CONNECT messages ... inbound session and NAT tests... X-Git-Tag: initial-import-from-subversion-38251~13043 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0bb2d2a34cbd8f1c0118f6203eaf9f41a1570fa7;p=oweals%2Fgnunet.git - changed behavior when receiving CONNECT messages ... inbound session and NAT tests work again --- diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index cdf948291..25296d95e 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c @@ -384,9 +384,6 @@ find_empty_session_slot (struct GNUNET_ATS_SchedulingHandle *sh, struct Session sh->session_array_size * 2); } GNUNET_assert (f > 0); - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api", - "Session %p for peer `%s' stored in slot %u \n", - session, GNUNET_i2s (peer), f); sh->session_array[f].session = session; sh->session_array[f].peer = *peer; sh->session_array[f].slot_used = GNUNET_YES; @@ -1117,8 +1114,11 @@ GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh, s = find_session_id (sh, session, &address->peer); if (NOT_FOUND != s) { - /* Already existing */ - GNUNET_break (0); + /* Already existing, nothing todo */ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Adding duplicate address for peer `%s', plugin `%s', session %p id %u\n", + GNUNET_i2s (&address->peer), + address->transport_name, session, s); return GNUNET_SYSERR; } s = find_empty_session_slot (sh, session, &address->peer); @@ -1213,12 +1213,8 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, { s = find_session_id (sh, session, &address->peer); if (NOT_FOUND == s) - { - /* new session without slot, find one */ - s = find_empty_session_slot (sh, session, &address->peer); - GNUNET_break (NOT_FOUND != s); + GNUNET_break (0); return; - } } m->session_id = htonl (s); @@ -1272,7 +1268,7 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh, return; } - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to set address to %s for peer `%s', plugin `%s', session %p\n", GNUNET_i2s (&address->peer), (GNUNET_NO == in_use) ? "NO" : "YES", diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index c200cb55b..974ecf288 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -287,11 +287,6 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, break; } end: -#if 1 - /* FIXME: this should not be needed, and not sure it's good to have it, but without - * this connections seem to go extra-slow */ - GNUNET_ATS_address_update (GST_ats, &address, session, ats, ats_count); -#endif GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Allowing receive from peer %s to continue in %llu ms\n", GNUNET_i2s (peer), (unsigned long long) ret.rel_value); diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index dd724e87b..d1a999376 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -221,10 +221,10 @@ struct MessageQueue * Possible state of a neighbour. Initially, we are S_NOT_CONNECTED. * * Then, there are two main paths. If we receive a CONNECT message, we - * first run a check against the blacklist and ask ATS for a - * suggestion. (S_CONNECT_RECV_ATS). If the blacklist comes back - * positive, we give the address to ATS. If ATS makes a suggestion, - * we ALSO give that suggestion to the blacklist + * first run a check against the blacklist (S_CONNECT_RECV_BLACKLIST_INBOUND). + * If this check is successful, we give the inbound address to ATS. + * After the check we ask ATS for a suggestion (S_CONNECT_RECV_ATS). + * If ATS makes a suggestion, we ALSO give that suggestion to the blacklist * (S_CONNECT_RECV_BLACKLIST). Once the blacklist approves the * address we got from ATS, we send our CONNECT_ACK and go to * S_CONNECT_RECV_ACK. If we receive a SESSION_ACK, we go to @@ -301,6 +301,11 @@ enum State */ S_CONNECT_SENT, + /** + * Received a CONNECT, do a blacklist check for inbound address + */ + S_CONNECT_RECV_BLACKLIST_INBOUND, + /** * Received a CONNECT, asking ATS about address suggestions. */ @@ -639,6 +644,9 @@ print_state (int state) case S_CONNECT_SENT: return "S_CONNECT_SENT"; break; + case S_CONNECT_RECV_BLACKLIST_INBOUND: + return "S_CONNECT_RECV_BLACKLIST_INBOUND"; + break; case S_CONNECT_RECV_ATS: return "S_CONNECT_RECV_ATS"; break; @@ -832,7 +840,6 @@ set_address (struct NeighbourAddress *na, if (GNUNET_YES == is_active) { /* Telling ATS about new session */ - GNUNET_ATS_address_add (GST_ats, na->address, na->session, NULL, 0); GNUNET_ATS_address_in_use (GST_ats, na->address, na->session, GNUNET_YES); GST_validation_set_address_use (na->address, na->session, GNUNET_YES, __LINE__); @@ -1728,14 +1735,6 @@ handle_test_blacklist_cont (void *cls, "Connection to new address of peer `%s' based on blacklist is `%s'\n", GNUNET_i2s (peer), (GNUNET_OK == result) ? "allowed" : "FORBIDDEN"); - if (GNUNET_OK == result) - { - /* valid new address, let ATS know! */ - GNUNET_ATS_address_add (GST_ats, - bcc->na.address, - bcc->na.session, - bcc->ats, bcc->ats_count); - } if (NULL == (n = lookup_neighbour (peer))) goto cleanup; /* nobody left to care about new address */ switch (n->state) @@ -1791,9 +1790,23 @@ handle_test_blacklist_cont (void *cls, n->connect_ack_timestamp); } break; + case S_CONNECT_RECV_BLACKLIST_INBOUND: + if (GNUNET_OK == result) + { + /* valid new address, let ATS know! */ + GNUNET_ATS_address_add (GST_ats, + bcc->na.address, + bcc->na.session, + bcc->ats, bcc->ats_count); + } + n->state = S_CONNECT_RECV_ATS; + n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT); + GNUNET_ATS_reset_backoff (GST_ats, peer); + GNUNET_ATS_suggest_address (GST_ats, peer); + break; case S_CONNECT_RECV_ATS: /* still waiting on ATS suggestion, don't care about blacklist */ - break; + break; case S_CONNECT_RECV_BLACKLIST: if (GNUNET_YES != address_matches (&bcc->na, &n->primary_address)) break; /* result for an address we currently don't care about */ @@ -2016,10 +2029,8 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, switch (n->state) { case S_NOT_CONNECTED: - n->state = S_CONNECT_RECV_ATS; - n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT); - GNUNET_ATS_reset_backoff (GST_ats, peer); - GNUNET_ATS_suggest_address (GST_ats, peer); + n->state = S_CONNECT_RECV_BLACKLIST_INBOUND; + /* Do a blacklist check for the new address */ check_blacklist (peer, ts, address, session, ats, ats_count); break; case S_INIT_ATS: @@ -2352,6 +2363,17 @@ master_task (void *cls, return; } break; + case S_CONNECT_RECV_BLACKLIST_INBOUND: + if (0 == delay.rel_value) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Connection to `%s' timed out waiting BLACKLIST to approve address to use for received CONNECT\n", + GNUNET_i2s (&n->id)); + n->state = S_DISCONNECT_FINISHED; + free_neighbour (n, GNUNET_NO); + return; + } + break; case S_CONNECT_RECV_ATS: if (0 == delay.rel_value) { diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 3e6100a29..e463243e1 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -1091,7 +1091,6 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, ve->latency = GNUNET_TIME_absolute_get_duration (ve->send_time); { struct GNUNET_ATS_Information ats; - ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); ats.value = htonl ((uint32_t) ve->latency.rel_value); GNUNET_ATS_address_add (GST_ats, ve->address, NULL, &ats, 1);