From: Christian Grothoff Date: Tue, 16 Mar 2010 16:20:44 +0000 (+0000) Subject: misc X-Git-Tag: initial-import-from-subversion-38251~22439 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fb8c8f76e503991036fefcc8eaf02ed18366a7f0;p=oweals%2Fgnunet.git misc --- diff --git a/TODO b/TODO index c549759ce..bde3d97b4 100644 --- a/TODO +++ b/TODO @@ -15,16 +15,22 @@ away), in order in which they will likely be done: 0.9.0pre0: * HOSTLIST/PEERINFO/CORE/TRANSPORT/TOPOLOGY: - - hostlist server learns about 2nd peer, but soon forgets! - - peers do not seem to connect (at least not for long!) - + - hostlist server learns about 2nd peer, but soon forgets (not + clear if this is still an issue, or if validation failed or + if this was an issue with the client's parsing of the reply, which + was broken...) * TOPOLOGY: - needs more testing (especially F2F topology) - - calls 'GNUNET_CORE_peer_request_connect' with 'my_identity' as the PID, - despite having specific checks to prevent exactly that (!?) - => assertion failure in gnunet-service-core:2255 (hostlist test) + - needs to re-try connecting after disconnect (currently, it + initially triggers a connection request, but if that connection + fails / goes down, it does not retry in a timely fashion; + cause seems to be the 'blacklist_after_attempt' being set to 1h, + which is rather long -- and should probably be adjusted based on + the number of connections / known peers) * CORE: - - needs more testing + - peers do not seem to connect (setkey, ping are there; PONG is sent, + not sure what else happens; eventually, the "neighbour" entry times + out and is removed) * UTIL: - load: need way to determine network load (up/down) -- and quickly so! - trust: need *fast* way to check/update trust in peers diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 70fa4e92c..aba4c5b0f 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -437,6 +437,12 @@ struct NeighbourList */ struct MessageQueue *messages_tail; + /** + * Context for peerinfo iteration. + * NULL after we are done processing peerinfo's information. + */ + struct GNUNET_PEERINFO_IteratorContext *piter; + /** * Identity of this neighbour. */ @@ -1167,6 +1173,17 @@ find_ready_address(struct NeighbourList *neighbour) addresses = head->addresses; while (addresses != NULL) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Have address `%s' for peer `%4s' (status: %d, %d, %d, %u, %llums, %u)\n", + GNUNET_a2s (addresses->addr, + addresses->addrlen), + GNUNET_i2s (&neighbour->id), + addresses->connected, + addresses->in_transmit, + addresses->validated, + addresses->connect_attempts, + (unsigned long long) addresses->timeout.value, + (unsigned int) addresses->distance); if ( ( (best_address == NULL) || (addresses->connected == GNUNET_YES) || (best_address->connected == GNUNET_NO) ) && @@ -1229,14 +1246,29 @@ try_transmission_to_peer (struct NeighbourList *neighbour) struct GNUNET_TIME_Relative timeout; if (neighbour->messages_head == NULL) - return; /* nothing to do */ + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Transmission queue for `%4s' is empty\n", + GNUNET_i2s (&neighbour->id)); + return; /* nothing to do */ + } rl = NULL; mq = neighbour->messages_head; /* FIXME: support bi-directional use of TCP */ if (mq->specific_address == NULL) - mq->specific_address = find_ready_address(neighbour); + { + mq->specific_address = find_ready_address(neighbour); + GNUNET_STATISTICS_update (stats, + gettext_noop ("# transport selected peer address freely"), + 1, + GNUNET_NO); + } if (mq->specific_address == NULL) { + GNUNET_STATISTICS_update (stats, + gettext_noop ("# transport failed to selected peer address"), + 1, + GNUNET_NO); timeout = GNUNET_TIME_absolute_get_remaining (mq->timeout); if (timeout.value == 0) { @@ -1740,10 +1772,10 @@ find_peer_address(struct NeighbourList *neighbour, * @return NULL if we do not have a transport plugin for 'tname' */ static struct ForeignAddressList * -add_peer_address(struct NeighbourList *neighbour, - const char *tname, - const char *addr, - size_t addrlen) +add_peer_address (struct NeighbourList *neighbour, + const char *tname, + const char *addr, + size_t addrlen) { struct ReadyList *head; struct ForeignAddressList *ret; @@ -1932,6 +1964,118 @@ neighbour_timeout_task (void *cls, } + +/** + * Add the given address to the list of foreign addresses + * available for the given peer (check for duplicates). + * + * @param cls the respective 'struct NeighbourList' to update + * @param tname name of the transport + * @param expiration expiration time + * @param addr the address + * @param addrlen length of the address + * @return GNUNET_OK (always) + */ +static int +add_to_foreign_address_list (void *cls, + const char *tname, + struct GNUNET_TIME_Absolute expiration, + const void *addr, size_t addrlen) +{ + struct NeighbourList *n = cls; + struct ForeignAddressList *fal; + int try; + + GNUNET_STATISTICS_update (stats, + gettext_noop ("# valid peer addresses returned by peerinfo"), + 1, + GNUNET_NO); + try = GNUNET_NO; + fal = find_peer_address (n, tname, addr, addrlen); + if (fal == NULL) + { +#if DEBUG_TRANSPORT + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Adding address `%s' (%s) for peer `%4s' due to peerinfo data for %llums.\n", + GNUNET_a2s (addr, addrlen), + tname, + GNUNET_i2s (&n->id), + expiration.value); +#endif + fal = add_peer_address (n, tname, addr, addrlen); + if (fal == NULL) + { + GNUNET_STATISTICS_update (stats, + gettext_noop ("# previously validated addresses lacking transport"), + 1, + GNUNET_NO); + } + try = GNUNET_YES; + } + if (fal == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Failed to add new address for `%4s'\n", + GNUNET_i2s (&n->id)); + return GNUNET_OK; + } + fal->expires = GNUNET_TIME_absolute_max (expiration, + fal->expires); + if (fal->validated == GNUNET_NO) + { + fal->validated = GNUNET_YES; + GNUNET_STATISTICS_update (stats, + gettext_noop ("# peer addresses considered valid"), + 1, + GNUNET_NO); + } + if (try == GNUNET_YES) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Have new addresses, will try to trigger transmissions.\n"); + try_transmission_to_peer (n); + } + return GNUNET_OK; +} + + +/** + * Add addresses in validated HELLO "h" to the set of addresses + * we have for this peer. + * + * @param cls closure ('struct NeighbourList*') + * @param peer id of the peer, NULL for last call + * @param h hello message for the peer (can be NULL) + * @param trust amount of trust we have in the peer (not used) + */ +static void +add_hello_for_peer (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Message *h, + uint32_t trust) +{ + struct NeighbourList *n = cls; + + if (peer == NULL) + { + n->piter = NULL; + return; + } + if (h == NULL) + return; /* no HELLO available */ +#if DEBUG_TRANSPORT + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Peerinfo had `%s' message for peer `%4s', adding existing addresses.\n", + "HELLO", + GNUNET_i2s (peer)); +#endif + GNUNET_HELLO_iterate_addresses (h, + GNUNET_NO, + &add_to_foreign_address_list, + n); +} + + /** * Create a fresh entry in our neighbour list for the given peer. * Will try to transmit our current HELLO to the new neighbour. @@ -1979,8 +2123,9 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer) n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &neighbour_timeout_task, n); - // FIXME: query PEERINFO for HELLO for this peer & - // add addresses!? + n->piter = GNUNET_PEERINFO_iterate (cfg, sched, peer, + 0, GNUNET_TIME_UNIT_FOREVER_REL, + &add_hello_for_peer, n); transmit_to_peer (NULL, NULL, 0, HELLO_ADDRESS_EXPIRATION, (const char *) our_hello, GNUNET_HELLO_size(our_hello), @@ -2436,71 +2581,6 @@ run_validation (void *cls, } -/** - * Add the given address to the list of foreign addresses - * available for the given peer (check for duplicates). - * - * @param cls the respective 'struct NeighbourList' to update - * @param tname name of the transport - * @param expiration expiration time - * @param addr the address - * @param addrlen length of the address - * @return GNUNET_OK (always) - */ -static int -add_to_foreign_address_list (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, size_t addrlen) -{ - struct NeighbourList *n = cls; - struct ForeignAddressList *fal; - int try; - - GNUNET_STATISTICS_update (stats, - gettext_noop ("# valid peer addresses returned by peerinfo"), - 1, - GNUNET_NO); - try = GNUNET_NO; - fal = find_peer_address (n, tname, addr, addrlen); - if (fal == NULL) - { -#if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Adding address `%s' (%s) for peer `%4s' due to peerinfo data for %llums.\n", - GNUNET_a2s (addr, addrlen), - tname, - GNUNET_i2s (&n->id), - expiration.value); -#endif - fal = add_peer_address (n, tname, addr, addrlen); - if (fal == NULL) - { - GNUNET_STATISTICS_update (stats, - gettext_noop ("# previously validated addresses lacking transport"), - 1, - GNUNET_NO); - } - try = GNUNET_YES; - } - if (fal == NULL) - return GNUNET_OK; - fal->expires = GNUNET_TIME_absolute_max (expiration, - fal->expires); - if (fal->validated == GNUNET_NO) - { - fal->validated = GNUNET_YES; - GNUNET_STATISTICS_update (stats, - gettext_noop ("# peer addresses considered valid"), - 1, - GNUNET_NO); - } - if (try == GNUNET_YES) - try_transmission_to_peer (n); - return GNUNET_OK; -} - - /** * Check if addresses in validated hello "h" overlap with * those in "chvc->hello" and validate the rest. @@ -2798,6 +2878,11 @@ disconnect_neighbour (struct NeighbourList *n, int check) GNUNET_SCHEDULER_cancel (sched, n->retry_task); n->retry_task = GNUNET_SCHEDULER_NO_TASK; } + if (n->piter != NULL) + { + GNUNET_PEERINFO_iterate_cancel (n->piter); + n->piter = NULL; + } /* finally, free n itself */ GNUNET_STATISTICS_update (stats, gettext_noop ("# active neighbours"),