diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-02 22:59:24 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-02 22:59:24 +0000 |
commit | ffd9516faaaa7d2a9595039d10a759bb07988b77 (patch) | |
tree | d494309d403532f898310f83fb6e75347777b0e2 /src/transport/gnunet-service-transport_validation.c | |
parent | 17aa8594c3970f4921146fa5ec3a8e81926e30f6 (diff) | |
download | gnunet-ffd9516faaaa7d2a9595039d10a759bb07988b77.tar.gz gnunet-ffd9516faaaa7d2a9595039d10a759bb07988b77.zip |
GST_validation_set_address_use does not need the session
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.c')
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index eff7570b0..b2948d086 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -691,6 +691,10 @@ revalidate_address (void *cls, | |||
691 | GNUNET_STRINGS_relative_time_to_string (blocked_for, | 691 | GNUNET_STRINGS_relative_time_to_string (blocked_for, |
692 | GNUNET_YES), | 692 | GNUNET_YES), |
693 | GST_plugins_a2s (ve->address)); | 693 | GST_plugins_a2s (ve->address)); |
694 | GNUNET_STATISTICS_update (GST_stats, | ||
695 | gettext_noop ("# validations delayed by global throttle"), | ||
696 | 1, | ||
697 | GNUNET_NO); | ||
694 | ve->revalidation_task = | 698 | ve->revalidation_task = |
695 | GNUNET_SCHEDULER_add_delayed (blocked_for, &revalidate_address, ve); | 699 | GNUNET_SCHEDULER_add_delayed (blocked_for, &revalidate_address, ve); |
696 | ve->next_validation = GNUNET_TIME_relative_to_absolute (blocked_for); | 700 | ve->next_validation = GNUNET_TIME_relative_to_absolute (blocked_for); |
@@ -756,7 +760,7 @@ find_validation_entry (const struct GNUNET_HELLO_Address *address) | |||
756 | ve = GNUNET_new (struct ValidationEntry); | 760 | ve = GNUNET_new (struct ValidationEntry); |
757 | ve->in_use = GNUNET_SYSERR; /* not defined */ | 761 | ve->in_use = GNUNET_SYSERR; /* not defined */ |
758 | ve->address = GNUNET_HELLO_address_copy (address); | 762 | ve->address = GNUNET_HELLO_address_copy (address); |
759 | ve->pong_sig_valid_until = GNUNET_TIME_absolute_get_zero_(); | 763 | ve->pong_sig_valid_until = GNUNET_TIME_UNIT_ZERO_ABS; |
760 | memset (&ve->pong_sig_cache, '\0', sizeof (struct GNUNET_CRYPTO_EddsaSignature)); | 764 | memset (&ve->pong_sig_cache, '\0', sizeof (struct GNUNET_CRYPTO_EddsaSignature)); |
761 | ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; | 765 | ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; |
762 | ve->challenge = | 766 | ve->challenge = |
@@ -780,7 +784,9 @@ find_validation_entry (const struct GNUNET_HELLO_Address *address) | |||
780 | * @param cls original HELLO message | 784 | * @param cls original HELLO message |
781 | * @param address the address | 785 | * @param address the address |
782 | * @param expiration expiration time | 786 | * @param expiration expiration time |
783 | * @return #GNUNET_OK (keep the address) | 787 | * @return #GNUNET_OK (keep the address), could return |
788 | * #GNUNET_NO (delete address, but this is ignored); | ||
789 | * #GNUNET_SYSERR would abort iteration (but we always iterate all) | ||
784 | */ | 790 | */ |
785 | static int | 791 | static int |
786 | add_valid_address (void *cls, | 792 | add_valid_address (void *cls, |
@@ -799,13 +805,6 @@ add_valid_address (void *cls, | |||
799 | GNUNET_break (0); | 805 | GNUNET_break (0); |
800 | return GNUNET_OK; /* invalid HELLO !? */ | 806 | return GNUNET_OK; /* invalid HELLO !? */ |
801 | } | 807 | } |
802 | if (0 == memcmp (&GST_my_identity, | ||
803 | &pid, | ||
804 | sizeof (struct GNUNET_PeerIdentity))) | ||
805 | { | ||
806 | /* Peerinfo returned own identity, skip validation */ | ||
807 | return GNUNET_OK; | ||
808 | } | ||
809 | if (NULL == GST_plugins_find (address->transport_name)) | 808 | if (NULL == GST_plugins_find (address->transport_name)) |
810 | { | 809 | { |
811 | /* might have been valid in the past, but we don't have that | 810 | /* might have been valid in the past, but we don't have that |
@@ -840,19 +839,28 @@ add_valid_address (void *cls, | |||
840 | /** | 839 | /** |
841 | * Function called for any HELLO known to PEERINFO. | 840 | * Function called for any HELLO known to PEERINFO. |
842 | * | 841 | * |
843 | * @param cls unused | 842 | * @param cls unused (NULL) |
844 | * @param peer id of the peer, NULL for last call | 843 | * @param peer id of the peer, NULL for last call (during iteration, |
844 | * as we are monitoring, this should never happen) | ||
845 | * @param hello hello message for the peer (can be NULL) | 845 | * @param hello hello message for the peer (can be NULL) |
846 | * @param err_msg error message | 846 | * @param err_msg error message |
847 | */ | 847 | */ |
848 | static void | 848 | static void |
849 | process_peerinfo_hello (void *cls, const struct GNUNET_PeerIdentity *peer, | 849 | process_peerinfo_hello (void *cls, |
850 | const struct GNUNET_PeerIdentity *peer, | ||
850 | const struct GNUNET_HELLO_Message *hello, | 851 | const struct GNUNET_HELLO_Message *hello, |
851 | const char *err_msg) | 852 | const char *err_msg) |
852 | { | 853 | { |
853 | GNUNET_assert (NULL != peer); | 854 | GNUNET_assert (NULL != peer); |
854 | if (NULL == hello) | 855 | if (NULL == hello) |
855 | return; | 856 | return; |
857 | if (0 == memcmp (&GST_my_identity, | ||
858 | peer, | ||
859 | sizeof (struct GNUNET_PeerIdentity))) | ||
860 | { | ||
861 | /* Peerinfo returned own identity, skip validation */ | ||
862 | return; | ||
863 | } | ||
856 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 864 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
857 | "Handling HELLO for peer `%s'\n", | 865 | "Handling HELLO for peer `%s'\n", |
858 | GNUNET_i2s (peer)); | 866 | GNUNET_i2s (peer)); |
@@ -910,7 +918,8 @@ void | |||
910 | GST_validation_stop () | 918 | GST_validation_stop () |
911 | { | 919 | { |
912 | GNUNET_CONTAINER_multipeermap_iterate (validation_map, | 920 | GNUNET_CONTAINER_multipeermap_iterate (validation_map, |
913 | &cleanup_validation_entry, NULL); | 921 | &cleanup_validation_entry, |
922 | NULL); | ||
914 | GNUNET_CONTAINER_multipeermap_destroy (validation_map); | 923 | GNUNET_CONTAINER_multipeermap_destroy (validation_map); |
915 | validation_map = NULL; | 924 | validation_map = NULL; |
916 | GNUNET_PEERINFO_notify_cancel (pnc); | 925 | GNUNET_PEERINFO_notify_cancel (pnc); |
@@ -946,7 +955,6 @@ multicast_pong (void *cls, | |||
946 | address->transport_name); | 955 | address->transport_name); |
947 | return; | 956 | return; |
948 | } | 957 | } |
949 | |||
950 | GNUNET_assert (NULL != papi->send); | 958 | GNUNET_assert (NULL != papi->send); |
951 | GNUNET_assert (NULL != papi->get_session); | 959 | GNUNET_assert (NULL != papi->get_session); |
952 | session = papi->get_session(papi->cls, address); | 960 | session = papi->get_session(papi->cls, address); |
@@ -965,7 +973,6 @@ multicast_pong (void *cls, | |||
965 | GST_neighbours_notify_data_sent (address, | 973 | GST_neighbours_notify_data_sent (address, |
966 | session, | 974 | session, |
967 | pong->header.size); | 975 | pong->header.size); |
968 | |||
969 | } | 976 | } |
970 | 977 | ||
971 | 978 | ||
@@ -996,7 +1003,6 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
996 | size_t len_address; | 1003 | size_t len_address; |
997 | size_t len_plugin; | 1004 | size_t len_plugin; |
998 | ssize_t ret; | 1005 | ssize_t ret; |
999 | int buggy = GNUNET_NO; | ||
1000 | struct GNUNET_HELLO_Address address; | 1006 | struct GNUNET_HELLO_Address address; |
1001 | 1007 | ||
1002 | if (ntohs (hdr->size) < sizeof (struct TransportPingMessage)) | 1008 | if (ntohs (hdr->size) < sizeof (struct TransportPingMessage)) |
@@ -1068,7 +1074,10 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
1068 | return GNUNET_SYSERR; | 1074 | return GNUNET_SYSERR; |
1069 | } | 1075 | } |
1070 | GNUNET_free (plugin_name); | 1076 | GNUNET_free (plugin_name); |
1071 | if (GNUNET_OK != papi->check_address (papi->cls, addrend, len_address)) | 1077 | if (GNUNET_OK != |
1078 | papi->check_address (papi->cls, | ||
1079 | addrend, | ||
1080 | len_address)) | ||
1072 | { | 1081 | { |
1073 | GNUNET_STATISTICS_update (GST_stats, | 1082 | GNUNET_STATISTICS_update (GST_stats, |
1074 | gettext_noop | 1083 | gettext_noop |
@@ -1090,22 +1099,16 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
1090 | GST_plugins_a2s (&address)); | 1099 | GST_plugins_a2s (&address)); |
1091 | } | 1100 | } |
1092 | 1101 | ||
1093 | if (GNUNET_YES != GST_hello_test_address (&address, &sig_cache, &sig_cache_exp)) | 1102 | if (GNUNET_YES != |
1103 | GST_hello_test_address (&address, | ||
1104 | &sig_cache, | ||
1105 | &sig_cache_exp)) | ||
1094 | { | 1106 | { |
1095 | if (GNUNET_NO == buggy) | 1107 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1096 | { | 1108 | _("Not confirming PING from peer `%s' with address `%s' since I cannot confirm having this address.\n"), |
1097 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1109 | GNUNET_i2s (sender), |
1098 | _("Not confirming PING from peer `%s' with address `%s' since I cannot confirm having this address.\n"), | 1110 | GST_plugins_a2s (&address)); |
1099 | GNUNET_i2s (sender), | 1111 | return GNUNET_SYSERR; |
1100 | GST_plugins_a2s (&address)); | ||
1101 | return GNUNET_SYSERR; | ||
1102 | } | ||
1103 | else | ||
1104 | { | ||
1105 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1106 | _("Received a PING message with validation bug from `%s'\n"), | ||
1107 | GNUNET_i2s (sender)); | ||
1108 | } | ||
1109 | } | 1112 | } |
1110 | } | 1113 | } |
1111 | else | 1114 | else |
@@ -1166,7 +1169,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
1166 | } | 1169 | } |
1167 | pong->signature = *sig_cache; | 1170 | pong->signature = *sig_cache; |
1168 | 1171 | ||
1169 | GNUNET_assert (sender_address != NULL); | 1172 | GNUNET_assert (NULL != sender_address); |
1170 | 1173 | ||
1171 | /* first see if the session we got this PING from can be used to transmit | 1174 | /* first see if the session we got this PING from can be used to transmit |
1172 | * a response reliably */ | 1175 | * a response reliably */ |
@@ -1286,7 +1289,10 @@ add_valid_peer_address (void *cls, | |||
1286 | if (GNUNET_YES == ve->copied) | 1289 | if (GNUNET_YES == ve->copied) |
1287 | return GNUNET_SYSERR; /* Done */ | 1290 | return GNUNET_SYSERR; /* Done */ |
1288 | ve->copied = GNUNET_YES; | 1291 | ve->copied = GNUNET_YES; |
1289 | return GNUNET_HELLO_add_address (ve->address, ve->valid_until, buf, max); | 1292 | return GNUNET_HELLO_add_address (ve->address, |
1293 | ve->valid_until, | ||
1294 | buf, | ||
1295 | max); | ||
1290 | } | 1296 | } |
1291 | 1297 | ||
1292 | 1298 | ||
@@ -1607,14 +1613,12 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, | |||
1607 | * Based on this, the validation module will measure latency for the | 1613 | * Based on this, the validation module will measure latency for the |
1608 | * address more or less often. | 1614 | * address more or less often. |
1609 | * | 1615 | * |
1610 | * @param address the address | 1616 | * @param address the address that we are now using (or not) |
1611 | * @param session the session | ||
1612 | * @param in_use #GNUNET_YES if we are now using the address for a connection, | 1617 | * @param in_use #GNUNET_YES if we are now using the address for a connection, |
1613 | * #GNUNET_NO if we are no longer using the address for a connection | 1618 | * #GNUNET_NO if we are no longer using the address for a connection |
1614 | */ | 1619 | */ |
1615 | void | 1620 | void |
1616 | GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, | 1621 | GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, |
1617 | struct Session *session, | ||
1618 | int in_use) | 1622 | int in_use) |
1619 | { | 1623 | { |
1620 | struct ValidationEntry *ve; | 1624 | struct ValidationEntry *ve; |
@@ -1628,13 +1632,10 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, | |||
1628 | GNUNET_break (0); | 1632 | GNUNET_break (0); |
1629 | return; | 1633 | return; |
1630 | } | 1634 | } |
1631 | if (NULL != address) | 1635 | ve = find_validation_entry (address); |
1632 | ve = find_validation_entry (address); | ||
1633 | else | ||
1634 | ve = NULL; /* FIXME: lookup based on session... */ | ||
1635 | if (NULL == ve) | 1636 | if (NULL == ve) |
1636 | { | 1637 | { |
1637 | /* this can happen for inbound connections (sender_address_len == 0); */ | 1638 | GNUNET_break (0); |
1638 | return; | 1639 | return; |
1639 | } | 1640 | } |
1640 | if (ve->in_use == in_use) | 1641 | if (ve->in_use == in_use) |