]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge branch 'maint-0.4.5' into maint-0.4.6
authorDavid Goulet <dgoulet@torproject.org>
Wed, 6 Oct 2021 19:35:43 +0000 (15:35 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Wed, 6 Oct 2021 19:35:43 +0000 (15:35 -0400)
1  2 
src/feature/dirclient/dirclient.c
src/feature/dircommon/directory.h

index fd677d33feb2ee2b87a7e4c515987d1120ea4b22,f2e1e5b5ffbce360ade381690c133edecfa83ecb..0b6a8101a5bd932872f4a01dba594f29eae2ef2f
@@@ -708,8 -734,26 +708,23 @@@ connection_dir_client_request_failed(di
       * failed. */
      entry_guard_failed(&conn->guard_state);
    }
 -  if (directory_conn_is_self_reachability_test(conn)) {
 -    return; /* this was a test fetch. don't retry. */
 -  }
    if (!entry_list_is_constrained(get_options()))
-     router_set_status(conn->identity_digest, 0); /* don't try this one again */
+     /* We must not set a directory to non-running for HS purposes else we end
+      * up flagging nodes from the hashring has unusable. It doesn't have direct
+      * effect on the HS subsystem because the nodes are selected regardless of
+      * their status but still, we shouldn't flag them as non running.
+      *
+      * One example where this can go bad is if a tor instance gets added a lot
+      * of ephemeral services and with a network with problem then many nodes in
+      * the consenus ends up unusable.
+      *
+      * Furthermore, a service does close any pending directory connections
+      * before uploading a descriptor and thus we can end up here in a natural
+      * way since closing a pending directory connection leads to this code
+      * path. */
+     if (!DIR_PURPOSE_IS_HS(TO_CONN(conn)->purpose)) {
+       router_set_status(conn->identity_digest, 0);
+     }
    if (conn->base_.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
               conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
      log_info(LD_DIR, "Giving up on serverdesc/extrainfo fetch from "
index f233e8b2448de1337d1132c84cb0c78e4d0f1300,2cd9c176c8777a32dbfc77add7e2db6fedb92234..7d861682bb03c8b9e8bc15953dea63552b52eaa8
@@@ -78,8 -84,15 +78,14 @@@ const dir_connection_t *CONST_TO_DIR_CO
    ((p)==DIR_PURPOSE_UPLOAD_DIR ||               \
     (p)==DIR_PURPOSE_UPLOAD_VOTE ||              \
     (p)==DIR_PURPOSE_UPLOAD_SIGNATURES ||        \
 -   (p)==DIR_PURPOSE_UPLOAD_RENDDESC_V2 ||       \
     (p)==DIR_PURPOSE_UPLOAD_HSDESC)
  
+ /** True iff p is a purpose corresponding to onion service that is either
+  * uploading or fetching actions. */
+ #define DIR_PURPOSE_IS_HS(p)          \
+   ((p) == DIR_PURPOSE_FETCH_HSDESC || \
+    (p) == DIR_PURPOSE_UPLOAD_HSDESC)
  enum compress_method_t;
  int parse_http_response(const char *headers, int *code, time_t *date,
                          enum compress_method_t *compression, char **response);