mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
entrynodes: Error msg for missing guard descs is now more informative.
This commit is contained in:
parent
f2231306ba
commit
5352785d0c
@ -3442,9 +3442,13 @@ guards_retry_optimistic(const or_options_t *options)
|
|||||||
/**
|
/**
|
||||||
* Check if we are missing any crucial dirinfo for the guard subsystem to
|
* Check if we are missing any crucial dirinfo for the guard subsystem to
|
||||||
* work. Return NULL if everything went well, otherwise return a newly
|
* work. Return NULL if everything went well, otherwise return a newly
|
||||||
* allocated string with an informative error message. */
|
* allocated string with an informative error message. In the latter case, use
|
||||||
|
* the genreal descriptor information <b>using_mds</b>, <b>num_present</b> and
|
||||||
|
* <b>num_usable</b> to improve the error message. */
|
||||||
char *
|
char *
|
||||||
guard_selection_get_dir_info_status_str(guard_selection_t *gs)
|
guard_selection_get_dir_info_status_str(guard_selection_t *gs,
|
||||||
|
int using_mds,
|
||||||
|
int num_present, int num_usable)
|
||||||
{
|
{
|
||||||
if (!gs->primary_guards_up_to_date)
|
if (!gs->primary_guards_up_to_date)
|
||||||
entry_guards_update_primary(gs);
|
entry_guards_update_primary(gs);
|
||||||
@ -3478,8 +3482,9 @@ guard_selection_get_dir_info_status_str(guard_selection_t *gs)
|
|||||||
|
|
||||||
/* otherwise return a helpful error string */
|
/* otherwise return a helpful error string */
|
||||||
tor_asprintf(&ret_str, "We're missing descriptors for %d/%d of our "
|
tor_asprintf(&ret_str, "We're missing descriptors for %d/%d of our "
|
||||||
"primary entry guards",
|
"primary entry guards (total %sdescriptors: %d/%d).",
|
||||||
n_missing_descriptors, num_primary_to_check);
|
n_missing_descriptors, num_primary_to_check,
|
||||||
|
using_mds?"micro":"", num_present, num_usable);
|
||||||
|
|
||||||
return ret_str;
|
return ret_str;
|
||||||
}
|
}
|
||||||
@ -3487,10 +3492,12 @@ guard_selection_get_dir_info_status_str(guard_selection_t *gs)
|
|||||||
/** As guard_selection_have_enough_dir_info_to_build_circuits, but uses
|
/** As guard_selection_have_enough_dir_info_to_build_circuits, but uses
|
||||||
* the default guard selection. */
|
* the default guard selection. */
|
||||||
char *
|
char *
|
||||||
entry_guards_get_dir_info_status_str(void)
|
entry_guards_get_dir_info_status_str(int using_mds,
|
||||||
|
int num_present, int num_usable)
|
||||||
{
|
{
|
||||||
return guard_selection_get_dir_info_status_str(
|
return guard_selection_get_dir_info_status_str(get_guard_selection_info(),
|
||||||
get_guard_selection_info());
|
using_mds,
|
||||||
|
num_present, num_usable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Free one guard selection context */
|
/** Free one guard selection context */
|
||||||
|
@ -572,8 +572,11 @@ int getinfo_helper_entry_guards(control_connection_t *conn,
|
|||||||
int entries_known_but_down(const or_options_t *options);
|
int entries_known_but_down(const or_options_t *options);
|
||||||
void entries_retry_all(const or_options_t *options);
|
void entries_retry_all(const or_options_t *options);
|
||||||
|
|
||||||
char *entry_guards_get_dir_info_status_str(void);
|
char *entry_guards_get_dir_info_status_str(int using_mds,
|
||||||
char *guard_selection_get_dir_info_status_str(guard_selection_t *gs);
|
int num_present, int num_usable);
|
||||||
|
char *guard_selection_get_dir_info_status_str(guard_selection_t *gs,
|
||||||
|
int using_mds,
|
||||||
|
int num_present, int num_usable);
|
||||||
|
|
||||||
void entry_guards_free_all(void);
|
void entry_guards_free_all(void);
|
||||||
|
|
||||||
|
@ -2282,6 +2282,7 @@ update_router_have_minimum_dir_info(void)
|
|||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
int res;
|
int res;
|
||||||
|
int num_present=0, num_usable=0;
|
||||||
const or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
const networkstatus_t *consensus =
|
const networkstatus_t *consensus =
|
||||||
networkstatus_get_reasonably_live_consensus(now,usable_consensus_flavor());
|
networkstatus_get_reasonably_live_consensus(now,usable_consensus_flavor());
|
||||||
@ -2303,7 +2304,6 @@ update_router_have_minimum_dir_info(void)
|
|||||||
/* Check fraction of available paths */
|
/* Check fraction of available paths */
|
||||||
{
|
{
|
||||||
char *status = NULL;
|
char *status = NULL;
|
||||||
int num_present=0, num_usable=0;
|
|
||||||
double paths = compute_frac_paths_available(consensus, options, now,
|
double paths = compute_frac_paths_available(consensus, options, now,
|
||||||
&num_present, &num_usable,
|
&num_present, &num_usable,
|
||||||
&status);
|
&status);
|
||||||
@ -2325,7 +2325,9 @@ update_router_have_minimum_dir_info(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ /* Check entry guard dirinfo status */
|
{ /* Check entry guard dirinfo status */
|
||||||
char *guard_error = entry_guards_get_dir_info_status_str();
|
char *guard_error = entry_guards_get_dir_info_status_str(using_md,
|
||||||
|
num_present,
|
||||||
|
num_usable);
|
||||||
if (guard_error) {
|
if (guard_error) {
|
||||||
strlcpy(dir_info_status, guard_error, sizeof(dir_info_status));
|
strlcpy(dir_info_status, guard_error, sizeof(dir_info_status));
|
||||||
tor_free(guard_error);
|
tor_free(guard_error);
|
||||||
@ -2334,7 +2336,6 @@ update_router_have_minimum_dir_info(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
/* If paths have just become available in this update. */
|
/* If paths have just become available in this update. */
|
||||||
|
@ -1641,9 +1641,9 @@ test_entry_guard_manage_primary(void *arg)
|
|||||||
|
|
||||||
/* Do some dirinfo checks */
|
/* Do some dirinfo checks */
|
||||||
{
|
{
|
||||||
/* Check that we have all required dirinfo for the primaries (that's done in
|
/* Check that we have all required dirinfo for the primaries (that's done
|
||||||
* big_fake_network_setup()) */
|
* in big_fake_network_setup()) */
|
||||||
char *dir_info_str = guard_selection_get_dir_info_status_str(gs);
|
char *dir_info_str = guard_selection_get_dir_info_status_str(gs, 0, 0, 0);
|
||||||
tt_assert(!dir_info_str);
|
tt_assert(!dir_info_str);
|
||||||
|
|
||||||
/* Now artificially remove the first primary's descriptor and re-check */
|
/* Now artificially remove the first primary's descriptor and re-check */
|
||||||
@ -1652,9 +1652,10 @@ test_entry_guard_manage_primary(void *arg)
|
|||||||
/* Change the first primary's identity digest so that the mocked functions
|
/* Change the first primary's identity digest so that the mocked functions
|
||||||
* can't find its descriptor */
|
* can't find its descriptor */
|
||||||
memset(first_primary->identity, 9, sizeof(first_primary->identity));
|
memset(first_primary->identity, 9, sizeof(first_primary->identity));
|
||||||
dir_info_str = guard_selection_get_dir_info_status_str(gs);
|
dir_info_str = guard_selection_get_dir_info_status_str(gs, 1, 2, 3);
|
||||||
tt_str_op(dir_info_str, OP_EQ,
|
tt_str_op(dir_info_str, OP_EQ,
|
||||||
"We're missing descriptors for 1/2 of our primary entry guards");
|
"We're missing descriptors for 1/2 of our primary entry guards "
|
||||||
|
"(total microdescriptors: 2/3).");
|
||||||
tor_free(dir_info_str);
|
tor_free(dir_info_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user