aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-09-18 10:03:57 -0400
committerNick Mathewson <nickm@torproject.org>2020-09-18 10:03:57 -0400
commit781ab9eea49b07b1925d7d8dcbad06348896344e (patch)
tree6a5ec10c59617467e25863fb911689625f2467dd /src/core
parent404c224c711714f014288c79257c4bfd3880905c (diff)
downloadtor-781ab9eea49b07b1925d7d8dcbad06348896344e.tar.gz
tor-781ab9eea49b07b1925d7d8dcbad06348896344e.zip
Add flag for whether an OR conn "counts" for bootstrap tracking
We set this flag if we've launched the connection in order to satisfy an origin circuit, or when we decide the connection _would_ satisfy an origin circuit. These are the only or_connections we want to consider for bootstrapping: other or_connections are opened because of client EXTEND requests, and they may succeed or fail because of the clients' confusion or misconfiguration. Closes #25061.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/or/channel.c10
-rw-r--r--src/core/or/channel.h2
-rw-r--r--src/core/or/channeltls.c22
-rw-r--r--src/core/or/circuitbuild.c3
-rw-r--r--src/core/or/or_connection_st.h5
5 files changed, 41 insertions, 1 deletions
diff --git a/src/core/or/channel.c b/src/core/or/channel.c
index d082174dc8..0765f222c1 100644
--- a/src/core/or/channel.c
+++ b/src/core/or/channel.c
@@ -2395,12 +2395,16 @@ channel_is_better(channel_t *a, channel_t *b)
* *msg_out to a message describing the channel's state and our next action,
* and set *launch_out to a boolean indicated whether the caller should try to
* launch a new channel with channel_connect().
+ *
+ * If `for_origin_circ` is set, mark the channel as interesting for origin
+ * circuits, and therefore interesting for our bootstrapping reports.
*/
MOCK_IMPL(channel_t *,
channel_get_for_extend,(const char *rsa_id_digest,
const ed25519_public_key_t *ed_id,
const tor_addr_t *target_ipv4_addr,
const tor_addr_t *target_ipv6_addr,
+ bool for_origin_circ,
const char **msg_out,
int *launch_out))
{
@@ -2440,8 +2444,12 @@ channel_get_for_extend,(const char *rsa_id_digest,
if (!CHANNEL_IS_OPEN(chan)) {
/* If the address matches, don't launch a new connection for this
* circuit. */
- if (matches_target)
+ if (matches_target) {
++n_inprogress_goodaddr;
+ if (for_origin_circ) {
+ channel_mark_as_used_for_origin_circuit(chan);
+ }
+ }
continue;
}
diff --git a/src/core/or/channel.h b/src/core/or/channel.h
index 606b0730b8..206d0fdc97 100644
--- a/src/core/or/channel.h
+++ b/src/core/or/channel.h
@@ -526,6 +526,7 @@ void channel_mark_for_close(channel_t *chan);
int channel_write_packed_cell(channel_t *chan, packed_cell_t *cell);
void channel_listener_mark_for_close(channel_listener_t *chan_l);
+void channel_mark_as_used_for_origin_circuit(channel_t *chan);
/* Channel callback registrations */
@@ -661,6 +662,7 @@ MOCK_DECL(channel_t *, channel_get_for_extend,(
const struct ed25519_public_key_t *ed_id,
const tor_addr_t *target_ipv4_addr,
const tor_addr_t *target_ipv6_addr,
+ bool for_origin_circ,
const char **msg_out,
int *launch_out));
diff --git a/src/core/or/channeltls.c b/src/core/or/channeltls.c
index a0debf8d22..2c52c07bb5 100644
--- a/src/core/or/channeltls.c
+++ b/src/core/or/channeltls.c
@@ -360,6 +360,28 @@ channel_tls_handle_incoming(or_connection_t *orconn)
return chan;
}
+/**
+ * Set the `potentially_used_for_bootstrapping` flag on the or_connection_t
+ * corresponding to the provided channel.
+ *
+ * This flag indicates that if the connection fails, it might be interesting
+ * to the bootstrapping subsystem.
+ **/
+void
+channel_mark_as_used_for_origin_circuit(channel_t *chan)
+{
+ if (BUG(!chan))
+ return;
+ if (chan->magic != TLS_CHAN_MAGIC)
+ return;
+ channel_tls_t *tlschan = channel_tls_from_base(chan);
+ if (BUG(!tlschan))
+ return;
+
+ if (tlschan->conn)
+ tlschan->conn->potentially_used_for_bootstrapping = 1;
+}
+
/*********
* Casts *
********/
diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c
index ab4ce9f784..225a0112f7 100644
--- a/src/core/or/circuitbuild.c
+++ b/src/core/or/circuitbuild.c
@@ -574,6 +574,7 @@ circuit_handle_first_hop(origin_circuit_t *circ)
&firsthop->extend_info->ed_identity,
orport4 ? &orport4->addr : NULL,
orport6 ? &orport6->addr : NULL,
+ true,
&msg,
&should_launch);
@@ -590,6 +591,7 @@ circuit_handle_first_hop(origin_circuit_t *circ)
log_info(LD_CIRC,"connect to firsthop failed. Closing.");
return -END_CIRC_REASON_CONNECTFAILED;
}
+ channel_mark_as_used_for_origin_circuit(n_chan);
circuit_chan_publish(circ, n_chan);
}
@@ -602,6 +604,7 @@ circuit_handle_first_hop(origin_circuit_t *circ)
} else { /* it's already open. use it. */
tor_assert(!circ->base_.n_hop);
circ->base_.n_chan = n_chan;
+ channel_mark_as_used_for_origin_circuit(n_chan);
circuit_chan_publish(circ, n_chan);
log_debug(LD_CIRC,"Conn open for %s. Delivering first onion skin.",
safe_str_client(extend_info_describe(firsthop->extend_info)));
diff --git a/src/core/or/or_connection_st.h b/src/core/or/or_connection_st.h
index 8e012a6b85..253fe67020 100644
--- a/src/core/or/or_connection_st.h
+++ b/src/core/or/or_connection_st.h
@@ -74,6 +74,11 @@ struct or_connection_t {
unsigned int is_outgoing:1;
unsigned int proxy_type:3; /**< One of PROXY_NONE...PROXY_HAPROXY */
unsigned int wide_circ_ids:1;
+ /** True iff a failure on this connection indicates a posssible
+ * bootstrapping problem. We set this as true if we notice that this
+ * connection could handle a pending origin circuit, or if we launch it to
+ * handle an origin circuit. */
+ unsigned int potentially_used_for_bootstrapping:1;
/** True iff this connection has had its bootstrap failure logged with
* control_event_bootstrap_problem. */
unsigned int have_noted_bootstrap_problem:1;