[or-cvs] fix vicious bug in connection_ap_attach_pending that caused...
Roger Dingledine
arma at seul.org
Wed Dec 3 09:50:04 UTC 2003
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
circuit.c connection.c connection_edge.c onion.c
Log Message:
fix vicious bug in connection_ap_attach_pending that caused it to
never work.
fix vicious bug in choose_good_exit_server that caused it to *skip over*
pending circuits, and look only at *non-pending circuits*, when choosing
a good exit node for the new circuit.
bugfix: remove incorrect asserts in circuit_get_newest()
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- circuit.c 20 Nov 2003 17:49:44 -0000 1.110
+++ circuit.c 3 Dec 2003 09:50:01 -0000 1.111
@@ -211,12 +211,10 @@
}
}
if(!newest || newest->timestamp_created < circ->timestamp_created) {
- assert(circ->n_circ_id);
newest = circ;
}
if(conn && circ->timestamp_dirty &&
(!leastdirty || leastdirty->timestamp_dirty < circ->timestamp_dirty)) {
- assert(circ->n_circ_id);
leastdirty = circ;
}
}
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- connection.c 30 Nov 2003 09:51:35 -0000 1.135
+++ connection.c 3 Dec 2003 09:50:02 -0000 1.136
@@ -44,7 +44,7 @@
"", /* 2 */
"", /* 3 */
"awaiting dest info", /* app, 4 */
- "waiting for OR connection", /* 5 */
+ "waiting for safe circuit", /* 5 */
"open" }, /* 6 */
{ "ready" }, /* dir listener, 0 */
{ "", /* dir, 0 */
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- connection_edge.c 3 Dec 2003 08:06:55 -0000 1.69
+++ connection_edge.c 3 Dec 2003 09:50:02 -0000 1.70
@@ -509,7 +509,7 @@
for (i = 0; i < n; ++i) {
conn = carray[i];
if (conn->type != CONN_TYPE_AP ||
- conn->type != AP_CONN_STATE_CIRCUIT_WAIT)
+ conn->state != AP_CONN_STATE_CIRCUIT_WAIT)
continue;
switch(connection_ap_handshake_attach_circuit(conn)) {
case -1: /* it will never work */
@@ -825,6 +825,9 @@
assert(conn->type == CONN_TYPE_AP);
assert(conn->socks_request);
+ log_fn(LOG_DEBUG,"considering nickname %s, for address %s / port %d:",
+ exit->nickname, conn->socks_request->address,
+ conn->socks_request->port);
addr = client_dns_lookup_entry(conn->socks_request->address);
return router_supports_exit_address(addr, conn->socks_request->port, exit);
}
Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- onion.c 3 Dec 2003 08:06:55 -0000 1.97
+++ onion.c 3 Dec 2003 09:50:02 -0000 1.98
@@ -242,7 +242,9 @@
* We use this for log messages now, but in the future we may depend on it.
*/
for (i = 0; i < n_connections; ++i) {
- if (carray[i]->type == CONN_TYPE_AP && carray[i]->state == AP_CONN_STATE_CIRCUIT_WAIT)
+ if (carray[i]->type == CONN_TYPE_AP &&
+ carray[i]->state == AP_CONN_STATE_CIRCUIT_WAIT &&
+ !carray[i]->marked_for_close)
++n_pending_connections;
}
log_fn(LOG_DEBUG, "Choosing exit node; %d connections are pending",
@@ -259,34 +261,46 @@
for (i = 0; i < dir->n_routers; ++i) { /* iterate over routers */
if(!dir->routers[i]->is_running) {
n_supported[i] = n_maybe_supported[i] = -1;
+ log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- directory says it's not running.",
+ dir->routers[i]->nickname, i);
continue; /* skip routers that are known to be down */
}
if(router_exit_policy_rejects_all(dir->routers[i])) {
n_supported[i] = n_maybe_supported[i] = -1;
+ log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- it rejects all.",
+ dir->routers[i]->nickname, i);
continue; /* skip routers that reject all */
}
n_supported[i] = n_maybe_supported[i] = 0;
++n_running_routers;
for (j = 0; j < n_connections; ++j) { /* iterate over connections */
if (carray[j]->type != CONN_TYPE_AP ||
- carray[j]->state == AP_CONN_STATE_CIRCUIT_WAIT ||
+ carray[j]->state != AP_CONN_STATE_CIRCUIT_WAIT ||
carray[j]->marked_for_close)
continue; /* Skip everything but APs in CIRCUIT_WAIT */
switch (connection_ap_can_use_exit(carray[j], dir->routers[i]))
{
case -1:
+ log_fn(LOG_DEBUG,"%s (index %d) would reject this stream.",
+ dir->routers[i]->nickname, i);
break; /* would be rejected; try next connection */
case 0:
++n_supported[i];
+ log_fn(LOG_DEBUG,"%s is supported. n_supported[%d] now %d.",
+ dir->routers[i]->nickname, i, n_supported[i]);
; /* Fall through: If it is supported, it is also maybe supported. */
case 1:
++n_maybe_supported[i];
+ log_fn(LOG_DEBUG,"%s is maybe supported. n_maybe_supported[%d] now %d.",
+ dir->routers[i]->nickname, i, n_maybe_supported[i]);
}
} /* End looping over connections. */
if (n_supported[i] > best_support) {
/* If this router is better than previous ones, remember its index
* and goodness, and start counting how many routers are this good. */
best_support = n_supported[i]; best_support_idx = i; n_best_support=1;
+ log_fn(LOG_DEBUG,"%s is new best supported option so far.",
+ dir->routers[i]->nickname);
} else if (n_supported[i] == best_support) {
/* If this router is _as good_ as the best one, just increment the
* count of equally good routers.*/
@@ -296,6 +310,8 @@
if (n_maybe_supported[i] > best_maybe_support) {
best_maybe_support = n_maybe_supported[i]; best_maybe_support_idx = i;
n_best_maybe_support = 1;
+ log_fn(LOG_DEBUG,"%s is new best maybe-supported option so far.",
+ dir->routers[i]->nickname);
} else if (n_maybe_supported[i] == best_maybe_support) {
++n_best_maybe_support;
}
More information about the tor-commits
mailing list