diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-26 16:29:55 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-26 16:29:55 +0000 |
commit | 2064d2f3d860a2e381b94f624f76a5262d3fde47 (patch) | |
tree | 502840420e3cde8ffa24625d03cba021ba429937 /src/transport/gnunet-service-transport_neighbours.c | |
parent | 8fc8d917d98848d7eb9ad15942ca6e7c824c7d62 (diff) | |
download | gnunet-2064d2f3d860a2e381b94f624f76a5262d3fde47.tar.gz gnunet-2064d2f3d860a2e381b94f624f76a5262d3fde47.zip |
error handling for failed CONNECT messages in CONNECT_SWITCHING
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 138 |
1 files changed, 80 insertions, 58 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 0292b019e..7378e72e1 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -838,7 +838,7 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
838 | } | 838 | } |
839 | 839 | ||
840 | /** | 840 | /** |
841 | * Clear the primary address of a neighbour since this primary address is not | 841 | * Clear the primary address of a neighbour since this address is not |
842 | * valid anymore and notify monitoring about it | 842 | * valid anymore and notify monitoring about it |
843 | * | 843 | * |
844 | * @param n the neighbour | 844 | * @param n the neighbour |
@@ -858,7 +858,18 @@ unset_primary_address (struct NeighbourMapEntry *n) | |||
858 | n->primary_address.bandwidth_out); | 858 | n->primary_address.bandwidth_out); |
859 | } | 859 | } |
860 | 860 | ||
861 | 861 | /** | |
862 | * Clear the alternative address of a neighbour since this address is not | ||
863 | * valid anymore | ||
864 | * | ||
865 | * @param n the neighbour | ||
866 | */ | ||
867 | static void | ||
868 | unset_alternative_address (struct NeighbourMapEntry *n) | ||
869 | { | ||
870 | /* Unset primary address */ | ||
871 | free_address (&n->alternative_address); | ||
872 | } | ||
862 | 873 | ||
863 | /** | 874 | /** |
864 | * Free a neighbour map entry. | 875 | * Free a neighbour map entry. |
@@ -1640,7 +1651,8 @@ send_session_connect_cont (void *cls, | |||
1640 | } | 1651 | } |
1641 | 1652 | ||
1642 | if ( (GNUNET_TRANSPORT_PS_CONNECT_SENT != n->state) && | 1653 | if ( (GNUNET_TRANSPORT_PS_CONNECT_SENT != n->state) && |
1643 | (GNUNET_TRANSPORT_PS_RECONNECT_SENT != n->state) ) | 1654 | (GNUNET_TRANSPORT_PS_RECONNECT_SENT != n->state) && |
1655 | (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT != n->state)) | ||
1644 | { | 1656 | { |
1645 | /* CONNECT continuation was called after neighbor changed state, | 1657 | /* CONNECT continuation was called after neighbor changed state, |
1646 | * for example due to a time out for the state or the session | 1658 | * for example due to a time out for the state or the session |
@@ -1656,34 +1668,40 @@ send_session_connect_cont (void *cls, | |||
1656 | GST_plugins_a2s (n->primary_address.address), | 1668 | GST_plugins_a2s (n->primary_address.address), |
1657 | n->primary_address.session); | 1669 | n->primary_address.session); |
1658 | 1670 | ||
1659 | /* Failed to send CONNECT message with this address */ | 1671 | switch (n->state) { |
1660 | GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, | 1672 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: |
1661 | n->primary_address.session); | 1673 | /* Remove address and request and additional one */ |
1662 | GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, | 1674 | GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, |
1663 | NULL); | 1675 | n->primary_address.session); |
1664 | 1676 | GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL ); | |
1665 | /* Remove address and request and additional one */ | 1677 | unset_primary_address (n); |
1666 | unset_primary_address (n); | ||
1667 | |||
1668 | if (n->state == GNUNET_TRANSPORT_PS_RECONNECT_SENT) | ||
1669 | { | ||
1670 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, | 1678 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, |
1671 | GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); | 1679 | GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); |
1672 | 1680 | break; | |
1673 | } | 1681 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: |
1674 | else if (n->state == GNUNET_TRANSPORT_PS_INIT_ATS) | 1682 | /* Remove address and request and additional one */ |
1675 | { | 1683 | GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, |
1676 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, | 1684 | n->primary_address.session); |
1677 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 1685 | GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL ); |
1678 | } | 1686 | unset_primary_address (n); |
1679 | else | ||
1680 | { | ||
1681 | GNUNET_break (0); | ||
1682 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, | 1687 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, |
1683 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 1688 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); |
1689 | break; | ||
1690 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: | ||
1691 | /* Remove address and request and go back to primary address */ | ||
1692 | GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address, | ||
1693 | n->alternative_address.session); | ||
1694 | GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address, | ||
1695 | NULL ); | ||
1696 | unset_alternative_address (n); | ||
1697 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, | ||
1698 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | ||
1699 | break; | ||
1700 | default: | ||
1701 | GNUNET_break(0); | ||
1702 | disconnect_neighbour (n); | ||
1703 | break; | ||
1684 | } | 1704 | } |
1685 | |||
1686 | return; | ||
1687 | } | 1705 | } |
1688 | 1706 | ||
1689 | /** | 1707 | /** |
@@ -1740,31 +1758,35 @@ send_session_connect (struct NeighbourAddress *na) | |||
1740 | GNUNET_break (0); | 1758 | GNUNET_break (0); |
1741 | return; | 1759 | return; |
1742 | } | 1760 | } |
1743 | /* Hard failure to send the CONNECT message with this address: | ||
1744 | Destroy address and session */ | ||
1745 | GNUNET_ATS_address_destroyed (GST_ats, na->address, na->session); | ||
1746 | GNUNET_ATS_address_destroyed (GST_ats, na->address, NULL); | ||
1747 | 1761 | ||
1748 | /* Remove address and request and additional one */ | 1762 | switch (n->state) { |
1749 | unset_primary_address (n); | 1763 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: |
1750 | if (n->state == GNUNET_TRANSPORT_PS_RECONNECT_SENT) | 1764 | /* Remove address and request and additional one */ |
1751 | { | 1765 | unset_primary_address (n); |
1752 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, | 1766 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, |
1753 | GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); | 1767 | GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); |
1754 | 1768 | /* Hard failure to send the CONNECT message with this address: | |
1755 | } | 1769 | Destroy address and session */ |
1756 | else if (n->state == GNUNET_TRANSPORT_PS_INIT_ATS) | 1770 | break; |
1757 | { | 1771 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: |
1758 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, | 1772 | /* Remove address and request and additional one */ |
1759 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 1773 | unset_primary_address (n); |
1760 | } | 1774 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, |
1761 | else | 1775 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); |
1762 | { | 1776 | break; |
1763 | GNUNET_break (0); | 1777 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: |
1764 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, | 1778 | /* Remove address and request and additional one */ |
1765 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 1779 | unset_alternative_address (n); |
1780 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, | ||
1781 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | ||
1782 | break; | ||
1783 | default: | ||
1784 | GNUNET_break (0); | ||
1785 | disconnect_neighbour (n); | ||
1786 | break; | ||
1766 | } | 1787 | } |
1767 | return; | 1788 | GNUNET_ATS_address_destroyed (GST_ats, na->address, na->session); |
1789 | GNUNET_ATS_address_destroyed (GST_ats, na->address, NULL); | ||
1768 | } | 1790 | } |
1769 | GST_neighbours_notify_data_sent (&na->address->peer, | 1791 | GST_neighbours_notify_data_sent (&na->address->peer, |
1770 | na->address, | 1792 | na->address, |
@@ -3062,7 +3084,7 @@ master_task (void *cls, | |||
3062 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 3084 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
3063 | if (0 == delay.rel_value_us) | 3085 | if (0 == delay.rel_value_us) |
3064 | { | 3086 | { |
3065 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3087 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3066 | "Connection to `%s' timed out waiting ATS to provide address to use for CONNECT_ACK\n", | 3088 | "Connection to `%s' timed out waiting ATS to provide address to use for CONNECT_ACK\n", |
3067 | GNUNET_i2s (&n->id)); | 3089 | GNUNET_i2s (&n->id)); |
3068 | free_neighbour (n, GNUNET_NO); | 3090 | free_neighbour (n, GNUNET_NO); |
@@ -3072,7 +3094,7 @@ master_task (void *cls, | |||
3072 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: | 3094 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: |
3073 | if (0 == delay.rel_value_us) | 3095 | if (0 == delay.rel_value_us) |
3074 | { | 3096 | { |
3075 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3097 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3076 | "Connection to `%s' timed out waiting for other peer to send SESSION_ACK\n", | 3098 | "Connection to `%s' timed out waiting for other peer to send SESSION_ACK\n", |
3077 | GNUNET_i2s (&n->id)); | 3099 | GNUNET_i2s (&n->id)); |
3078 | disconnect_neighbour (n); | 3100 | disconnect_neighbour (n); |
@@ -3082,7 +3104,7 @@ master_task (void *cls, | |||
3082 | case GNUNET_TRANSPORT_PS_CONNECTED: | 3104 | case GNUNET_TRANSPORT_PS_CONNECTED: |
3083 | if (0 == delay.rel_value_us) | 3105 | if (0 == delay.rel_value_us) |
3084 | { | 3106 | { |
3085 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3107 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3086 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs\n", | 3108 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs\n", |
3087 | GNUNET_i2s (&n->id)); | 3109 | GNUNET_i2s (&n->id)); |
3088 | disconnect_neighbour (n); | 3110 | disconnect_neighbour (n); |
@@ -3094,7 +3116,7 @@ master_task (void *cls, | |||
3094 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: | 3116 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: |
3095 | if (0 == delay.rel_value_us) | 3117 | if (0 == delay.rel_value_us) |
3096 | { | 3118 | { |
3097 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3119 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3098 | "Connection to `%s' timed out, waiting for ATS replacement address\n", | 3120 | "Connection to `%s' timed out, waiting for ATS replacement address\n", |
3099 | GNUNET_i2s (&n->id)); | 3121 | GNUNET_i2s (&n->id)); |
3100 | disconnect_neighbour (n); | 3122 | disconnect_neighbour (n); |
@@ -3104,7 +3126,7 @@ master_task (void *cls, | |||
3104 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: | 3126 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: |
3105 | if (0 == delay.rel_value_us) | 3127 | if (0 == delay.rel_value_us) |
3106 | { | 3128 | { |
3107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3129 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3108 | "Connection to `%s' timed out, waiting for other peer to CONNECT_ACK replacement address\n", | 3130 | "Connection to `%s' timed out, waiting for other peer to CONNECT_ACK replacement address\n", |
3109 | GNUNET_i2s (&n->id)); | 3131 | GNUNET_i2s (&n->id)); |
3110 | disconnect_neighbour (n); | 3132 | disconnect_neighbour (n); |
@@ -3114,7 +3136,7 @@ master_task (void *cls, | |||
3114 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: | 3136 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: |
3115 | if (0 == delay.rel_value_us) | 3137 | if (0 == delay.rel_value_us) |
3116 | { | 3138 | { |
3117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3139 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3118 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to CONNECT on alternative address)\n", | 3140 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to CONNECT on alternative address)\n", |
3119 | GNUNET_i2s (&n->id)); | 3141 | GNUNET_i2s (&n->id)); |
3120 | disconnect_neighbour (n); | 3142 | disconnect_neighbour (n); |
@@ -3124,7 +3146,7 @@ master_task (void *cls, | |||
3124 | send_keepalive (n); | 3146 | send_keepalive (n); |
3125 | break; | 3147 | break; |
3126 | case GNUNET_TRANSPORT_PS_DISCONNECT: | 3148 | case GNUNET_TRANSPORT_PS_DISCONNECT: |
3127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3149 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3128 | "Cleaning up connection to `%s' after sending DISCONNECT\n", | 3150 | "Cleaning up connection to `%s' after sending DISCONNECT\n", |
3129 | GNUNET_i2s (&n->id)); | 3151 | GNUNET_i2s (&n->id)); |
3130 | free_neighbour (n, GNUNET_NO); | 3152 | free_neighbour (n, GNUNET_NO); |