mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
prop224: Recompute all HSDir indices when we enter overlap mode.
When we enter overlap mode we start using the next hsdir index of relays. However, we only compute the next hsdir index of relays when we receive a consensus or their descriptor. This means that there is a window of time between entering the overlap period and fetching the consensus where relays have their next hsdir index uninitialized. This patch fixes this by recomputing all hsdir indices when we first enter the overlap period.
This commit is contained in:
parent
7823c98a38
commit
3e593f09ad
@ -1739,6 +1739,13 @@ rotate_all_descriptors(time_t now)
|
|||||||
* it in order to make sure we don't rotate at next check. */
|
* it in order to make sure we don't rotate at next check. */
|
||||||
service->state.in_overlap_period = 1;
|
service->state.in_overlap_period = 1;
|
||||||
|
|
||||||
|
/* We just entered overlap period: recompute all HSDir indices. We need to
|
||||||
|
* do this otherwise nodes can get stuck with old HSDir indices until we
|
||||||
|
* fetch a new consensus, and we might need to reupload our desc before
|
||||||
|
* that. */
|
||||||
|
/* XXX find a better place than rotate_all_descriptors() to do this */
|
||||||
|
nodelist_recompute_all_hsdir_indices();
|
||||||
|
|
||||||
/* If we have a next descriptor lined up, rotate the descriptors so that it
|
/* If we have a next descriptor lined up, rotate the descriptors so that it
|
||||||
* becomes current. */
|
* becomes current. */
|
||||||
if (service->desc_next) {
|
if (service->desc_next) {
|
||||||
|
@ -238,6 +238,27 @@ node_set_hsdir_index(node_t *node, const networkstatus_t *ns)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Recompute all node hsdir indices. */
|
||||||
|
void
|
||||||
|
nodelist_recompute_all_hsdir_indices(void)
|
||||||
|
{
|
||||||
|
networkstatus_t *consensus;
|
||||||
|
if (!the_nodelist) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get a live consensus. Abort if not found */
|
||||||
|
consensus = networkstatus_get_live_consensus(approx_time());
|
||||||
|
if (!consensus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Recompute all hsdir indices */
|
||||||
|
SMARTLIST_FOREACH_BEGIN(the_nodelist->nodes, node_t *, node) {
|
||||||
|
node_set_hsdir_index(node, consensus);
|
||||||
|
} SMARTLIST_FOREACH_END(node);
|
||||||
|
}
|
||||||
|
|
||||||
/** Called when a node's address changes. */
|
/** Called when a node's address changes. */
|
||||||
static void
|
static void
|
||||||
node_addrs_changed(node_t *node)
|
node_addrs_changed(node_t *node)
|
||||||
|
@ -28,6 +28,8 @@ void nodelist_remove_routerinfo(routerinfo_t *ri);
|
|||||||
void nodelist_purge(void);
|
void nodelist_purge(void);
|
||||||
smartlist_t *nodelist_find_nodes_with_microdesc(const microdesc_t *md);
|
smartlist_t *nodelist_find_nodes_with_microdesc(const microdesc_t *md);
|
||||||
|
|
||||||
|
void nodelist_recompute_all_hsdir_indices(void);
|
||||||
|
|
||||||
void nodelist_free_all(void);
|
void nodelist_free_all(void);
|
||||||
void nodelist_assert_ok(void);
|
void nodelist_assert_ok(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user