[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Update descriptor ID when it changes in rend_data



commit a9b9f6d90f473e1a4fad3816ee73190da15b2291
Author: David Goulet <dgoulet@xxxxxxxxx>
Date:   Tue Apr 28 10:22:14 2015 -0400

    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@xxxxxxxxx>
---
 src/or/rendclient.c |   20 ++++++++++++++------
 src/or/rendclient.h |    7 +++----
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 1ddaa8e..834759c 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -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;
diff --git a/src/or/rendclient.h b/src/or/rendclient.h
index 5227b5c..639ec1e 100644
--- a/src/or/rendclient.h
+++ b/src/or/rendclient.h
@@ -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,



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits