Commit Graph

346 Commits

Author SHA1 Message Date
Mike Perry 74d6fd534a Bug 40828: Add more log scrubbing to protocol warnings 2023-07-31 14:12:39 +00:00
Roger Dingledine eba9190933 compute the client-side pow in a cpuworker thread
We mark the intro circuit with a new flag saying that the pow is
in the cpuworker queue. When the cpuworker comes back, it either
has a solution, in which case we proceed with sending the intro1
cell, or it has no solution, in which case we unmark the intro
circuit and let the whole process restart on the next iteration of
connection_ap_handshake_attach_circuit().
2023-05-10 07:37:11 -07:00
Roger Dingledine a5b0c7b404 start the cpuworkers always, even for clients
prepares the way for client-side pow cpuworkers

also happens to resolve bug https://bugs.torproject.org/tpo/core/tor/40617
(which went into 0.4.7.4-alpha) because now we survive initing the
cpuworker subsystem when we're not a relay.
2023-05-10 07:37:11 -07:00
David Goulet 2bb8988629 Fix cases where edge connections can stall.
We discovered two cases where edge connections can stall during testing:
  1. Due to final data sitting in the edge inbuf when it was resumed
  2. Due to flag synchronization between the token bucket and XON/XOFF

The first issue has always existed in C-Tor, but we were able to tickle it
in scp testing. If the last data from the protocol is able to fit in the
inbuf, but not large enough to send, if an XOFF or connection block comes in
at exactly that point, when the edge connection resumes, there will be no
data to read from the socket, but the inbuf can just sit there, never
draining.

We noticed the second issue along the way to finding the first. It seems
wrong, but it didn't seem to affect anything in practice.

These are extremely rare in normal operation, but with conflux, XON/XOFF
activity is more common, so we hit these.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-04-06 15:57:11 +00:00
Mike Perry 21c861bfa3 Refactor stream blocking due to channel cell queues
Streams can get blocked on a circuit in two ways:
  1. When the circuit package window is full
  2. When the channel's cell queue is too high

Conflux needs to decouple stream blocking from both of these conditions,
because streams can continue on another circuit, even if the primary circuit
is blocked for either of these cases.

However, both conflux and congestion control need to know if the channel's
cell queue hit the highwatermark and is still draining, because this condition
is used by those components, independent of stream state.

Therefore, this commit renames the 'streams_blocked_on_chan' variable to
signify that it refers to the cell queue state, and also refactors the actual
stream blocking bits out, so they can be handled separately if conflux is
present.
2023-04-06 15:57:10 +00:00
Gabriela Moldovan a9c7cd6b2c Fix small typo in mainloop.c docs.
The docs should reference `tor_event_new()` rather than `tor_libevent_new()`.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-02-07 12:15:12 +00:00
David Goulet 923463a1e6 Fix duplicate code after tor-gitlab/mr/671 forward merge
Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-12-20 09:11:30 -05:00
David Goulet 713efae94b Merge branch 'maint-0.4.7' 2022-12-20 09:09:47 -05:00
Alex Xu (Hello71) 1d9166c8c9 Enable IP_BIND_ADDRESS_NO_PORT if supported
Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-12-20 09:09:33 -05:00
David Goulet 03ddeb9539 Merge branch 'tor-gitlab/mr/660' 2022-12-12 15:10:06 -05:00
qontinuum 7dd55c29f9 Replace socket_failed_from_resource_exhaustion() by socket_failed_from_fd_exhaustion() 2022-12-11 10:14:23 +01:00
qontinuum 5852319bd4 Isolate warn_about_resource_exhaution() 2022-12-11 10:14:18 +01:00
David Goulet 3ac08ac200 Merge branch 'tor-gitlab/mr/658' 2022-11-28 09:33:32 -05:00
qontinuum 0b015c9731 Rely on kernel errno when logging resource exhaustion
Signed-off-by: qontinuum <qontinuum@monaco.mc>
2022-11-25 19:38:48 +01:00
David Goulet 04d8753676 Merge branch 'maint-0.4.7' 2022-11-23 14:54:43 -05:00
David Goulet fbc9e92fdb relay: Use the configured number of threads for worker work calculation
We cap our number of CPU worker threads to at least 2 even if we have a
single core. But also, before we used to always add one extra thread
regardless of the number of core.

This meant that we were off when re-using the get_num_cpus() function
when calculating our onionskin work overhead because we were always off
by one.

This commit makes it that we always use the number of thread our actual
thread pool was configured with.

Fixes #40719

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-11-23 14:05:10 -05:00
David Goulet b9de73e46e cpu: Set number of threads to number of cores
Cap this to 2 threads always because we need a low and high priority
thread even with a single core.

Fixes #40713

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-11-23 13:52:36 -05:00
David Goulet 560d44b08b Merge branch 'maint-0.4.7' 2022-11-09 15:29:04 -05:00
David Goulet e3f6908984 relay: Make the max pending tasks per CPU a consensus parameter
Until now, there was this magic number (64) used as the maximum number
of tasks a CPU worker can take at once.

This commit makes it a consensus parameter so our future selves can
think of a better value depending on network conditions.

Part of #40704

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-11-09 13:13:21 -05:00
David Goulet 8b8873b759 Merge branch 'maint-0.4.7' 2022-11-08 15:26:44 -05:00
David Goulet 5b0103cfb4 Merge branch 'tor-gitlab/mr/651' into maint-0.4.7 2022-11-08 15:25:08 -05:00
David Goulet d634a5ebc7 relay: Remove unused conn->ext_or_conn_id
This also incidently removes a use of uninitialized stack data from the
connection_or_set_ext_or_identifier() function.

Fixes #40648

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-11-08 12:35:09 -05:00
David Goulet 6196e9596a metrics: Add connection socket family to metrics
Adds either ipv4 or ipv6 to the "tor_relay_connections_total" stats.

Closes #40710

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-11-03 13:05:21 -04:00
David Goulet c733ccda99 Merge branch 'tor-gitlab/mr/579' 2022-10-31 15:28:36 -04:00
David Goulet 5080a4ff67 Merge branch 'maint-0.4.7' 2022-10-12 15:52:04 -04:00
David Goulet c8d8fa0d36 relay: Add number of rejected connections to MetricsPort
Related to #40194

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-10-12 09:25:19 -04:00
David Goulet 5603baf257 conn: Keep stats of opened and closed connections
Related to #40194

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-10-12 09:25:19 -04:00
David Goulet b7f9a24c08 relay: Remove unused conn->ext_or_conn_id
This also incidently removes a use of uninitialized stack data from the
connection_or_set_ext_or_identifier() function.

Fixes #40648

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-07-26 11:56:33 -04:00
Alex Xu (Hello71) b65ffa6f06 Enable IP_BIND_ADDRESS_NO_PORT if supported 2022-06-15 08:35:40 -04:00
David Goulet b733f9d6ac Merge branch 'maint-0.4.7' 2022-06-02 16:11:04 -04:00
Mike Perry 9769b77c9b Demote log message to info.
This log is harmless, and can be common at relays if clients are sending XOFF.
2022-06-02 18:48:14 +00:00
Alex Xu (Hello71) 87b2ce6f84 Trigger OOS on bind failures (fixes #40597) 2022-05-21 21:30:06 -04:00
Alex Xu (Hello71) 15e95c3bda Use tor_event_free instead of event_del+tor_free
Using tor_free is wrong; event_free must be called for objects obtained from
event_new. Additionally, this slightly simplifies the code.

Also, add a static_assert to prevent further instances.
2022-04-20 00:14:25 -04:00
Mike Perry b2553bfba2 Use path type hint for Vegas queue parameters.
These parameters will vary depending on path length, especially for onions.
2022-02-22 19:28:35 +00:00
Mike Perry b6d5fbba7d Implement congestion control parameter negotiation 2022-02-22 19:28:34 +00:00
Nick Mathewson 93318ba5e2 Convert TODO into TODO-324 for better visibility. 2022-02-22 19:28:33 +00:00
Nick Mathewson a511718a30 Negotiated circuit parameters must pass from worker. 2022-02-22 19:28:33 +00:00
Nick Mathewson 244444e8b1 Add an exported struct to onion handshakes for circuits params
THis will eventually hold the congestion control parameters that we
negotiated, plus whatever else is relevant.
2022-02-22 19:28:33 +00:00
Nick Mathewson 358ce9a19d Add a size argument for the buffer on onion handshake functions 2022-02-22 19:28:33 +00:00
Mike Perry 0422eb26a7 Prop#324: Hook up flow control 2021-10-04 10:45:46 -04:00
David Goulet 819b69244a Support rate limiting of edge connections reads.
We only need to rate limit reading on edges for flow control, as per the rate
that comes in the XON from the other side. When we rate limit reading from the
edge source to this rate, we will only deliver that fast to the other side,
thus satisfying its rate request.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-10-04 10:45:46 -04:00
Mike Perry 5c3021be85 Make inbuf and outbuf len check params const 2021-07-30 12:57:31 -04:00
George Kadianakis 30a97d9bb3 Increase frequency of vg-lite callback to 15 minutes 2021-07-20 13:03:32 +03:00
George Kadianakis 314a6b42c5 Introduce vanguards-lite subsystem and some of its entry points
Co-authored-by: Mike Perry <mikeperry-git@torproject.org>
2021-07-01 18:15:55 +03:00
Nick Mathewson af560f21ec Merge branch 'maint-0.4.6' 2021-05-17 09:04:22 -04:00
Nick Mathewson fbd47a5078 Merge branch 'maint-0.4.5' into maint-0.4.6 2021-05-17 09:04:22 -04:00
David Goulet 5f009a59da conn: MetricsPort listener is a listener port
The connection type for the listener part was missing from the "is
connection a listener" function.

This lead to our periodic event that retries our listeners to keep
trying to bind() again on an already opened MetricsPort.

Closes #40370

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-05-12 15:13:50 -04:00
David Goulet 22861c2f40 relay: Add TCP port exhaustion metrics
Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-05-12 11:58:25 -04:00
Roger Dingledine 962b15aa6f fix some tiny typos 2021-03-24 18:13:46 -04:00
George Kadianakis 29f07a4e9d Merge branch 'mr/334' 2021-03-17 18:23:18 +02:00