diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-08-07 20:19:38 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-08-07 20:19:38 +0000 |
commit | 62340f1d766da299fa0b3f0f1a5a71dfd4603dce (patch) | |
tree | 87e7c753c083c83f0f050dc642485ee817df534e /src/or | |
parent | 355d84d1225c8185b06ce251ffd2be0a8c884218 (diff) | |
download | tor-62340f1d766da299fa0b3f0f1a5a71dfd4603dce.tar.gz tor-62340f1d766da299fa0b3f0f1a5a71dfd4603dce.zip |
Backport to 0.2.0.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.
svn:r16463
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/circuitbuild.c | 2 | ||||
-rw-r--r-- | src/or/circuitlist.c | 8 | ||||
-rw-r--r-- | src/or/command.c | 2 | ||||
-rw-r--r-- | src/or/or.h | 1 |
4 files changed, 11 insertions, 2 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index bb302836f7..3be2689995 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -99,7 +99,7 @@ get_unique_circ_id_by_conn(or_connection_t *conn) 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; } diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 7bd3829f62..adb0d7867e 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -661,6 +661,14 @@ circuit_get_by_circid_orconn(uint16_t circ_id, or_connection_t *conn) 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) diff --git a/src/or/command.c b/src/or/command.c index 552624fb76..f125f47690 100644 --- a/src/or/command.c +++ b/src/or/command.c @@ -252,7 +252,7 @@ command_process_create_cell(cell_t *cell, or_connection_t *conn) 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. " diff --git a/src/or/or.h b/src/or/or.h index e1a2fe6d9e..6f7d92cabf 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2568,6 +2568,7 @@ origin_circuit_t *origin_circuit_new(void); 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); |