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

[tor-commits] [tor/master] prop224: Pick the right hsdir index based on descriptor.



commit e0371935a1787d5f34237343d0b7eaf206e133cf
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Fri Sep 8 13:05:22 2017 +0300

    prop224: Pick the right hsdir index based on descriptor.
    
    There was a bug in upload_descriptor_to_all() where we picked between
    first and second hsdir index based on which time segment we are. That's
    not right and instead we should be uploading our two descriptors using a
    different hsdir index every time. That is, upload first descriptor using
    first hsdir index, and upload second descriptor using second hdsir index.
    
    Also simplify stuff in pick_hdsir_v3() since that's only used to fetch
    descriptors and hence we can just always use the fetch hsdir index.
---
 src/or/hs_client.c  | 4 +---
 src/or/hs_common.h  | 4 ++--
 src/or/hs_service.c | 6 +-----
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/or/hs_client.c b/src/or/hs_client.c
index c9709b4d2..3394e0eb6 100644
--- a/src/or/hs_client.c
+++ b/src/or/hs_client.c
@@ -162,7 +162,6 @@ static routerstatus_t *
 pick_hsdir_v3(const ed25519_public_key_t *onion_identity_pk)
 {
   int retval;
-  unsigned int is_new_tp = 0;
   char base64_blinded_pubkey[ED25519_BASE64_LEN + 1];
   uint64_t current_time_period = hs_get_time_period_num(0);
   smartlist_t *responsible_hsdirs;
@@ -183,9 +182,8 @@ pick_hsdir_v3(const ed25519_public_key_t *onion_identity_pk)
   }
 
   /* Get responsible hsdirs of service for this time period */
-  is_new_tp = hs_in_period_between_tp_and_srv(NULL, time(NULL));
   hs_get_responsible_hsdirs(&blinded_pubkey, current_time_period,
-                            is_new_tp, 1, responsible_hsdirs);
+                            0, 1, responsible_hsdirs);
 
   log_debug(LD_REND, "Found %d responsible HSDirs and about to pick one.",
            smartlist_len(responsible_hsdirs));
diff --git a/src/or/hs_common.h b/src/or/hs_common.h
index 77b4e6544..5851578fd 100644
--- a/src/or/hs_common.h
+++ b/src/or/hs_common.h
@@ -146,8 +146,8 @@ typedef struct hsdir_index_t {
   uint8_t fetch[DIGEST256_LEN];
 
   /* HSDir index used by services to store their first and second
-   * descriptor. The first descriptor is the one that uses older TP and SRV
-   * values than the second one. */
+   * descriptor. The first descriptor is chronologically older than the second
+   * one and uses older TP and SRV values. */
   uint8_t store_first[DIGEST256_LEN];
   uint8_t store_second[DIGEST256_LEN];
 } hsdir_index_t;
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 8f5da2b63..5759aa812 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -2382,21 +2382,17 @@ STATIC void
 upload_descriptor_to_all(const hs_service_t *service,
                          hs_service_descriptor_t *desc)
 {
-  unsigned int is_new_tp = 0;
   smartlist_t *responsible_dirs = NULL;
 
   tor_assert(service);
   tor_assert(desc);
 
-  /* Do we have a new TP that is are we between a new time period and the next
-   * SRV creation? */
-  is_new_tp = hs_in_period_between_tp_and_srv(NULL, approx_time());
   /* Get our list of responsible HSDir. */
   responsible_dirs = smartlist_new();
   /* The parameter 0 means that we aren't a client so tell the function to use
    * the spread store consensus paremeter. */
   hs_get_responsible_hsdirs(&desc->blinded_kp.pubkey, desc->time_period_num,
-                            is_new_tp, 0, responsible_dirs);
+                            service->desc_next == desc, 0, responsible_dirs);
 
   /** Clear list of previous hsdirs since we are about to upload to a new
    *  list. Let's keep it up to date. */



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