[or-cvs] r16464: {tor} Backport to 0.1.2.x: Never allow a circuit to be created wit (in tor/branches/tor-0_1_2-patches: . src/or)

nickm at seul.org nickm at seul.org
Thu Aug 7 20:19:55 UTC 2008


Author: nickm
Date: 2008-08-07 16:19:53 -0400 (Thu, 07 Aug 2008)
New Revision: 16464

Modified:
   tor/branches/tor-0_1_2-patches/ChangeLog
   tor/branches/tor-0_1_2-patches/src/or/circuitbuild.c
   tor/branches/tor-0_1_2-patches/src/or/circuitlist.c
   tor/branches/tor-0_1_2-patches/src/or/command.c
   tor/branches/tor-0_1_2-patches/src/or/or.h
Log:
Backport to 0.1.2.x: Never allow a circuit to be created with the same circid as a circuit that has been marked for close.  May fix 779.  Needs testing.

Modified: tor/branches/tor-0_1_2-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_1_2-patches/ChangeLog	2008-08-07 20:19:38 UTC (rev 16463)
+++ tor/branches/tor-0_1_2-patches/ChangeLog	2008-08-07 20:19:53 UTC (rev 16464)
@@ -15,6 +15,9 @@
       would stop building circuits and start refusing connections after
       24 hours, since we falsely believed that Tor was dormant. Reported
       by nwf.
+    - Ensure that two circuits can never exist on the same connection
+      with the same circuit ID, even if one is marked for close.  This
+      is conceivably a bugfix for bug 779; fixes a bug on 0.1.0.4-rc.
 
   o Minor bugfixes:
     - Stop recommending that every server operator send mail to tor-ops.

Modified: tor/branches/tor-0_1_2-patches/src/or/circuitbuild.c
===================================================================
--- tor/branches/tor-0_1_2-patches/src/or/circuitbuild.c	2008-08-07 20:19:38 UTC (rev 16463)
+++ tor/branches/tor-0_1_2-patches/src/or/circuitbuild.c	2008-08-07 20:19:53 UTC (rev 16464)
@@ -94,7 +94,7 @@
       return 0;
     }
     test_circ_id |= high_bit;
-  } while (circuit_get_by_circid_orconn(test_circ_id, conn));
+  } while (circuit_id_in_use_on_orconn(test_circ_id, conn));
   return test_circ_id;
 }
 

Modified: tor/branches/tor-0_1_2-patches/src/or/circuitlist.c
===================================================================
--- tor/branches/tor-0_1_2-patches/src/or/circuitlist.c	2008-08-07 20:19:38 UTC (rev 16463)
+++ tor/branches/tor-0_1_2-patches/src/or/circuitlist.c	2008-08-07 20:19:53 UTC (rev 16464)
@@ -615,6 +615,14 @@
     return circ;
 }
 
+/** Return true iff the circuit ID <b>circ_id</b> is currently used by a
+ * circuit, marked or not, on <b>conn</b>. */
+int
+circuit_id_in_use_on_orconn(uint16_t circ_id, or_connection_t *conn)
+{
+  return circuit_get_by_circid_orconn_impl(circ_id, conn) != NULL;
+}
+
 /** Return the circuit that a given edge connection is using. */
 circuit_t *
 circuit_get_by_edge_conn(edge_connection_t *conn)

Modified: tor/branches/tor-0_1_2-patches/src/or/command.c
===================================================================
--- tor/branches/tor-0_1_2-patches/src/or/command.c	2008-08-07 20:19:38 UTC (rev 16463)
+++ tor/branches/tor-0_1_2-patches/src/or/command.c	2008-08-07 20:19:53 UTC (rev 16464)
@@ -196,7 +196,7 @@
     return;
   }
 
-  if (circuit_get_by_circid_orconn(cell->circ_id, conn)) {
+  if (circuit_id_in_use_on_orconn(cell->circ_id, conn)) {
     routerinfo_t *router = router_get_by_digest(conn->identity_digest);
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
            "Received CREATE cell (circID %d) for known circ. "

Modified: tor/branches/tor-0_1_2-patches/src/or/or.h
===================================================================
--- tor/branches/tor-0_1_2-patches/src/or/or.h	2008-08-07 20:19:38 UTC (rev 16463)
+++ tor/branches/tor-0_1_2-patches/src/or/or.h	2008-08-07 20:19:53 UTC (rev 16464)
@@ -1997,6 +1997,7 @@
 or_circuit_t *or_circuit_new(uint16_t p_circ_id, or_connection_t *p_conn);
 circuit_t *circuit_get_by_circid_orconn(uint16_t circ_id,
                                         or_connection_t *conn);
+int circuit_id_in_use_on_orconn(uint16_t circ_id, or_connection_t *conn);
 circuit_t *circuit_get_by_edge_conn(edge_connection_t *conn);
 void circuit_unlink_all_from_or_conn(or_connection_t *conn, int reason);
 origin_circuit_t *circuit_get_by_global_id(uint32_t id);



More information about the tor-commits mailing list