address validation subsystem More...
#include "platform.h"
#include "gnunet-service-transport_ats.h"
#include "gnunet-service-transport_hello.h"
#include "gnunet-service-transport_neighbours.h"
#include "gnunet-service-transport_plugins.h"
#include "gnunet-service-transport_validation.h"
#include "gnunet-service-transport.h"
#include "gnunet_hello_lib.h"
#include "gnunet_ats_service.h"
#include "gnunet_peerinfo_service.h"
#include "gnunet_signatures.h"
Go to the source code of this file.
Data Structures | |
struct | TransportPingMessage |
Message used to ask a peer to validate receipt (to check an address from a HELLO). More... | |
struct | TransportPongMessage |
Message used to validate a HELLO. More... | |
struct | ValidationEntry |
Information about an address under validation. More... | |
struct | ValidationEntryMatchContext |
Context for the validation entry match function. More... | |
struct | IteratorContext |
Closure for the neighbours_iterate() function. More... | |
Macros | |
#define | PONG_SIGNATURE_LIFETIME |
How long is a PONG signature valid? We'll recycle a signature until 1/4 of this time is remaining. More... | |
#define | HELLO_ADDRESS_EXPIRATION |
After how long do we expire an address in a HELLO that we just validated? This value is also used for our own addresses when we create a HELLO. More... | |
#define | UNVALIDATED_PING_KEEPALIVE |
How often do we allow PINGing an address that we have not yet validated? This also determines how long we track an address that we cannot validate (because after this time we can destroy the validation record). More... | |
#define | VALIDATED_PING_FREQUENCY |
How often do we PING an address that we have successfully validated in the past but are not actively using? Should be (significantly) smaller than HELLO_ADDRESS_EXPIRATION. More... | |
#define | CONNECTED_PING_FREQUENCY |
How often do we PING an address that we are currently using? More... | |
#define | ACCEPTABLE_PING_DELAY |
How much delay is acceptable for sending the PING or PONG? More... | |
#define | VALIDATION_MAP_SIZE 256 |
Size of the validation map hashmap. More... | |
#define | PING_PRIORITY 2 |
Priority to use for PINGs. More... | |
#define | PONG_PRIORITY 4 |
Priority to use for PONGs. More... | |
Enumerations | |
enum | GNUNET_TRANSPORT_ValidationState { GNUNET_TRANSPORT_VS_NONE , GNUNET_TRANSPORT_VS_NEW , GNUNET_TRANSPORT_VS_UPDATE , GNUNET_TRANSPORT_VS_TIMEOUT , GNUNET_TRANSPORT_VS_REMOVE } |
Current state of a validation process. More... | |
Functions | |
static void | publish_ve_stat_update () |
Provide an update on the validation_map map size to statistics. More... | |
static int | validation_entry_match (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Iterate over validation entries until a matching one is found. More... | |
static void | validation_entry_changed (struct ValidationEntry *ve, enum GNUNET_TRANSPORT_ValidationState state) |
A validation entry changed. More... | |
static int | cleanup_validation_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Iterate over validation entries and free them. More... | |
static void | timeout_hello_validation (void *cls) |
Address validation cleanup task. More... | |
static void | transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_HELLO_Address *address_null, struct GNUNET_ATS_Session *session_null, int result) |
Function called with the result from blacklisting. More... | |
static void | revalidate_address (void *cls) |
Do address validation again to keep address valid. More... | |
static struct ValidationEntry * | find_validation_entry (const struct GNUNET_HELLO_Address *address) |
Find a ValidationEntry entry for the given neighbour that matches the given address and transport. More... | |
static int | add_valid_address (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration) |
Iterator which adds the given address to the set of validated addresses. More... | |
static void | process_peerinfo_hello (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
Function called for any HELLO known to PEERINFO. More... | |
void | GST_validation_start (unsigned int max_fds) |
Start the validation subsystem. More... | |
void | GST_validation_stop () |
Stop the validation subsystem. More... | |
static void | multicast_pong (void *cls, struct GNUNET_TIME_Absolute valid_until, struct GNUNET_TIME_Absolute validation_block, const struct GNUNET_HELLO_Address *address) |
Send the given PONG to the given address. More... | |
int | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr, const struct GNUNET_HELLO_Address *sender_address, struct GNUNET_ATS_Session *session) |
We've received a PING. More... | |
void | GST_validation_handle_address (const struct GNUNET_HELLO_Address *address) |
Validate an individual address. More... | |
static int | validate_address_iterator (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration) |
Iterator callback to go over all addresses and try to validate them (unless blocked or already validated). More... | |
static ssize_t | add_valid_peer_address (void *cls, size_t max, void *buf) |
Add the validated peer address to the HELLO. More... | |
int | GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr) |
We've received a PONG. More... | |
int | GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello) |
We've received a HELLO, check which addresses are new and trigger validation. More... | |
static int | iterate_addresses (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Call the callback in the closure for each validation entry. More... | |
void | GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, GST_ValidationAddressCallback cb, void *cb_cls) |
Call the given function for each address for the given target. More... | |
void | GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, int in_use) |
Update if we are using an address for a connection actively right now. More... | |
Variables | |
static struct GNUNET_CONTAINER_MultiPeerMap * | validation_map |
Map of PeerIdentities to 'struct ValidationEntry*'s (addresses of the given peer that we are currently validating, have validated or are blocked from re-validation for a while). More... | |
static struct GNUNET_PEERINFO_NotifyContext * | pnc |
Context for peerinfo iteration. More... | |
static struct GNUNET_TIME_Relative | validation_delay |
Minimum delay between to validations. More... | |
static unsigned int | validations_running |
Number of validations running; any PING that was not yet matched by a PONG and for which we have not yet hit the timeout is considered a running 'validation'. More... | |
static unsigned int | validations_fast_start_threshold |
Validition fast start threshold. More... | |
static struct GNUNET_TIME_Absolute | validation_next |
When is next validation allowed. More... | |
address validation subsystem
Definition in file gnunet-service-transport_validation.c.
#define PONG_SIGNATURE_LIFETIME |
How long is a PONG signature valid? We'll recycle a signature until 1/4 of this time is remaining.
PONGs should expire so that if our external addresses change an adversary cannot replay them indefinitely. OTOH, we don't want to spend too much time generating PONG signatures, so they must have some lifetime to reduce our CPU usage.
Definition at line 91 of file gnunet-service-transport_validation.c.
#define HELLO_ADDRESS_EXPIRATION |
After how long do we expire an address in a HELLO that we just validated? This value is also used for our own addresses when we create a HELLO.
Definition at line 99 of file gnunet-service-transport_validation.c.
#define UNVALIDATED_PING_KEEPALIVE |
How often do we allow PINGing an address that we have not yet validated? This also determines how long we track an address that we cannot validate (because after this time we can destroy the validation record).
Definition at line 108 of file gnunet-service-transport_validation.c.
#define VALIDATED_PING_FREQUENCY |
How often do we PING an address that we have successfully validated in the past but are not actively using? Should be (significantly) smaller than HELLO_ADDRESS_EXPIRATION.
Definition at line 116 of file gnunet-service-transport_validation.c.
#define CONNECTED_PING_FREQUENCY |
How often do we PING an address that we are currently using?
Definition at line 122 of file gnunet-service-transport_validation.c.
#define ACCEPTABLE_PING_DELAY |
How much delay is acceptable for sending the PING or PONG?
Definition at line 128 of file gnunet-service-transport_validation.c.
#define VALIDATION_MAP_SIZE 256 |
Size of the validation map hashmap.
Definition at line 134 of file gnunet-service-transport_validation.c.
#define PING_PRIORITY 2 |
Priority to use for PINGs.
Definition at line 139 of file gnunet-service-transport_validation.c.
#define PONG_PRIORITY 4 |
Priority to use for PONGs.
Definition at line 144 of file gnunet-service-transport_validation.c.
Current state of a validation process.
FIXME: what state is used to indicate that a validation was successful? If that is clarified/determined, "UGH" in ~gnunetpeerinfogtk.c:1103 should be resolved.
Enumerator | |
---|---|
GNUNET_TRANSPORT_VS_NONE | Undefined state. Used for final callback indicating operation done |
GNUNET_TRANSPORT_VS_NEW | Fresh validation entry. Entry was just created, no validation process was executed |
GNUNET_TRANSPORT_VS_UPDATE | Updated validation entry. This is an update for an existing validation entry |
GNUNET_TRANSPORT_VS_TIMEOUT | Timeout for validation entry. A timeout occurred during the validation process |
GNUNET_TRANSPORT_VS_REMOVE | Validation entry is removed. The validation entry is getting removed due to a failed validation |
Definition at line 45 of file gnunet-service-transport_validation.c.
|
static |
Provide an update on the validation_map
map size to statistics.
This function should be called whenever the validation_map
is changed.
Definition at line 383 of file gnunet-service-transport_validation.c.
References gettext_noop, GNUNET_CONTAINER_multipeermap_size(), GNUNET_NO, GNUNET_STATISTICS_set(), GST_stats, and validation_map.
Referenced by cleanup_validation_entry(), and find_validation_entry().
|
static |
Iterate over validation entries until a matching one is found.
cls | the struct ValidationEntryMatchContext * |
key | peer identity (unused) |
value | a struct ValidationEntry * to match |
Definition at line 402 of file gnunet-service-transport_validation.c.
References ValidationEntry::address, ValidationEntryMatchContext::address, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_YES, value, and ValidationEntryMatchContext::ve.
Referenced by find_validation_entry().
|
static |
A validation entry changed.
Update the state and notify monitors.
ve | validation entry that changed |
state | new state |
Definition at line 427 of file gnunet-service-transport_validation.c.
References state, and ValidationEntry::state.
Referenced by add_valid_address(), cleanup_validation_entry(), find_validation_entry(), GST_validation_handle_pong(), and transmit_ping_if_allowed().
|
static |
Iterate over validation entries and free them.
cls | (unused) |
key | peer identity (unused) |
value | a struct ValidationEntry * to clean up |
Definition at line 443 of file gnunet-service-transport_validation.c.
References ValidationEntry::address, ValidationEntry::bc, ValidationEntry::expecting_pong, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_HELLO_address_free, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_REMOVE, GNUNET_YES, GST_ats_expire_address(), GST_ats_is_known_no_session(), GST_blacklist_test_cancel(), GST_stats, ValidationEntry::known_to_ats, ValidationEntry::next_validation, GNUNET_HELLO_Address::peer, publish_ve_stat_update(), ValidationEntry::revalidation_task, ValidationEntry::timeout_task, ValidationEntry::valid_until, validation_entry_changed(), validation_map, validations_running, and value.
Referenced by GST_validation_stop(), timeout_hello_validation(), and transmit_ping_if_allowed().
|
static |
Address validation cleanup task.
Assesses if the record is no longer valid and then possibly triggers its removal.
cls | the struct ValidationEntry |
Definition at line 505 of file gnunet-service-transport_validation.c.
References ValidationEntry::address, cleanup_validation_entry(), gettext_noop, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_max(), GST_stats, max, GNUNET_HELLO_Address::peer, GNUNET_TIME_Relative::rel_value_us, ValidationEntry::revalidation_block, ValidationEntry::timeout_task, and ValidationEntry::valid_until.
Referenced by find_validation_entry().
|
static |
Function called with the result from blacklisting.
Send a PING to the other peer if a communication is allowed.
cls | our struct ValidationEntry |
pid | identity of the other peer |
address_null | address associated with the request, always NULL |
session_null | session associated with the request, always NULL |
result | GNUNET_OK if the connection is allowed, GNUNET_NO if not, GNUNET_SYSERR if operation was aborted |
Definition at line 553 of file gnunet-service-transport_validation.c.
References ACCEPTABLE_PING_DELAY, address, GNUNET_HELLO_Address::address, ValidationEntry::address, GNUNET_HELLO_Address::address_length, ValidationEntry::bc, ValidationEntry::challenge, cleanup_validation_entry(), GNUNET_TRANSPORT_PluginFunctions::cls, ValidationEntry::expecting_pong, GNUNET_TRANSPORT_PluginFunctions::get_network, GNUNET_TRANSPORT_PluginFunctions::get_session, gettext_noop, GNUNET_ALIGN, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_PING, GNUNET_NO, GNUNET_NT_UNSPECIFIED, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_max(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_VS_UPDATE, GNUNET_YES, GST_hello_get(), GST_neighbours_notify_data_sent(), GST_plugins_a2s(), GST_plugins_find(), GST_stats, ValidationEntry::network, pid, ping(), PING_PRIORITY, result, ret, GNUNET_TRANSPORT_PluginFunctions::send, ValidationEntry::send_time, GNUNET_MessageHeader::size, GNUNET_HELLO_Address::transport_name, validation_delay, validation_entry_changed(), validation_next, and validations_running.
Referenced by revalidate_address().
|
static |
Do address validation again to keep address valid.
cls | the struct ValidationEntry |
Definition at line 695 of file gnunet-service-transport_validation.c.
References ValidationEntry::address, ValidationEntry::bc, CONNECTED_PING_FREQUENCY, delay, gettext_noop, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_add(), GNUNET_TIME_relative_min(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_MICROSECONDS, GNUNET_YES, GST_blacklist_test_allowed(), GST_blacklist_test_cancel(), GST_plugins_a2s(), GST_stats, ValidationEntry::in_use, ValidationEntry::next_validation, GNUNET_HELLO_Address::peer, GNUNET_TIME_Relative::rel_value_us, ValidationEntry::revalidation_block, ValidationEntry::revalidation_task, transmit_ping_if_allowed(), GNUNET_HELLO_Address::transport_name, UNVALIDATED_PING_KEEPALIVE, ValidationEntry::valid_until, VALIDATED_PING_FREQUENCY, validation_next, validations_fast_start_threshold, and validations_running.
Referenced by add_valid_address(), and GST_validation_handle_address().
|
static |
Find a ValidationEntry entry for the given neighbour that matches the given address and transport.
If none exists, create one (but without starting any validation).
address | address to find |
Definition at line 822 of file gnunet-service-transport_validation.c.
References address, ValidationEntry::address, ValidationEntryMatchContext::address, ValidationEntry::challenge, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_HELLO_address_copy(), GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NEW, GST_ats_is_known_no_session(), ValidationEntry::in_use, ValidationEntry::latency, ValidationEntry::pong_sig_cache, ValidationEntry::pong_sig_valid_until, publish_ve_stat_update(), timeout_hello_validation(), ValidationEntry::timeout_task, UNVALIDATED_PING_KEEPALIVE, validation_entry_changed(), validation_entry_match(), validation_map, and ValidationEntryMatchContext::ve.
Referenced by add_valid_address(), GST_validation_handle_address(), and GST_validation_handle_pong().
|
static |
Iterator which adds the given address to the set of validated addresses.
cls | original HELLO message |
address | the address |
expiration | expiration time |
Definition at line 873 of file gnunet-service-transport_validation.c.
References address, ValidationEntry::address, GNUNET_TRANSPORT_PluginFunctions::address_to_string, GNUNET_TRANSPORT_PluginFunctions::cls, GNUNET_ATS_Properties::delay, expiration, find_validation_entry(), GNUNET_TRANSPORT_PluginFunctions::get_network_for_address, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_HELLO_get_id(), GNUNET_i2s(), GNUNET_log, GNUNET_NT_UNSPECIFIED, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_max(), GNUNET_TIME_relative_divide(), GNUNET_TRANSPORT_VS_UPDATE, GNUNET_YES, GST_ats_add_address(), GST_ats_is_known_no_session(), GST_plugins_a2s(), GST_plugins_find(), ValidationEntry::known_to_ats, ValidationEntry::latency, ValidationEntry::network, ValidationEntry::next_validation, pid, revalidate_address(), ValidationEntry::revalidation_task, GNUNET_ATS_Properties::scope, ValidationEntry::valid_until, and validation_entry_changed().
Referenced by process_peerinfo_hello().
|
static |
Function called for any HELLO known to PEERINFO.
cls | unused (NULL) |
peer | id of the peer, NULL for last call (during iteration, as we are monitoring, this should never happen) |
hello | hello message for the peer (can be NULL) |
err_msg | error message |
Definition at line 951 of file gnunet-service-transport_validation.c.
References add_valid_address(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_iterate_addresses(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GST_my_identity, and peer.
Referenced by GST_validation_start().
void GST_validation_start | ( | unsigned int | max_fds | ) |
Start the validation subsystem.
max_fds | maximum number of fds to use |
Initialization for validation throttling
We have a maximum number max_fds of connections we can use for validation We monitor the number of validations in parallel and start to throttle it when doing to many validations in parallel: if (running validations < (max_fds / 2))
Definition at line 982 of file gnunet-service-transport_validation.c.
References gettext_noop, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_multipeermap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_PEERINFO_notify(), GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_YES, GST_cfg, GST_stats, pnc, process_peerinfo_hello(), GNUNET_TIME_Relative::rel_value_us, validation_delay, validation_map, VALIDATION_MAP_SIZE, validation_next, validations_fast_start_threshold, and validations_running.
Referenced by run().
void GST_validation_stop | ( | void | ) |
Stop the validation subsystem.
Definition at line 1019 of file gnunet-service-transport_validation.c.
References cleanup_validation_entry(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_PEERINFO_notify_cancel(), pnc, and validation_map.
Referenced by shutdown_task().
|
static |
Send the given PONG to the given address.
cls | the PONG message |
valid_until | is ZERO if we never validated the address, otherwise a time up to when we consider it (or was) valid |
validation_block | is FOREVER if the address is for an unsupported plugin (from PEERINFO) is ZERO if the address is considered valid (no validation needed) otherwise a time in the future if we're currently denying re-validation |
address | target address |
Definition at line 1042 of file gnunet-service-transport_validation.c.
References ACCEPTABLE_PING_DELAY, address, GNUNET_TRANSPORT_PluginFunctions::cls, GNUNET_TRANSPORT_PluginFunctions::get_session, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GST_ats_new_session(), GST_neighbours_notify_data_sent(), GST_plugins_find(), pong(), PONG_PRIORITY, and GNUNET_TRANSPORT_PluginFunctions::send.
Referenced by GST_validation_handle_ping().
int GST_validation_handle_ping | ( | const struct GNUNET_PeerIdentity * | sender, |
const struct GNUNET_MessageHeader * | hdr, | ||
const struct GNUNET_HELLO_Address * | sender_address, | ||
struct GNUNET_ATS_Session * | session | ||
) |
We've received a PING.
If appropriate, generate a PONG.
sender | peer sending the PING |
hdr | the PING |
sender_address | the sender address as we got it |
session | session we got the PING from |
Definition at line 1090 of file gnunet-service-transport_validation.c.
References _, ACCEPTABLE_PING_DELAY, address, GNUNET_TRANSPORT_PluginFunctions::check_address, GNUNET_TRANSPORT_PluginFunctions::cls, GNUNET_TRANSPORT_PluginFunctions::get_session, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CRYPTO_eddsa_sign_(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_i2s(), GNUNET_i2s_full(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_PONG, GNUNET_NO, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, GNUNET_snprintf(), GNUNET_STATISTICS_update(), GNUNET_strdup, GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, GST_hello_test_address(), GST_my_identity, GST_my_private_key, GST_neighbours_notify_data_sent(), GST_plugins_a2s(), GST_plugins_find(), GST_stats, GST_validation_get_addresses(), multicast_pong(), ping(), plugin_name, pong(), PONG_PRIORITY, PONG_SIGNATURE_LIFETIME, GNUNET_TIME_Relative::rel_value_us, ret, GNUNET_TRANSPORT_PluginFunctions::send, and GNUNET_MessageHeader::size.
void GST_validation_handle_address | ( | const struct GNUNET_HELLO_Address * | address | ) |
Validate an individual address.
address | address we should try to validate |
Definition at line 1356 of file gnunet-service-transport_validation.c.
References address, ValidationEntry::address, find_validation_entry(), GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_add_now(), GST_plugins_a2s(), GST_plugins_find(), GNUNET_HELLO_Address::peer, revalidate_address(), and ValidationEntry::revalidation_task.
Referenced by plugin_env_session_start_bl_check_cont(), and validate_address_iterator().
|
static |
Iterator callback to go over all addresses and try to validate them (unless blocked or already validated).
cls | NULL |
address | the address |
expiration | expiration time |
Definition at line 1399 of file gnunet-service-transport_validation.c.
References address, expiration, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, GNUNET_TIME_absolute_get_remaining(), and GST_validation_handle_address().
Referenced by GST_validation_handle_hello().
|
static |
Add the validated peer address to the HELLO.
cls | the struct ValidationEntry * with the validated address |
max | space in buf |
buf | where to add the address |
Definition at line 1424 of file gnunet-service-transport_validation.c.
References ValidationEntry::address, buf, ValidationEntry::copied, GNUNET_HELLO_add_address(), GNUNET_SYSERR, GNUNET_YES, max, and ValidationEntry::valid_until.
Referenced by GST_validation_handle_pong().
int GST_validation_handle_pong | ( | const struct GNUNET_PeerIdentity * | sender, |
const struct GNUNET_MessageHeader * | hdr | ||
) |
We've received a PONG.
Check if it matches a pending PING and mark the respective address as confirmed.
sender | peer sending the PONG |
hdr | the PONG |
Definition at line 1449 of file gnunet-service-transport_validation.c.
References add_valid_peer_address(), address, ValidationEntry::address, TransportPongMessage::addrlen, ValidationEntry::copied, GNUNET_ATS_Properties::delay, ValidationEntry::expecting_pong, find_validation_entry(), gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CRYPTO_eddsa_verify_(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_HELLO_create(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_NT_UNSPECIFIED, GNUNET_OK, GNUNET_PEERINFO_add_peer(), GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_VS_UPDATE, GNUNET_YES, GST_ats_add_address(), GST_ats_is_known_no_session(), GST_ats_update_delay(), GST_my_identity, GST_peerinfo, GST_plugins_a2s(), GST_plugins_find(), GST_stats, HELLO_ADDRESS_EXPIRATION, ValidationEntry::known_to_ats, ValidationEntry::latency, ValidationEntry::network, GNUNET_HELLO_Address::peer, pong(), ValidationEntry::pong_sig_cache, ValidationEntry::pong_sig_valid_until, GNUNET_PeerIdentity::public_key, GNUNET_TIME_Relative::rel_value_us, GNUNET_ATS_Properties::scope, ValidationEntry::send_time, GNUNET_MessageHeader::size, size, ValidationEntry::valid_until, validation_entry_changed(), and validations_running.
int GST_validation_handle_hello | ( | const struct GNUNET_MessageHeader * | hello | ) |
We've received a HELLO, check which addresses are new and trigger validation.
hello | the HELLO we received |
Definition at line 1671 of file gnunet-service-transport_validation.c.
References GNUNET_assert, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_get_id(), GNUNET_HELLO_is_friend_only(), GNUNET_HELLO_iterate_addresses(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GST_my_identity, pid, GNUNET_MessageHeader::size, and validate_address_iterator().
Referenced by handle_client_hello().
|
static |
Call the callback in the closure for each validation entry.
cls | the struct IteratorContext |
key | the peer's identity |
value | the struct ValidationEntry |
Definition at line 1737 of file gnunet-service-transport_validation.c.
References ValidationEntry::address, IteratorContext::cb, IteratorContext::cb_cls, GNUNET_OK, ValidationEntry::revalidation_block, ValidationEntry::valid_until, and value.
Referenced by GST_validation_get_addresses().
void GST_validation_get_addresses | ( | const struct GNUNET_PeerIdentity * | target, |
GST_ValidationAddressCallback | cb, | ||
void * | cb_cls | ||
) |
Call the given function for each address for the given target.
Can either give a snapshot (synchronous API) or be continuous.
target | peer information is requested for |
cb | function to call; will not be called after this function returns |
cb_cls | closure for cb |
Definition at line 1761 of file gnunet-service-transport_validation.c.
References IteratorContext::cb, IteratorContext::cb_cls, GNUNET_CONTAINER_multipeermap_get_multiple(), iterate_addresses(), and validation_map.
Referenced by GST_validation_handle_ping().
void GST_validation_set_address_use | ( | const struct GNUNET_HELLO_Address * | address, |
int | in_use | ||
) |
Update if we are using an address for a connection actively right now.
Based on this, the validation module will measure latency for the address more or less often.
address | the address that we are now using (or not) |
in_use | GNUNET_YES if we are now using the address for a connection, GNUNET_NO if we are no longer using the address for a connection |
Definition at line 1785 of file gnunet-service-transport_validation.c.
Referenced by free_address(), and set_primary_address().
|
static |
Map of PeerIdentities to 'struct ValidationEntry*'s (addresses of the given peer that we are currently validating, have validated or are blocked from re-validation for a while).
Definition at line 330 of file gnunet-service-transport_validation.c.
Referenced by cleanup_validation_entry(), find_validation_entry(), GST_validation_get_addresses(), GST_validation_start(), GST_validation_stop(), and publish_ve_stat_update().
|
static |
Context for peerinfo iteration.
Definition at line 335 of file gnunet-service-transport_validation.c.
Referenced by GST_validation_start(), and GST_validation_stop().
|
static |
Minimum delay between to validations.
Definition at line 335 of file gnunet-service-transport_validation.c.
Referenced by GST_validation_start(), and transmit_ping_if_allowed().
|
static |
Number of validations running; any PING that was not yet matched by a PONG and for which we have not yet hit the timeout is considered a running 'validation'.
Definition at line 347 of file gnunet-service-transport_validation.c.
Referenced by cleanup_validation_entry(), GST_validation_handle_pong(), GST_validation_start(), revalidate_address(), and transmit_ping_if_allowed().
|
static |
Validition fast start threshold.
Definition at line 352 of file gnunet-service-transport_validation.c.
Referenced by GST_validation_start(), and revalidate_address().
|
static |
When is next validation allowed.
Definition at line 352 of file gnunet-service-transport_validation.c.
Referenced by GST_validation_start(), revalidate_address(), and transmit_ping_if_allowed().