Commit Graph

26190 Commits

Author SHA1 Message Date
teor
82010b0e2e parseconf: Add an authority IPv6 ORPort test
These tests don't actually exercise the authority IPv6 ORPort
self-add feature in 32822, but they do improve coverage of the
related config code.

Part of 32822.
2020-07-02 07:09:02 -04:00
teor
1f58b0ca26 router: Authorities add their own IPv6 to trusted dir servers
Authorities currently add themselves to the trusted dir servers list,
but if they have an IPv6 ORPort, they leave it out.

This commit makes authorities add their own IPv6 ORPort to the trusted
dir servers list.

Closes ticket 32822.
2020-07-02 07:09:02 -04:00
Nick Mathewson
538b25241e Merge remote-tracking branch 'dgoulet/ticket33235_045_01' 2020-07-01 16:27:12 -04:00
David Goulet
f152d5b15f test: Rename test_rep_hist to test_stats
The exposed interface is "stats/" thus make the unit tests clear that it is
testing that specific GETINFO command.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-01 12:31:40 -04:00
David Goulet
f30f53e099 Merge branch 'tor-github/pr/1907' 2020-07-01 12:26:19 -04:00
Neel Chauhan
4173876bc4 Add GETINFO "rephist/{tap,ntor}/onion_handshakes_{assigned/requested}" test 2020-07-01 12:00:53 -04:00
Neel Chauhan
4477317cbe control: Add a key to GETINFO to fetch the circuit onion handshake rephist values 2020-07-01 12:00:53 -04:00
Nick Mathewson
368156fcb7 Merge branch 'ticket34137' 2020-07-01 10:34:39 -04:00
Nick Mathewson
5d956d797b Add a comment explaining reachability vs bandwidth self-tests
This is in response to a question about why we don't always log
orport self-tests as reachability tests.

I'm not 100% convinced that bandwidth self-tests are still useful,
but that's an issue for another day. :)
2020-07-01 10:33:27 -04:00
David Goulet
b039d3e803 Merge branch 'tor-github/pr/1953' 2020-07-01 09:47:26 -04:00
George Kadianakis
0d02c053f8 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-07-01 12:55:03 +03:00
George Kadianakis
7f999203ce Merge branch 'maint-0.4.4' 2020-07-01 12:55:03 +03:00
George Kadianakis
1932a84ef5 Merge branch 'maint-0.4.2' into maint-0.4.3 2020-07-01 12:55:02 +03:00
George Kadianakis
38208185be Merge branch 'maint-0.3.5' into maint-0.4.2 2020-07-01 12:55:02 +03:00
George Kadianakis
9beae02713 Merge branch 'tor-github/pr/1766' into maint-0.3.5 2020-07-01 12:54:29 +03:00
Nick Mathewson
8f59b3e6f2 resolve_addr.c: remove a needless quote mark 2020-06-30 14:36:11 -04:00
David Goulet
ec57cbf179 addr: Document better is_local_addr_to_resolve_addr()
This function is about learning if a given address is local to us as in the
resolved address as a relay.

Closes #40009

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 13:50:01 -04:00
David Goulet
2ac2ba4e2c node: Rename addrs_in_same_network_family()
New name reflects that the function is only used to compare router addresses
in order to learn if they are in the same network.

The network check is /16 and /32 respectively for IPv4 and IPv6.

Related to #40009

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 13:48:22 -04:00
David Goulet
b14b1f2b1d addr: Don't guess our address if no Address lines are valid
If at least one Address line is given but invalid, we should not attempt to
guess our address.

This commit sends back the "bail" signal so find_my_address() can return an
error if the requested family doesn't exists but still an Address line is
found which is likely another family.

Fixed in #33235
Related to #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 12:13:23 -04:00
David Goulet
6f1423cb57 addr: Continue trying all Address options on resolve failure
When going over all Address lines from the configuration, continue to attempt
resolving other lines if one fails.

Before that, we would bail right away and never noticed the other Address
lines.

Fixed in #33235
Related to #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 12:12:04 -04:00
David Goulet
a8b8a1ee99 addr: Only attempt Address resolution on non parsable lines
In get_address_from_config(), we would attempt to resolve an Address line that
is not from the requested family but that line could be a valid address from
another family (v4 vs v6).

This makes it that we don't attempt to resolve a valid address from another
family.

Found with unit test config/find_my_address_mixed.

Fixed in #33235
Related to #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 12:05:56 -04:00
David Goulet
89c26f4cfd test: Mixed unit tests for find_my_address()
This unit tests validates the use of IPv4 _and_ IPv6 together as in multiple
option Address lines both addresses and hostnames.

Closes #33235

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 12:04:18 -04:00
Nick Mathewson
39830b6408 Downgrade "Bug: No entry found in extrainfo map" message.
This is not actually a bug!  It can happen for a bunch of reasons,
which all boil down to "trying to add an extrainfo for which we no
longer have the corresponding routerinfo".

Fixes #16016; bugfix on 0.2.6.3-alpha.
2020-06-30 11:54:13 -04:00
Nick Mathewson
2238b6320b Refactor reachability test logging: log exactly what we launch.
Previously we had two chains of logic for reachability tests: one
for launching them, and one for telling the user that we had
launched them.  Now, we simply have the launch code inform the user:
this way, we can't get out of sync.

Closes ticket 34137.
2020-06-30 11:12:46 -04:00
Alexander Færøy
dbb70d85bf Merge branch 'maint-0.3.5' into maint-0.4.2 2020-06-30 14:23:41 +00:00
Alexander Færøy
8697205be4 Merge branch 'tor-github/pr/1909' into maint-0.3.5 2020-06-30 14:23:17 +00:00
David Goulet
fe6b049651 test: Unit tests for find_my_address() IPv6
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 10:22:01 -04:00
Alexander Færøy
5a38c73f70 Merge branch 'tor-github/pr/1887' into maint-0.4.3 2020-06-30 14:19:28 +00:00
Alexander Færøy
881f50a9a9 Merge branch 'tor-github/pr/1806' into maint-0.4.2 2020-06-30 14:15:57 +00:00
Alexander Færøy
c9c4a3d0f6 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-06-30 14:03:04 +00:00
David Goulet
faba6909f8 test: Rename function to be IPv4 specific
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 09:56:14 -04:00
Alexander Færøy
8444fbe904 Merge branch 'tor-github/pr/1793' into maint-0.3.5 2020-06-30 13:55:39 +00:00
Alexander Færøy
483082b57b Merge branch 'maint-0.3.5' into maint-0.4.2 2020-06-30 13:48:49 +00:00
Alexander Færøy
c3ad2a1d23 Merge branch 'tor-github/pr/1785' into maint-0.3.5 2020-06-30 13:47:55 +00:00
Alexander Færøy
b0bfee8c78 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-06-30 13:37:20 +00:00
Alexander Færøy
bebdd2888f Merge remote-tracking branch 'nickm-github/bug32884_035' into maint-0.3.5 2020-06-30 13:35:13 +00:00
Alexander Færøy
96876d3ad7 Merge branch 'tor-github/pr/1940' 2020-06-30 01:22:44 +00:00
Nick Mathewson
d235e523d5 Merge branch 'ticket33290_v2_042' into maint-0.4.2 2020-06-29 13:57:13 -04:00
Nick Mathewson
a692b87f82 Merge remote-tracking branch 'tor-github/pr/1696/head' into maint-0.4.2 2020-06-29 13:53:27 -04:00
Nick Mathewson
0575a182a6 Merge remote-tracking branch 'tor-github/pr/1697/head' into maint-0.4.2 2020-06-29 13:48:25 -04:00
Nick Mathewson
216456299f Merge remote-tracking branch 'tor-github/pr/1722/head' into maint-0.4.2 2020-06-29 12:58:23 -04:00
Nick Mathewson
3008255aea Merge remote-tracking branch 'tor-github/pr/1829/head' into maint-0.4.3 2020-06-29 12:56:39 -04:00
Nick Mathewson
fd8ce812b0 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-06-29 12:55:35 -04:00
Nick Mathewson
0c0214bcc0 Merge remote-tracking branch 'tor-github/pr/1725/head' into maint-0.3.5 2020-06-29 12:55:27 -04:00
Alexander Færøy
f1932265fc Merge branch 'dgoulet/tor-ticket40008_045_01' 2020-06-29 14:09:53 +00:00
Nick Mathewson
e429ceb266 Add a TLS_ERROR bootstrap failure reason.
If our TLS connection fails for a "misc" reason, we don't need to
say that the reason is "misc" -- we can at least localize it to
the TLS module.

Part of a fix for #32622.
2020-06-26 10:59:59 -04:00
Nick Mathewson
d486c6cf74 Store errors from TLS write and handshake in the tls_error field.
Previously, we would only update this field when the error happened
during a read.

This will improves our reporting for our bootstrap status, and help
to address #32622.  The problem is not completely solved by this
patch, however: too many errors are still lumped into "MISC".
2020-06-26 10:58:53 -04:00
Nick Mathewson
5336ac2669 Move remaining CodeStructure.md contents into doxygen. 2020-06-26 10:11:42 -04:00
Nick Mathewson
a7aa97298b Remove special authority semantics for AssumeReachable.
AssumeReachable should only be about whether a relay thinks that it
is reachable itself.  But previously, we've had it also turn off
reachability checking of _other_ relays on authorities.
(Technically, reachability tests were still run, but we would ignore
the results.)

With this patch, there is a new AuthDirTestReachability option
(default 1) that controls whether authorities run reachability
tests.

Making this change allows us to have test networks where authorities
set AssumeReachable without disabling their reachability testing
entirely.

Closes ticket #34445.
2020-06-26 08:37:36 -04:00
Nick Mathewson
dbc2b75009 Merge branch 'assume_reachable_revamp' 2020-06-26 08:34:56 -04:00
Nick Mathewson
cb25f57724 Remove stub macro for router_new_consensus_params()
I had incorrectly believed that the router.c file was disabled when
we were building with relay mode disabled.
2020-06-26 08:32:33 -04:00
David Goulet
40922629fe addr: Look at /48 for IPv6 in is_local_addr()
Closes #33618

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-25 13:45:05 -04:00
David Goulet
069566b40a Merge branch 'tor-github/pr/1951' 2020-06-25 13:41:45 -04:00
David Goulet
374626c09b Merge branch 'tor-github/pr/1917' 2020-06-25 13:35:34 -04:00
Neel Chauhan
7b2ab93f65 Add test for fingerprint-ed25519 file 2020-06-25 13:35:15 -04:00
Neel Chauhan
ef563a8fef Add an fingerprint-ed25519 file to the data directory 2020-06-25 13:35:15 -04:00
David Goulet
dc4f3a219f Merge branch 'tor-github/pr/1948' 2020-06-25 10:13:04 -04:00
Nick Mathewson
50abc06d84 Remove now-unused OPTIONS_DUMP_DEFAULTS. 2020-06-25 10:02:17 -04:00
Nick Mathewson
62e1d983cf Deprecate the "--dump-config non-builtin" option
When it works, "non-builtin" doesn't do anything different from
"short".  (When it doesn't work, it gives an assertion failure.)

Closes ticket #33398.
2020-06-25 10:01:40 -04:00
David Goulet
c370b4a049 Merge branch 'maint-0.4.4' 2020-06-25 07:36:56 -04:00
David Goulet
fd5b2d0f1c Merge branch 'tor-github/pr/1935' 2020-06-24 15:48:47 -04:00
Neel Chauhan
c8fd7b7040 Make HSFETCH take the decoded length into account, not the base32 one 2020-06-24 15:47:57 -04:00
Nick Mathewson
edb023b1e7 Add an AssumeReachableIPv6 autobool option.
This option tells Tor that our IPv6 orport is reachable, and doesn't
need to be checked.

Closes the rest of 33224.
2020-06-24 15:25:34 -04:00
Nick Mathewson
6edf7f6710 Add two new networkstatus parameters to emulate AssumeReachable.
These parameters do not suppress checks, but they tell relays that
it's okay to publish even when those checks fail.

I have chosen lowercase hyphenated names, since these seem to be
more common in networkstatus params.

Closes #33224 and part of #34064.
2020-06-24 15:25:26 -04:00
Nick Mathewson
f9de0affd3 Rename router_should_skip_orport_reachability_check.
This was supposed to happen in #40012, but the command line was wrong.

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        router_should_skip_orport_reachability_check router_all_orports_seem_reachable
2020-06-24 15:25:17 -04:00
Nick Mathewson
5c5fb0fcca Move code into notify_after_networkstatus_changes().
The purpose of having this function was to inform other code that
the consensus has changed, so it should go there.
2020-06-24 15:25:12 -04:00
Nick Mathewson
93ccb3294b Make a bunch of networkstatus_t parameters constant.
This is part of refactoring our "notify the rest of the code that we
have a new consensus" code.
2020-06-24 15:25:07 -04:00
Nick Mathewson
366c695020 Add a control event for launching IPv6 ORPort checks. 2020-06-24 14:00:34 -04:00
David Goulet
86da0cfd36 Merge branch 'tor-github/pr/1945' 2020-06-24 13:51:51 -04:00
David Goulet
29a35d262c addr: Rename resolved_addr_is_local()
Better function name.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
59f5c3d263 addr: Refactor find_my_address() to simplify it
Instead of a complex if/else block, use a table of functions that have the
same interface and each of them attempt to find the address one after the
other.

Pointed out by nickm's during review.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
25a451bac7 addr: Set out parameters to NULL in resolve_addr.c
By doing this, a memory leak was found with "hostname_used" that could have
been overwritten by another function.

This commit changes that by making it a NULL string instead.

Found by nickm's review.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
5895aafe7e addr: Safeguard last resolved address index access
The last resolved address cache uses an index that is mapped to an address
family (AF_INET and AF_INET6).

This commit adds a conversion function from af to index and change the code to
use that all the time only.

In the process, this commit fixes a bug that the last resolved address
accessors were using the af value insted of the index.

Spotted by nickm during review

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
5f62ae2577 test: Modernize find_my_address() unit test
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
b76325190b addr: Remove resolve_my_address_v4()
Replace it by find_my_address() everywhere. This changes many parts of the
code that uses it to use a tor_addr_t instead of a plain uint32_t for IPv4.

Many changes to the unit test to also use the new interface.

Part #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
2f3b4e3888 addr: Refactor is_local_addr() to support IPv6
Series of changes:

  1. Rename function to reflect the namespace of the file.

  2. Use the new last resolved cache instead of the unused
     last_resolved_addr_v4 (which is also removed in this commit).

  3. Make the entire code base use the new resolved_addr_is_local() function.

You will notice that this function uses /24 to differentiate subnets where the
rest of tor uses /16 (including documentation of EnforceDistinctSubnets).
Ticket #40009 has been opened for that.

But that the moment, the function keeps looking at /24.

Part of #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
7795dd7ef6 addr: Refactor last resolved address cache accessors
Series of things done in this commit:

  1. Rename the functions to better reflect the namespace of the file.

  2. Make both reset and get function to operate on the last_resolved_addrs
     cache that is per family.

  3. Make the get function to take a tor_addr_t.

  4. Change all callsite to use the new convention.

Part of #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
b8042c9d9a addr: Make resolve_my_address_v4() use find_my_address()
In order to transition smoothly, maek resolve_my_address_v4() call the new
fancy find_my_address() with AF_INET.

Next commits should remove the use of resolve_my_address_v4() accross the code
to use find_my_address().

This commit is so the unit tests would be more easily fixed and port to the
new find_my_address() internals.

Part of #33233.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
9e85056de9 addr: New find_my_address() to support multiple address families
resolve_my_address() was beyond repair in terms of refactoring. Way too
complex and doing too many things.

This commit implements find_my_address() which in theory does the same as
resolve_my_address() but in a more clean, concise and modern way using the
tor_addr_t interface and for multiple address family.

The caller needs to pass the address family (IPv4 or IPv6) which this
interface supports. For both, a last resolved cache is used as well.

Implements #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
4af6e3b4dc Merge branch 'tor-github/pr/1947' 2020-06-24 13:49:03 -04:00
Nick Mathewson
fd3e0c561d Merge branch 'pr_1931_squashed' 2020-06-24 13:38:32 -04:00
Neel Chauhan
c3c7ef5125 Add routerset_contains_router() test 2020-06-24 13:38:27 -04:00
Neel Chauhan
0a3e6d81bb Make routerset_contains_router() support IPv6 2020-06-24 13:38:27 -04:00
Nick Mathewson
636cf9763a Replace router_should_skip_*() identifiers.
These identifiers are confusing and unreadable.  I think these
replacements should be better. Closes ticket #40012.

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        router_should_skip_orport_reachability_check_family router_orport_seems_reachable \
        router_should_skip_dirport_reachability_check router_dirport_seems_reachable \
        router_should_skip_dirport_reachability_check router_all_orports_seem_reachable
2020-06-24 13:25:49 -04:00
David Goulet
bc50f082bd Merge branch 'tor-github/pr/1944' 2020-06-24 10:48:14 -04:00
David Goulet
3adabaf3e9 tls: Make buf_read_from_tls() read at most bytes
The buf_read_from_tls() function was designed to read up to a certain number
of bytes a TLS socket using read_to_chunk_tls() which boils down to SSL_read()
(with OpenSSL, common case).

However, at the end of the loop, the returned number of bytes from
read_to_chunk_tls() was treated like the syscall read() for which if less
bytes than the total asked are returned, it signals EOF.

But, with SSL_read(), it returns up to a TLS record which can be less than
what was asked. The assumption that it was EOF was wrong which made the while
loop exiting before it was able to consume all requested bytes (at_most
parameter).

The general use case that Tor sees is that it will ask the network layer to
give it at most 16KB (that is roughly 32 cells) but because of KIST scheduler,
the highest possible TLS record we currently observe is 4096 bytes (4KB or 8
cells). Thus the loop would at best always return 8 cells even though much
more could be on the TLS socket. See ticket #40006 for more details.

Fixes #40006

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 10:47:53 -04:00
George Kadianakis
2eae59e475 Merge branch 'tor-github/pr/1939' 2020-06-24 17:22:53 +03:00
Neel Chauhan
1bd0494f8c Make summarize_protover_flags() handle NULL and empty string the same 2020-06-24 17:22:45 +03:00
David Goulet
2d91960540 Merge branch 'tor-github/pr/1942' 2020-06-24 07:44:41 -04:00
George Kadianakis
a3b573b392 Merge branch 'tor-github/pr/1943' 2020-06-23 20:31:44 +03:00
Mike Perry
220ed863ce Relocate CBT event to control_events.c
Needed to satisfy practracker.
2020-06-23 20:31:26 +03:00
Mike Perry
ad1f8b70b7 Mark state file dirty upon DROPTIMEOUTS command 2020-06-23 20:31:26 +03:00
George Kadianakis
68d848e244 Reinstate support for GUARD NEW/UP/DOWN control port events. 2020-06-23 19:48:37 +03:00
Nick Mathewson
65328fd4e7 Merge branch 'maint-0.4.4' 2020-06-23 12:29:47 -04:00
Nick Mathewson
318753f502 Merge branch 'ticket34382' into maint-0.4.4 2020-06-23 12:29:39 -04:00
Nick Mathewson
ac648fa307 Clarify logic in router_should_skip_orport_reachability_check_family()
The '!=' checks were confusing the issue of what the code was really
doing.
2020-06-23 11:24:20 -04:00
Nick Mathewson
b365179ee0 reachability_warnings_callback: simplify v4/v6_ok logic
Since "skip orport check" is the "and" of v4_ok and v6_ok, we can
just compute v4_ok and v6_ok once, to clarify that we don't enter
this block of code if they're both true.
2020-06-23 11:20:05 -04:00
David Goulet
d08d7e1535 addr: Rename last_resolved_addr to be v4 specific
Part of #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-23 09:25:36 -04:00
David Goulet
6da8c0b4fa addr: Rename resolve_my_address to be v4 specific
Part of #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-23 09:25:36 -04:00
David Goulet
47f9edde69 config: Change Address to be a LINELIST
With prop312, we want to support IPv4 and IPv6 thus multiple Address statement
(up to 2) will be accepted.

For this, "Address" option becomes a LINELIST so we can properly process the
IPv4 or/and IPv6.

Part of #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-23 09:25:36 -04:00