Update descriptor ID when it changes in rend_data

When we have a new descriptor ID for an onion address request, change it in
the rend_data_t object and purge the old one from the last hid serv request
cache.

Signed-off-by: David Goulet <dgoulet@ev0ke.net>
This commit is contained in:
David Goulet 2015-04-28 10:22:14 -04:00 committed by Nick Mathewson
parent d33327ec22
commit a9b9f6d90f
2 changed files with 17 additions and 10 deletions

View File

@ -792,8 +792,7 @@ end:
* On success, 1 is returned. If no hidden service is left to ask, return 0.
* On error, -1 is returned. */
static int
fetch_v2_desc_by_addr(const rend_data_t *query,
smartlist_t *hsdirs)
fetch_v2_desc_by_addr(rend_data_t *query, smartlist_t *hsdirs)
{
char descriptor_id[DIGEST_LEN];
int replicas_left_to_try[REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS];
@ -823,6 +822,16 @@ fetch_v2_desc_by_addr(const rend_data_t *query,
goto end;
}
if (tor_memcmp(descriptor_id, query->descriptor_id[chosen_replica],
sizeof(descriptor_id)) != 0) {
/* Not equal from what we currently have so purge the last hid serv
* request cache and update the descriptor ID with the new value. */
purge_hid_serv_from_last_hid_serv_requests(
query->descriptor_id[chosen_replica]);
memcpy(query->descriptor_id[chosen_replica], descriptor_id,
sizeof(query->descriptor_id[chosen_replica]));
}
/* Trigger the fetch with the computed descriptor ID. */
ret = fetch_v2_desc_by_descid(descriptor_id, query, hsdirs);
if (ret != 0) {
@ -849,8 +858,7 @@ end:
* On success, 1 is returned. If no hidden service is left to ask, return 0.
* On error, -1 is returned. */
int
rend_client_fetch_v2_desc(const rend_data_t *query,
smartlist_t *hsdirs)
rend_client_fetch_v2_desc(rend_data_t *query, smartlist_t *hsdirs)
{
int ret;
@ -877,7 +885,7 @@ error:
* one (possibly) working introduction point in it, start a connection to a
* hidden service directory to fetch a v2 rendezvous service descriptor. */
void
rend_client_refetch_v2_renddesc(const rend_data_t *rend_query)
rend_client_refetch_v2_renddesc(rend_data_t *rend_query)
{
int ret;
rend_cache_entry_t *e = NULL;
@ -964,7 +972,7 @@ rend_client_cancel_descriptor_fetches(void)
*/
int
rend_client_report_intro_point_failure(extend_info_t *failed_intro,
const rend_data_t *rend_query,
rend_data_t *rend_query,
unsigned int failure_type)
{
int i, r;

View File

@ -19,9 +19,8 @@ void rend_client_rendcirc_has_opened(origin_circuit_t *circ);
int rend_client_introduction_acked(origin_circuit_t *circ,
const uint8_t *request,
size_t request_len);
void rend_client_refetch_v2_renddesc(const rend_data_t *rend_query);
int rend_client_fetch_v2_desc(const rend_data_t *query,
smartlist_t *hsdirs);
void rend_client_refetch_v2_renddesc(rend_data_t *rend_query);
int rend_client_fetch_v2_desc(rend_data_t *query, smartlist_t *hsdirs);
void rend_client_cancel_descriptor_fetches(void);
void rend_client_purge_last_hid_serv_requests(void);
@ -30,7 +29,7 @@ void rend_client_purge_last_hid_serv_requests(void);
#define INTRO_POINT_FAILURE_UNREACHABLE 2
int rend_client_report_intro_point_failure(extend_info_t *failed_intro,
const rend_data_t *rend_query,
rend_data_t *rend_query,
unsigned int failure_type);
int rend_client_rendezvous_acked(origin_circuit_t *circ,