Commit Graph

121 Commits

Author SHA1 Message Date
David Goulet
8b8873b759 Merge branch 'maint-0.4.7' 2022-11-08 15:26:44 -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
fff2b92682 Merge branch 'maint-0.4.7' 2022-10-27 10:46:54 -04:00
David Goulet
a1c40c8511 metrics: Fix naming and documentation
After nickm's review, minor changes to names and comments.

Related to #40194

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-10-27 10:45:08 -04:00
David Goulet
98b98fd3ce rephist: Track number of streams seen per type
Related to #40194

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-10-26 15:16:48 -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
Roger Dingledine
834745929a fix easy typos 2022-07-05 15:18:29 -04:00
David Goulet
9a47372096 rephist: Introduce a fraction and period for overload onionskin
This code was heavily reused from the previous DNS timeout work done in
ticket #40491 that was removed afterall from our code.

Closes #40560

Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-03-15 13:28:17 -04:00
Mike Perry
a0eeadfba2 Handle other places that use onion handshake type values
We want ntor and ntorv3 to use the same queues and stats.
2022-02-22 19:28:34 +00:00
David Goulet
bf1ed5c853 relay: Change DNS timeout label on MetricsPort
Change it from "timeout" to "tor_timeout" in order to indicate that the
DNS timeout is one from tor's DNS threshold and not the DNS server
itself.

Fixes #40527

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-12-13 10:49:00 -05:00
David Goulet
ad6a0ebb11 Merge branch 'ticket40527_046_01' into ticket40527_047_01 2021-12-13 10:48:54 -05:00
David Goulet
cda7acb35d relay: Don't make DNS timeout trigger an overload
Tor has configure libevent to attempt up to 3 times a DNS query for a
maximum of 5 seconds each. Once that 5 seconds has elapsed, it consider
the query "Timed Out" but tor only gets a timeout if all 3 attempts have
failed.

For example, using Unbound, it has a much higher threshold of timeout.
It is well defined in
https://www.nlnetlabs.nl/documentation/unbound/info-timeout/ and has
some complexity to it. But the gist is that if it times out, it will be
much more than 5 seconds.

And so the Tor DNS timeouts are more of a "UX issue" rather than a
"network issue". For this reason, we are removing this metric from the
overload general signal.

See https://gitlab.torproject.org/tpo/network-health/team/-/issues/139
for more information.

Fixes #40527

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-12-13 10:47:46 -05:00
Alexander Færøy
bd1c14f015 Merge branch 'maint-0.4.5' into maint-0.4.6 2021-10-21 12:35:36 +00:00
David Goulet
e7abab8782 relay: For metrics, don't report DNS errors by query type
This is due to the libevent bug
https://github.com/libevent/libevent/issues/1219 that fails to return
back the DNS record type on error.

And so, the MetricsPort now only reports the errors as a global counter
and not a per record type.

Closes #40490

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-10-20 10:40:56 -04:00
David Goulet
7a8108ea87 relay: Overload state on DNS timeout is now X% over Y secs
With this commit, we will only report a general overload state if we've
seen more than X% of DNS timeout errors over Y seconds. Previous
behavior was to report when a single timeout occured which is really too
small of a threshold.

The value X is a consensus parameters called
"overload_dns_timeout_scale_percent" which is a scaled percentage
(factor of 1000) so we can represent decimal points for X like 0.5% for
instance. Its default is 1000 which ends up being 1%.

The value Y is a consensus parameters called
"overload_dns_timeout_period_secs" which is the time period for which
will gather DNS errors and once over, we assess if that X% has been
reached ultimately triggering a general overload signal.

Closes #40491

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-10-20 10:00:03 -04:00
David Goulet
de907893be relay: Overload state on DNS timeout is now X% over Y secs
With this commit, we will only report a general overload state if we've
seen more than X% of DNS timeout errors over Y seconds. Previous
behavior was to report when a single timeout occured which is really too
small of a threshold.

The value X is a consensus parameters called
"overload_dns_timeout_scale_percent" which is a scaled percentage
(factor of 1000) so we can represent decimal points for X like 0.5% for
instance. Its default is 1000 which ends up being 1%.

The value Y is a consensus parameters called
"overload_dns_timeout_period_secs" which is the time period for which
will gather DNS errors and once over, we assess if that X% has been
reached ultimately triggering a general overload signal.

Closes #40491

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-10-20 09:09:25 -04:00
George Kadianakis
2b97c1dd34 Merge remote-tracking branch 'tor-gitlab/mr/385' 2021-06-28 14:11:46 +03:00
Nick Mathewson
d642da020e Merge remote-tracking branch 'tor-gitlab/mr/338' 2021-06-14 13:10:18 -04:00
Neel Chauhan
96b59fc4d3 Fix the fencepost issue when we check stability_last_downrated 2021-05-20 11:06:50 -07:00
David Goulet
d4fbfb54d4 rephist: Add a counter for the onioniskins stats
Current counters are reset every heartbeat. This commit adds two
counters for the assigned and dropped onionskins that are not reset so
they can be exported onto the MetricsPort.

Closes #40387

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-05-12 15:31:44 -04:00
David Goulet
d4718e4db9 relay: We might be noting down an unknown DNS error type
Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-05-12 14:44:04 -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
David Goulet
423910e01b dns: Gather DNS request statistics
We now keep track of all errors and total number of request seen. This
is so we can expose those values to the MetricsPort to help Exit
operators monitor the DNS requests and failures.

Related to #40367.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-05-12 11:58:25 -04:00
David Goulet
897344fddc relay: Add the global connection limit metrics
This emits two events (read and write) of the total number that the
global connection limit was reached.

Related to #40367

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-05-12 11:58:25 -04:00
David Goulet
8bb1874f1e relay: Add the onionskins processing metrics
With this commit, a relay now emits metrics event on the MetricsPort
related to how many onionskins were handled (processed or dropped) for
each handshake type.

Related to #40367

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-05-12 11:58:25 -04:00
Nick Mathewson
9d7fca2306 Make MinTimeToReportBandwidth a testing-only option (and rename it) 2021-05-11 15:49:00 -04:00
Nick Mathewson
6e140c530c Make client heartbeat stats tied to the heartbeat period.
Patch from cypherpunks. Closes #40330.
2021-05-11 10:08:52 -04:00
Alexander Færøy
705ea32c6e relay: Move "overload-general" from extra-info to server descriptor.
Fixes #40364

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-04-13 15:11:03 -04:00
Nick Mathewson
cd0e5a942e Terminate rep_hist_get_overload_stats_lines() with an NL.
We use it in router.c, where chunks are joined with "", not with
NL... so leaving off the terminating NL will lead to an unparseable
extrainfo.

Found by toralf. Bug not in any released Tor.
2021-03-18 13:30:49 -04:00
George Kadianakis
80da1761a6 Fix compiler warning about signed/unsigned conversion.
```
src/feature/stats/rephist.c: In function ‘overload_happened_recently’:
src/feature/stats/rephist.c:215:21: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
   if (overload_time > approx_time() - 3600 * n_hours) {
```
from https://gitlab.torproject.org/tpo/core/tor/-/issues/40341#note_2729364
2021-03-17 20:03:39 +02:00
George Kadianakis
29f07a4e9d Merge branch 'mr/334' 2021-03-17 18:23:18 +02:00
George Kadianakis
7740a8b5d4 Rate-limit counter should increase once per minute. 2021-03-17 18:22:38 +02:00
George Kadianakis
0a5ecb3342 Implement backbone of overload statistics.
- Implement overload statistics structure.
- Implement function that keeps track of overload statistics.
- Implement function that writes overload statistics to descriptor.
- Unittest for the whole logic.
2021-03-17 18:22:38 +02:00
Nick Mathewson
2ae24d003d Add a MinTimeToReportBandwidth option; make it 0 for testing networks.
This option changes the time for which a bandwidth measurement period
must have been in progress before we include it when reporting our
observed bandwidth in our descriptors.  Without this option, we only
consider a time period towards our maximum if it has been running
for a full day.  Obviously, that's unacceptable for testing
networks, where we'd like to get results as soon as possible.

For non-testing networks, I've put a (somewhat arbitrary) 2-hour
minimum on the option, since there are traffic analysis concerns
with immediate reporting here.

Closes #40337.
2021-03-17 08:45:37 -04:00
Nick Mathewson
444233c15e Run "make autostyle" in advance of new series. 2021-03-12 11:40:48 -05:00
Nick Mathewson
b5d08ddc09 Update copyrights to 2021, using "make update-copyright" 2021-03-12 11:39:23 -05:00
Nick Mathewson
100221baac Merge remote-tracking branch 'origin/master' 2021-02-23 08:43:19 -05:00
David Goulet
94b56eaa75 dos: New client connect rate detection
This is a new detection type which is that a relay can now control the rate of
client connections from a single address.

The mechanism is pretty simple, if the rate/burst is reached, the address is
marked for a period of time and any connection from that address is denied.

Closes #40253

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-02-22 15:48:42 -05:00
David Goulet
38649b4f95 relay: Remove dirport reachability self test
Regular relays are about to get their DirPort removed so that reachability
test is not useful anymore

Authorities will still use the DirPort but because network reentry towards
their DirPort is now denied network wide, this test is not useful anymore and
so it should simply be considered reachable at all time.

Part of #40282

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-02-22 08:52:06 -05:00
David Goulet
897ec8a34c hs: Remove v2 stats
We still keep v2 rendezvous stats since we will allow them until the network
has entirely phased out.

Related to #40266

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-02-19 13:20:49 -05:00
George Kadianakis
0bd12cfe99 Revert HSv3 stats string formatting to its old %u self.
The rest of rephist.c is doing the same kind of unsigned casting. For example
see rep_hist_format_buffer_stats() and rep_hist_format_exit_stats().

The previous switch to %ld made Appveyor fail:
    https://ci.appveyor.com/project/torproject/tor/builds/36118502
2020-11-23 13:35:26 +02:00
David Goulet
7c06707750 Merge branch 'tor-gitlab/mr/182' into master 2020-11-17 10:36:05 -05:00
Samanta Navarro
4a0cd79588 Fix typos.
Typos found with codespell.

Please keep in mind that this should have impact on actual code
and must be carefully evaluated:

src/core/or/lttng_circuit.inc
-    ctf_enum_value("CONTROLER", CIRCUIT_PURPOSE_CONTROLLER)
+    ctf_enum_value("CONTROLLER", CIRCUIT_PURPOSE_CONTROLLER)
2020-11-12 11:44:09 -05:00
George Kadianakis
0812ecd517 Add more docs about the HSv3 stat collection period. 2020-11-03 19:19:02 +02:00
George Kadianakis
810183aaf1 Improve string formatting in rep_hist_format_hs_stats(). 2020-11-03 19:15:01 +02:00
George Kadianakis
9a98d1da30 Switch v3_onions_seen_this_period to digest256map_t. 2020-11-03 19:14:57 +02:00
George Kadianakis
a96432ab06 Abstract v2/v3 "format stats to str" logic into a single function. 2020-11-03 11:12:17 +02:00
George Kadianakis
6178a64fcf Abstract v2/v3 "write stats to file" logic into a single function. 2020-11-03 11:12:17 +02:00