]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a conflux helper to log conflux sets.
authorMike Perry <mikeperry-git@torproject.org>
Tue, 6 Jun 2023 15:14:33 +0000 (15:14 +0000)
committerMike Perry <mikeperry-git@torproject.org>
Tue, 6 Jun 2023 15:15:20 +0000 (15:15 +0000)
src/core/or/conflux_pool.c
src/core/or/conflux_pool.h

index c84613503f0ccbb49ec60bf6b85cd5d324142cba..53985df810c42d7495d52313b38ad9545a1f90c7 100644 (file)
@@ -2020,6 +2020,51 @@ conflux_pool_init(void)
   }
 }
 
+/**
+ * Return a description of all linked and unlinked circuits associated
+ * with a conflux set.
+ *
+ * For use in rare bug cases that are hard to diagnose.
+ */
+void
+conflux_log_set(const conflux_t *cfx, bool is_client)
+{
+  tor_assert(cfx);
+
+  log_warn(LD_BUG, "Conflux %s: %d linked, %d launched",
+               fmt_nonce(cfx->nonce), smartlist_len(cfx->legs),
+               cfx->num_leg_launch);
+
+  // Log all linked legs
+  int legs = 0;
+  CONFLUX_FOR_EACH_LEG_BEGIN(cfx, leg) {
+   log_warn(LD_BUG,
+            " - Linked Leg %d purpose=%d; RTT %"PRIu64", sent: %"PRIu64
+            " marked: %d",
+            legs, leg->circ->purpose, leg->circ_rtts_usec,
+            leg->linked_sent_usec, leg->circ->marked_for_close);
+   legs++;
+  } CONFLUX_FOR_EACH_LEG_END(leg);
+
+  // Look up the nonce to see if we have any unlinked circuits.
+  unlinked_circuits_t *unlinked = unlinked_pool_get(cfx->nonce, is_client);
+  if (unlinked) {
+    // Log the number of legs and the is_for_linked_set status
+    log_warn(LD_BUG, " - Unlinked set:  %d legs, for link: %d",
+             smartlist_len(unlinked->legs), unlinked->is_for_linked_set);
+    legs = 0;
+    SMARTLIST_FOREACH_BEGIN(unlinked->legs, leg_t *, leg) {
+      log_warn(LD_BUG,
+        "     Unlinked Leg: %d purpose=%d; linked: %d, RTT %"PRIu64", "
+        "sent: %"PRIu64" link ptr %p, marked: %d",
+               legs, leg->circ->purpose, leg->linked,
+               leg->rtt_usec, leg->link_sent_usec,
+               leg->link, leg->circ->marked_for_close);
+      legs++;
+    } SMARTLIST_FOREACH_END(leg);
+  }
+}
+
 /** Free and clean up the conflux pool subsystem. This is called by the subsys
  * manager AFTER all circuits have been freed which implies that all objects in
  * the pools aren't referenced anymore. */
index 6bb858bb09d798665c63c092adf82cb5b8570ece..9a9701a4846b66c19ecfa6edbe46783ed9c89207 100644 (file)
@@ -36,6 +36,9 @@ void conflux_process_linked(circuit_t *circ, crypt_path_t *layer_hint,
                             const cell_t *cell, const uint16_t cell_len);
 void conflux_process_linked_ack(circuit_t *circ);
 
+typedef struct conflux_t conflux_t;
+void conflux_log_set(const conflux_t *cfx, bool is_client);
+
 #ifdef TOR_UNIT_TESTS
 bool launch_new_set(int num_legs);
 digest256map_t *get_linked_pool(bool is_client);