[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] when we were cannibalizing a circuit with a particular exit
Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or
Modified Files:
circuitlist.c circuituse.c or.h
Log Message:
when we were cannibalizing a circuit with a particular exit
node in mind, we weren't checking to see if that exit node
was already present earlier in the circuit. oops.
Index: circuitlist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitlist.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- circuitlist.c 29 Oct 2005 19:13:48 -0000 1.68
+++ circuitlist.c 11 Nov 2005 19:25:29 -0000 1.69
@@ -99,7 +99,7 @@
_last_circid_orconn_ent = NULL;
}
- if (old_conn) {
+ if (old_conn) { /* we may need to remove it from the conn-circid map */
search.circ_id = old_id;
search.or_conn = old_conn;
found = RB_FIND(orconn_circid_tree, &orconn_circid_circuit_map, &search);
@@ -112,6 +112,7 @@
if (conn == NULL)
return;
+ /* now add the new one to the conn-circid map */
search.circ_id = id;
search.or_conn = conn;
found = RB_FIND(orconn_circid_tree, &orconn_circid_circuit_map, &search);
@@ -549,16 +550,19 @@
}
/** Return a circuit that is open, has specified <b>purpose</b>,
- * has a timestamp_dirty value of 0, and is uptime/capacity/internal
- * if required; or NULL if no circuit fits this description.
+ * has a timestamp_dirty value of 0, is uptime/capacity/internal
+ * if required, and if info is defined, does not already use info
+ * as any of its hops; or NULL if no circuit fits this description.
*
* Avoid returning need_uptime circuits if not necessary.
+ *
* FFFF As a more important goal, not yet implemented, avoid returning
* internal circuits if not necessary.
*/
circuit_t *
-circuit_get_clean_open(uint8_t purpose, int need_uptime,
- int need_capacity, int internal)
+circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
+ int need_uptime,
+ int need_capacity, int internal)
{
circuit_t *circ;
circuit_t *best=NULL;
@@ -574,8 +578,19 @@
(!need_uptime || circ->build_state->need_uptime) &&
(!need_capacity || circ->build_state->need_capacity) &&
(!internal || circ->build_state->is_internal)) {
+ if (info) {
+ /* need to make sure we don't duplicate hops */
+ crypt_path_t *hop = circ->cpath;
+ do {
+ if (!memcmp(hop->extend_info->identity_digest,
+ info->identity_digest, DIGEST_LEN))
+ goto next;
+ hop=hop->next;
+ } while (hop!=circ->cpath);
+ }
if (!best || (best->build_state->need_uptime && !need_uptime))
best = circ;
+ next:
}
}
return best;
Index: circuituse.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- circuituse.c 25 Oct 2005 18:01:01 -0000 1.87
+++ circuituse.c 11 Nov 2005 19:25:30 -0000 1.88
@@ -756,8 +756,9 @@
if ((info || purpose != CIRCUIT_PURPOSE_C_GENERAL) &&
purpose != CIRCUIT_PURPOSE_TESTING) {
/* see if there are appropriate circs available to cannibalize. */
- if ((circ = circuit_get_clean_open(CIRCUIT_PURPOSE_C_GENERAL, need_uptime,
- need_capacity, internal))) {
+ circ = circuit_find_to_cannibalize(CIRCUIT_PURPOSE_C_GENERAL, info,
+ need_uptime, need_capacity, internal);
+ if (circ) {
info(LD_CIRC,"Cannibalizing circ '%s' for purpose %d",
build_state_get_exit_nickname(circ->build_state), purpose);
circ->purpose = purpose;
@@ -779,7 +780,7 @@
return NULL;
break;
default:
- warn(LD_BUG, "Bug: unexpected purpose %d when cannibalizing a general circ.", purpose);
+ warn(LD_BUG, "Bug: unexpected purpose %d when cannibalizing a circ.", purpose);
tor_fragile_assert();
return NULL;
}
Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.731
retrieving revision 1.732
diff -u -d -r1.731 -r1.732
--- or.h 5 Nov 2005 20:15:27 -0000 1.731
+++ or.h 11 Nov 2005 19:25:30 -0000 1.732
@@ -1443,8 +1443,9 @@
circuit_t *circuit_get_next_by_pk_and_purpose(circuit_t *start,
const char *digest, uint8_t purpose);
circuit_t *circuit_get_rendezvous(const char *cookie);
-circuit_t *circuit_get_clean_open(uint8_t purpose, int need_uptime,
- int need_capacity, int internal);
+circuit_t *circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
+ int need_uptime,
+ int need_capacity, int internal);
void circuit_mark_all_unused_circs(void);
void circuit_expire_all_dirty_circs(void);
void _circuit_mark_for_close(circuit_t *circ, int line, const char *file);