diff options
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 15 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 55 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 42 |
3 files changed, 68 insertions, 44 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index efbd67619..60f942d91 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -504,7 +504,7 @@ GST_receive_callback (void *cls, | |||
504 | return ret; | 504 | return ret; |
505 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: | 505 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: |
506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
507 | "Processing `%s' from `%s'\n", "PING", | 507 | "Processing PING from `%s'\n", |
508 | GST_plugins_a2s (address)); | 508 | GST_plugins_a2s (address)); |
509 | if (GNUNET_OK != | 509 | if (GNUNET_OK != |
510 | GST_validation_handle_ping (&address->peer, | 510 | GST_validation_handle_ping (&address->peer, |
@@ -520,7 +520,7 @@ GST_receive_callback (void *cls, | |||
520 | break; | 520 | break; |
521 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: | 521 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: |
522 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 522 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
523 | "Processing `%s' from `%s'\n", "PONG", | 523 | "Processing PONG from `%s'\n", |
524 | GST_plugins_a2s (address)); | 524 | GST_plugins_a2s (address)); |
525 | if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message)) | 525 | if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message)) |
526 | { | 526 | { |
@@ -572,13 +572,16 @@ GST_receive_callback (void *cls, | |||
572 | } | 572 | } |
573 | break; | 573 | break; |
574 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: | 574 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: |
575 | GST_neighbours_handle_disconnect_message (&address->peer, message); | 575 | GST_neighbours_handle_disconnect_message (&address->peer, |
576 | message); | ||
576 | break; | 577 | break; |
577 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE: | 578 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE: |
578 | GST_neighbours_keepalive (&address->peer, message); | 579 | GST_neighbours_keepalive (&address->peer, |
580 | message); | ||
579 | break; | 581 | break; |
580 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE: | 582 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE: |
581 | GST_neighbours_keepalive_response (&address->peer, message); | 583 | GST_neighbours_keepalive_response (&address->peer, |
584 | message); | ||
582 | break; | 585 | break; |
583 | default: | 586 | default: |
584 | /* should be payload */ | 587 | /* should be payload */ |
@@ -591,7 +594,7 @@ GST_receive_callback (void *cls, | |||
591 | message); | 594 | message); |
592 | break; | 595 | break; |
593 | } | 596 | } |
594 | end: | 597 | end: |
595 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 598 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
596 | "Allowing receive from peer %s to continue in %s\n", | 599 | "Allowing receive from peer %s to continue in %s\n", |
597 | GNUNET_i2s (&address->peer), | 600 | GNUNET_i2s (&address->peer), |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 729de12d3..c4886520b 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -1402,7 +1402,7 @@ send_keepalive (struct NeighbourMapEntry *n) | |||
1402 | GNUNET_YES, | 1402 | GNUNET_YES, |
1403 | NULL, NULL); | 1403 | NULL, NULL); |
1404 | GNUNET_STATISTICS_update (GST_stats, | 1404 | GNUNET_STATISTICS_update (GST_stats, |
1405 | gettext_noop ("# keepalives sent"), | 1405 | gettext_noop ("# KEEPALIVES sent"), |
1406 | 1, | 1406 | 1, |
1407 | GNUNET_NO); | 1407 | GNUNET_NO); |
1408 | n->primary_address.keep_alive_nonce = nonce; | 1408 | n->primary_address.keep_alive_nonce = nonce; |
@@ -1428,9 +1428,12 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour, | |||
1428 | struct SessionKeepAliveMessage msg; | 1428 | struct SessionKeepAliveMessage msg; |
1429 | 1429 | ||
1430 | if (sizeof (struct SessionKeepAliveMessage) != ntohs (m->size)) | 1430 | if (sizeof (struct SessionKeepAliveMessage) != ntohs (m->size)) |
1431 | { | ||
1432 | GNUNET_break_op (0); | ||
1431 | return; | 1433 | return; |
1434 | } | ||
1432 | 1435 | ||
1433 | msg_in = (struct SessionKeepAliveMessage *) m; | 1436 | msg_in = (const struct SessionKeepAliveMessage *) m; |
1434 | if (NULL == (n = lookup_neighbour (neighbour))) | 1437 | if (NULL == (n = lookup_neighbour (neighbour))) |
1435 | { | 1438 | { |
1436 | GNUNET_STATISTICS_update (GST_stats, | 1439 | GNUNET_STATISTICS_update (GST_stats, |
@@ -1449,8 +1452,9 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour, | |||
1449 | } | 1452 | } |
1450 | 1453 | ||
1451 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1454 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1452 | "Received keep alive request from peer `%s' with nonce %u\n", | 1455 | "Received KEEPALIVE request from peer `%s' with nonce %u\n", |
1453 | GNUNET_i2s (&n->id), ntohl (msg_in->nonce)); | 1456 | GNUNET_i2s (&n->id), |
1457 | ntohl (msg_in->nonce)); | ||
1454 | 1458 | ||
1455 | /* send reply to allow neighbour to measure latency */ | 1459 | /* send reply to allow neighbour to measure latency */ |
1456 | msg.header.size = htons (sizeof (struct SessionKeepAliveMessage)); | 1460 | msg.header.size = htons (sizeof (struct SessionKeepAliveMessage)); |
@@ -1484,50 +1488,50 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, | |||
1484 | struct GNUNET_TIME_Relative latency; | 1488 | struct GNUNET_TIME_Relative latency; |
1485 | 1489 | ||
1486 | if (sizeof (struct SessionKeepAliveMessage) != ntohs (m->size)) | 1490 | if (sizeof (struct SessionKeepAliveMessage) != ntohs (m->size)) |
1491 | { | ||
1492 | GNUNET_break_op (0); | ||
1487 | return; | 1493 | return; |
1494 | } | ||
1488 | 1495 | ||
1489 | msg = (const struct SessionKeepAliveMessage *) m; | 1496 | msg = (const struct SessionKeepAliveMessage *) m; |
1490 | if (NULL == (n = lookup_neighbour (neighbour))) | 1497 | if (NULL == (n = lookup_neighbour (neighbour))) |
1491 | { | 1498 | { |
1492 | GNUNET_STATISTICS_update (GST_stats, | 1499 | GNUNET_STATISTICS_update (GST_stats, |
1493 | gettext_noop | 1500 | gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (not connected)"), |
1494 | ("# KEEPALIVE_RESPONSE messages discarded (not connected)"), | 1501 | 1, |
1495 | 1, GNUNET_NO); | 1502 | GNUNET_NO); |
1496 | return; | 1503 | return; |
1497 | } | 1504 | } |
1498 | if ( (GNUNET_TRANSPORT_PS_CONNECTED != n->state) || | 1505 | if ( (GNUNET_TRANSPORT_PS_CONNECTED != n->state) || |
1499 | (GNUNET_YES != n->expect_latency_response) ) | 1506 | (GNUNET_YES != n->expect_latency_response) ) |
1500 | { | 1507 | { |
1501 | GNUNET_STATISTICS_update (GST_stats, | 1508 | GNUNET_STATISTICS_update (GST_stats, |
1502 | gettext_noop | 1509 | gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (not expected)"), |
1503 | ("# KEEPALIVE_RESPONSE messages discarded (not expected)"), | 1510 | 1, |
1504 | 1, GNUNET_NO); | 1511 | GNUNET_NO); |
1505 | return; | 1512 | return; |
1506 | } | 1513 | } |
1507 | if (NULL == n->primary_address.address) | 1514 | if (NULL == n->primary_address.address) |
1508 | { | 1515 | { |
1509 | GNUNET_STATISTICS_update (GST_stats, | 1516 | GNUNET_STATISTICS_update (GST_stats, |
1510 | gettext_noop | 1517 | gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (address changed)"), |
1511 | ("# KEEPALIVE_RESPONSE messages discarded (address changed)"), | 1518 | 1, |
1512 | 1, GNUNET_NO); | 1519 | GNUNET_NO); |
1513 | return; | 1520 | return; |
1514 | } | 1521 | } |
1515 | if (n->primary_address.keep_alive_nonce != ntohl (msg->nonce)) | 1522 | if (n->primary_address.keep_alive_nonce != ntohl (msg->nonce)) |
1516 | { | 1523 | { |
1517 | GNUNET_STATISTICS_update (GST_stats, | 1524 | GNUNET_STATISTICS_update (GST_stats, |
1518 | gettext_noop | 1525 | gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (wrong nonce)"), |
1519 | ("# KEEPALIVE_RESPONSE messages discarded (wrong nonce)"), | 1526 | 1, |
1520 | 1, GNUNET_NO); | 1527 | GNUNET_NO); |
1521 | return; | 1528 | return; |
1522 | } | 1529 | } |
1523 | else | 1530 | GNUNET_STATISTICS_update (GST_stats, |
1524 | { | 1531 | gettext_noop ("# KEEPALIVE_RESPONSE messages received in good order"), |
1525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1532 | 1, |
1526 | "Received keep alive response from peer `%s' for session %p\n", | 1533 | GNUNET_NO); |
1527 | GNUNET_i2s (&n->id), | ||
1528 | n->primary_address.session); | ||
1529 | 1534 | ||
1530 | } | ||
1531 | 1535 | ||
1532 | /* Update session timeout here */ | 1536 | /* Update session timeout here */ |
1533 | if (NULL != (papi = GST_plugins_find (n->primary_address.address->transport_name))) | 1537 | if (NULL != (papi = GST_plugins_find (n->primary_address.address->transport_name))) |
@@ -1553,12 +1557,13 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, | |||
1553 | 1557 | ||
1554 | latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time); | 1558 | latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time); |
1555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1559 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1556 | "Latency for peer `%s' is %s\n", | 1560 | "Received KEEPALIVE_RESPONSE from peer `%s', latency is %s\n", |
1557 | GNUNET_i2s (&n->id), | 1561 | GNUNET_i2s (&n->id), |
1558 | GNUNET_STRINGS_relative_time_to_string (latency, | 1562 | GNUNET_STRINGS_relative_time_to_string (latency, |
1559 | GNUNET_YES)); | 1563 | GNUNET_YES)); |
1560 | GST_ats_update_delay (n->primary_address.address, | 1564 | GST_ats_update_delay (n->primary_address.address, |
1561 | GNUNET_TIME_relative_divide (latency, 2)); | 1565 | GNUNET_TIME_relative_divide (latency, |
1566 | 2)); | ||
1562 | } | 1567 | } |
1563 | 1568 | ||
1564 | 1569 | ||
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index b6b323bd0..ee8a145c1 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -413,7 +413,8 @@ cleanup_validation_entry (void *cls, | |||
413 | ve->valid_until = GNUNET_TIME_UNIT_ZERO_ABS; | 413 | ve->valid_until = GNUNET_TIME_UNIT_ZERO_ABS; |
414 | 414 | ||
415 | /* Notify about deleted entry */ | 415 | /* Notify about deleted entry */ |
416 | validation_entry_changed (ve, GNUNET_TRANSPORT_VS_REMOVE); | 416 | validation_entry_changed (ve, |
417 | GNUNET_TRANSPORT_VS_REMOVE); | ||
417 | 418 | ||
418 | if (NULL != ve->bc) | 419 | if (NULL != ve->bc) |
419 | { | 420 | { |
@@ -449,9 +450,6 @@ cleanup_validation_entry (void *cls, | |||
449 | gettext_noop ("# validations running"), | 450 | gettext_noop ("# validations running"), |
450 | validations_running, | 451 | validations_running, |
451 | GNUNET_NO); | 452 | GNUNET_NO); |
452 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
453 | "Validation aborted, %u validation processes running\n", | ||
454 | validations_running); | ||
455 | } | 453 | } |
456 | GNUNET_free (ve); | 454 | GNUNET_free (ve); |
457 | return GNUNET_OK; | 455 | return GNUNET_OK; |
@@ -474,20 +472,30 @@ timeout_hello_validation (void *cls, | |||
474 | struct GNUNET_TIME_Relative left; | 472 | struct GNUNET_TIME_Relative left; |
475 | 473 | ||
476 | ve->timeout_task = NULL; | 474 | ve->timeout_task = NULL; |
475 | /* For valid addresses, we want to wait until the expire; | ||
476 | for addresses under PING validation, we want to wait | ||
477 | until we give up on the PING */ | ||
477 | max = GNUNET_TIME_absolute_max (ve->valid_until, | 478 | max = GNUNET_TIME_absolute_max (ve->valid_until, |
478 | ve->revalidation_block); | 479 | ve->revalidation_block); |
479 | left = GNUNET_TIME_absolute_get_remaining (max); | 480 | left = GNUNET_TIME_absolute_get_remaining (ve->max); |
480 | if (left.rel_value_us > 0) | 481 | if (left.rel_value_us > 0) |
481 | { | 482 | { |
482 | /* should wait a bit longer */ | 483 | /* We should wait a bit longer. This happens when |
484 | address lifetimes are extended due to successful | ||
485 | validations. */ | ||
483 | ve->timeout_task = | 486 | ve->timeout_task = |
484 | GNUNET_SCHEDULER_add_delayed (left, &timeout_hello_validation, ve); | 487 | GNUNET_SCHEDULER_add_delayed (left, |
488 | &timeout_hello_validation, | ||
489 | ve); | ||
485 | return; | 490 | return; |
486 | } | 491 | } |
487 | GNUNET_STATISTICS_update (GST_stats, | 492 | GNUNET_STATISTICS_update (GST_stats, |
488 | gettext_noop ("# address records discarded"), 1, | 493 | gettext_noop ("# address records discarded (timeout)"), |
494 | 1, | ||
489 | GNUNET_NO); | 495 | GNUNET_NO); |
490 | cleanup_validation_entry (NULL, &ve->address->peer, ve); | 496 | cleanup_validation_entry (NULL, |
497 | &ve->address->peer, | ||
498 | ve); | ||
491 | } | 499 | } |
492 | 500 | ||
493 | 501 | ||
@@ -519,11 +527,17 @@ transmit_ping_if_allowed (void *cls, | |||
519 | if (GNUNET_NO == result) | 527 | if (GNUNET_NO == result) |
520 | { | 528 | { |
521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 529 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
522 | "Blacklist denies to send PING to `%s' `%s' `%s'\n", | 530 | "Blacklist denies sending PING to `%s' `%s' `%s'\n", |
523 | GNUNET_i2s (pid), | 531 | GNUNET_i2s (pid), |
524 | GST_plugins_a2s (ve->address), | 532 | GST_plugins_a2s (ve->address), |
525 | ve->address->transport_name); | 533 | ve->address->transport_name); |
526 | cleanup_validation_entry (NULL, pid, ve); | 534 | GNUNET_STATISTICS_update (GST_stats, |
535 | gettext_noop ("# address records discarded (blacklist)"), | ||
536 | 1, | ||
537 | GNUNET_NO); | ||
538 | cleanup_validation_entry (NULL, | ||
539 | pid, | ||
540 | ve); | ||
527 | return; | 541 | return; |
528 | } | 542 | } |
529 | hello = GST_hello_get (); | 543 | hello = GST_hello_get (); |
@@ -775,8 +789,10 @@ find_validation_entry (const struct GNUNET_HELLO_Address *address) | |||
775 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); | 789 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); |
776 | ve->timeout_task = | 790 | ve->timeout_task = |
777 | GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE, | 791 | GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE, |
778 | &timeout_hello_validation, ve); | 792 | &timeout_hello_validation, |
779 | GNUNET_CONTAINER_multipeermap_put (validation_map, &address->peer, | 793 | ve); |
794 | GNUNET_CONTAINER_multipeermap_put (validation_map, | ||
795 | &address->peer, | ||
780 | ve, | 796 | ve, |
781 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 797 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
782 | publish_ve_stat_update (); | 798 | publish_ve_stat_update (); |