[or-cvs] r16853: {tor} Start building more server-side introduction circuits than n (tor/branches/hidserv-design-changes/src/or)

kloesing at seul.org kloesing at seul.org
Thu Sep 11 17:16:59 UTC 2008


Author: kloesing
Date: 2008-09-11 13:16:59 -0400 (Thu, 11 Sep 2008)
New Revision: 16853

Modified:
   tor/branches/hidserv-design-changes/src/or/circuitlist.c
   tor/branches/hidserv-design-changes/src/or/or.h
   tor/branches/hidserv-design-changes/src/or/rendservice.c
Log:
Start building more server-side introduction circuits than needed (five), pick the first three that succeed, and use the others as general-purpose circuits.

Modified: tor/branches/hidserv-design-changes/src/or/circuitlist.c
===================================================================
--- tor/branches/hidserv-design-changes/src/or/circuitlist.c	2008-09-11 17:11:47 UTC (rev 16852)
+++ tor/branches/hidserv-design-changes/src/or/circuitlist.c	2008-09-11 17:16:59 UTC (rev 16853)
@@ -810,6 +810,25 @@
                                      DIGEST_LEN);
 }
 
+/** Return the number of introduction points that are or have been
+ * established for the given service address and rendezvous version. */
+int
+circuit_get_num_intro_points(const char *query, int rend_version)
+{
+  int num_ipos = 0;
+  circuit_t *circ;
+  for (circ = global_circuitlist; circ; circ = circ->next) {
+    if (!circ->marked_for_close &&
+        circ->state == CIRCUIT_STATE_OPEN &&
+        (circ->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO ||
+         circ->purpose == CIRCUIT_PURPOSE_S_INTRO) &&
+        !rend_cmp_service_ids(query, TO_ORIGIN_CIRCUIT(circ)->rend_query) &&
+        TO_ORIGIN_CIRCUIT(circ)->rend_desc_version == rend_version)
+      num_ipos++;
+  }
+  return num_ipos;
+}
+
 /** Return a circuit that is open, is CIRCUIT_PURPOSE_C_GENERAL,
  * has a timestamp_dirty value of 0, has flags matching the CIRCLAUNCH_*
  * flags in <b>flags</b>, and if info is defined, does not already use info

Modified: tor/branches/hidserv-design-changes/src/or/or.h
===================================================================
--- tor/branches/hidserv-design-changes/src/or/or.h	2008-09-11 17:11:47 UTC (rev 16852)
+++ tor/branches/hidserv-design-changes/src/or/or.h	2008-09-11 17:16:59 UTC (rev 16853)
@@ -2675,6 +2675,7 @@
                                          const char *digest, uint8_t purpose);
 or_circuit_t *circuit_get_rendezvous(const char *cookie);
 or_circuit_t *circuit_get_intro_point(const char *digest);
+int circuit_get_num_intro_points(const char *query, int rend_version);
 origin_circuit_t *circuit_find_to_cannibalize(uint8_t purpose,
                                               extend_info_t *info, int flags);
 void circuit_mark_all_unused_circs(void);

Modified: tor/branches/hidserv-design-changes/src/or/rendservice.c
===================================================================
--- tor/branches/hidserv-design-changes/src/or/rendservice.c	2008-09-11 17:11:47 UTC (rev 16852)
+++ tor/branches/hidserv-design-changes/src/or/rendservice.c	2008-09-11 17:16:59 UTC (rev 16853)
@@ -1152,6 +1152,18 @@
     goto err;
   }
 
+  /* If we already have enough introduction circuits, redefine this
+   * one as a general circuit. */
+  if (circuit_get_num_intro_points(serviceid,
+          circuit->rend_desc_version) > NUM_INTRO_POINTS) {
+    log_info(LD_CIRC|LD_REND, "We have just finished an introduction "
+             "circuit, but we already have enough. Redefining purpose to "
+             "general.");
+    TO_CIRCUIT(circuit)->purpose = CIRCUIT_PURPOSE_C_GENERAL;
+    circuit_has_opened(circuit);
+    return;
+  }
+
   log_info(LD_REND,
            "Established circuit %d as introduction point for service %s",
            circuit->_base.n_circ_id, serviceid);
@@ -1662,9 +1674,11 @@
 
     /* Remember how many introduction circuits we started with. */
     prev_intro_nodes = smartlist_len(service->intro_nodes);
-
-    /* The directory is now here. Pick three ORs as intro points. */
-    for (j=prev_intro_nodes; j < NUM_INTRO_POINTS; ++j) {
+    /* The directory is now here. Pick three ORs as intro points (plus, if
+     * we currently have none at all, two more so that we can pick the first
+     * three afterwards). */
+    for (j=prev_intro_nodes; j < (prev_intro_nodes == 0 ?
+                               NUM_INTRO_POINTS+2 : NUM_INTRO_POINTS); ++j) {
       router_crn_flags_t flags = CRN_NEED_UPTIME;
       if (get_options()->_AllowInvalid & ALLOW_INVALID_INTRODUCTION)
         flags |= CRN_ALLOW_INVALID;



More information about the tor-commits mailing list