Commit Graph

26567 Commits

Author SHA1 Message Date
Nick Mathewson
26b257757b Bump to 0.4.4.4-rc-dev 2020-08-13 09:43:54 -04:00
Nick Mathewson
7b4716a762 Make test_glob() pass even when run as root.
Previously the test relied on not being able to look inside 000
directories, which is a thing root _can_ do.

Bug not in any released Tor version.
2020-08-12 20:36:23 -04:00
Nick Mathewson
9ef991dbe3 Use correct type for gl_closedir to avoid a compiler warning 2020-08-12 14:42:30 -04:00
Nick Mathewson
e151442037 Merge remote-tracking branch 'tor-gitlab/mr/62' 2020-08-12 14:37:21 -04:00
Nick Mathewson
f9bb49d870 Fix allocation counting in clean_v2_descs_as_dir test.
Without this fix, running this test on its own would fail.

Fixes bug 40099. Bugfix on ade5005853 in 0.2.8.1-alpha.
2020-08-12 14:25:46 -04:00
Daniel Pinto
60c436d14d Attempt to fix test_include.py on TravisCI #25140 2020-08-12 14:35:51 +01:00
George Kadianakis
347f87ae9d Merge branch 'maint-0.4.4' 2020-08-12 13:47:59 +03:00
George Kadianakis
5a1918d7e7 Merge remote-tracking branch 'tor-gitlab/mr/107' into maint-0.4.4 2020-08-12 13:47:34 +03:00
George Kadianakis
c591a0d246 Merge branch 'maint-0.4.4' 2020-08-12 13:23:33 +03:00
George Kadianakis
8e9edb93be Merge remote-tracking branch 'tor-gitlab/mr/104' into maint-0.4.4 2020-08-12 13:23:08 +03:00
Nick Mathewson
4fdec27a12 Remove extraneous EVENT_CONTROLLER_WAIT
This turned into a new StreamStatus value.

Closes #40092. Bug not in any released Tor.
2020-08-11 18:41:15 -04:00
Nick Mathewson
1770d1c216 bump version to 0.4.4.4-rc 2020-08-11 17:46:44 -04:00
Nick Mathewson
a02002dc99 Lower the minimum value for MaxMemInQueues to 64 MB for relays.
For clients, there is no minimum value; in both cases, we warn if
the value seems too low.

Closes ticket 24308.
2020-08-11 17:01:49 -04:00
Daniel Pinto
0b633b1f6d Improved documentation and comments #25140 2020-08-11 18:26:41 +01:00
Nick Mathewson
431dcc42e0 Rename argument to compute_real_max_mem_in_queues() 2020-08-11 12:59:07 -04:00
Nick Mathewson
d76f8457f3 Merge remote-tracking branch 'tor-gitlab/mr/119' into maint-0.4.4 2020-08-11 12:40:02 -04:00
Nick Mathewson
11961f0bc5 Merge remote-tracking branch 'tor-gitlab/mr/119' 2020-08-11 12:39:30 -04:00
George Kadianakis
b705cfa024 Merge remote-tracking branch 'tor-gitlab/mr/111' 2020-08-11 15:12:43 +03:00
George Kadianakis
f971a8fbad Merge branch 'mr/105' 2020-08-11 15:04:15 +03:00
Nick Mathewson
7df52b71bf Only log port self-testing message when we are _starting_ to test.
(Unlike approaches in earlier versions of Tor, this one logs if and
only if we are launching a test, and we haven't said that we're
testing this port.)

Fixes bug 40068; bug not in any released version.

Closes #40068.
2020-08-11 15:02:44 +03:00
George Kadianakis
b8003fbe99 Merge branch 'maint-0.4.4' 2020-08-11 14:54:26 +03:00
George Kadianakis
ab9c35f043 Merge remote-tracking branch 'tor-gitlab/mr/102' into maint-0.4.4 2020-08-11 14:53:03 +03:00
George Kadianakis
9316ca9f06 Remove a BUG() that could normally trigger in edge-cases. 2020-08-11 14:42:18 +03:00
Nick Mathewson
069946852a Merge branch 'maint-0.4.4' 2020-08-10 19:33:07 -04:00
Nick Mathewson
7d80bf80fe Merge branch 'maint-0.4.3' into maint-0.4.4 2020-08-10 19:33:07 -04:00
Nick Mathewson
f3fcc89d05 Merge branch 'maint-0.4.2' into maint-0.4.3 2020-08-10 19:33:06 -04:00
Nick Mathewson
68f8250cbb Merge branch 'maint-0.3.5' into maint-0.4.2 2020-08-10 19:32:49 -04:00
Nick Mathewson
e873c7e893 small code tweaks to try to work around debian stable complaints 2020-08-10 19:20:05 -04:00
Nick Mathewson
3eb9331133 Merge remote-tracking branch 'tor-gitlab/mr/110' 2020-08-10 14:51:12 -04:00
Nick Mathewson
24c721de37 Log number of inbound/outbound ipv4/6 conns as part of heartbeat
Closes #29113
2020-08-07 10:45:29 -04:00
Nick Mathewson
6fde1548f2 Revise test_status to use log testing helpers.
This change lets us make these tests much shorter and easier to
maintain.
2020-08-07 10:42:12 -04:00
Nick Mathewson
b417594dbc Replace several C identifiers for ticket 18106.
We used to have a single boolean, "FascistFirewall".  Ages ago, in
tickets #17840 and #9067, we added an improved "ReachableAddresses"
mechanism.  It's time to rename related identifiers in the code for
consistency.  This closes #18106.

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        fascist_firewall_allows_address reachable_addr_allows \
        fascist_firewall_use_ipv6 reachable_addr_use_ipv6 \
        fascist_firewall_prefer_ipv6_impl reachable_addr_prefer_ipv6_impl \
        fascist_firewall_prefer_ipv6_orport reachable_addr_prefer_ipv6_orport \
        fascist_firewall_prefer_ipv6_dirport reachable_addr_prefer_ipv6_dirport \
        fascist_firewall_allows_address_addr reachable_addr_allows_addr \
        fascist_firewall_allows_address_ap reachable_addr_allows_ap \
        fascist_firewall_allows_base reachable_addr_allows_base \
        fascist_firewall_allows_ri_impl reachable_addr_allows_ri_impl \
        fascist_firewall_allows_rs_impl reachable_addr_allows_rs_impl \
        fascist_firewall_allows_rs reachable_addr_allows_rs \
        fascist_firewall_allows_md_impl reachable_addr_allows_md_impl \
        fascist_firewall_allows_node reachable_addr_allows_node \
        fascist_firewall_allows_dir_server reachable_addr_allows_dir_server \
        fascist_firewall_choose_address_impl reachable_addr_choose_impl \
        fascist_firewall_choose_address reachable_addr_choose \
        fascist_firewall_choose_address_base reachable_addr_choose_base \
        fascist_firewall_choose_address_rs reachable_addr_choose_from_rs \
        fascist_firewall_choose_address_ls reachable_addr_choose_from_ls \
        fascist_firewall_choose_address_node reachable_addr_choose_from_node \
        fascist_firewall_choose_address_dir_server reachable_addr_choose_from_dir_server
2020-08-05 16:34:45 -04:00
George Kadianakis
afd88ee87f Merge remote-tracking branch 'tor-gitlab/mr/88' 2020-08-05 14:57:20 +03:00
Neel Chauhan
d1413e04f8 ipv6: Specialize GETINFO address interface for v4 and v6 2020-08-04 13:59:49 -07:00
Nick Mathewson
1d0695fe7e Improve ratelimit message to list true interval.
Previous message would say "N messages in the last T seconds", but
would give an inaccurate number for N.

We now give an accurate number, rounded up to the nearest 60 seconds.

Closes #19431.
2020-08-04 13:56:28 -04:00
Nick Mathewson
04926126ee Merge remote-tracking branch 'tor-gitlab/mr/100' 2020-08-04 13:28:51 -04:00
Nick Mathewson
08de260682 Merge branch 'bug40083_035' into bug40083_042
Fixes conflicts due to code movement.
2020-08-04 13:10:16 -04:00
Nick Mathewson
62361cc698 Launch early reachability tests once a minute, not once a second.
This fixes bug 40083, which was introduced in 9f31908a in
0.2.8.1-alpha.
2020-08-04 13:05:07 -04:00
Daniel Pinto
ccdd0d801a Minor style improvements. #30045 2020-08-03 20:08:17 +01:00
Nick Mathewson
aef9c0f580 Merge branch 'ticket40081_035' into ticket40081_044
Resolves conflicts:
	src/core/or/channel.c
        src/test/test_channel.c
2020-08-03 11:49:09 -04:00
Nick Mathewson
435f31aed3 Remove channel_is_canonical_is_reliable()
This function once served to let circuits continue to be built over
version-1 link connections.  But such connections are long-obsolete,
and it's time to remove this check.

Closes #40081.
2020-08-03 11:25:37 -04:00
Nick Mathewson
ea876ab00e Wipe address strings from connections before freeing them them.
This is a defense-in-depth fix; closes 6198.
2020-08-03 10:15:08 -04:00
Nick Mathewson
5b9508c9a5 Add a tor_str_wipe_and_free() function.
Frequently we want to do

    if (s) {
      memwipe(s, 0, sizeof(s));
      tor_free(s);
    }

and it's good to have a way to do this concisely.
2020-08-03 10:11:03 -04:00
George Kadianakis
e069b0af4b Merge branch 'maint-0.4.4' 2020-08-03 16:49:05 +03:00
George Kadianakis
18d2c7c5d7 Merge remote-tracking branch 'tor-gitlab/mr/79' into maint-0.4.4 2020-08-03 16:48:52 +03:00
Nick Mathewson
ce57404a42 Fix comment on protover_list_is_invalid 2020-08-03 08:57:21 -04:00
Nick Mathewson
efc969e862 Rename protover_contains_long_protocol_names to protover_list_is_invalid
This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        protover_contains_long_protocol_names protover_list_is_invalid
2020-08-03 08:55:17 -04:00
Nick Mathewson
d1fda62d11 Merge remote-tracking branch 'tor-gitlab/mr/94' 2020-08-03 08:54:03 -04:00
Nick Mathewson
3e3b0b0443 Merge remote-tracking branch 'tor-github/pr/1986/head' 2020-08-03 08:33:22 -04:00
Nick Mathewson
efe8a98817 Fix a leak-on-failure on test_get_bandwidth_lines()
Spotted by coverity. This is CID 1465571.
2020-08-01 09:29:08 -04:00
Daniel Pinto
1474ab3395 Add --format argument to --key-expiration option. #30045 2020-08-01 01:08:37 +01:00
Neel Chauhan
837e0c4dc9 Code simplifications for AP_CONN_STATE_CONTROLLER_WAIT 2020-07-31 09:21:43 -07:00
MrSquanchee
bb585c5e37
test_stats : Removed CONFIG_PRIVATE
Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
2020-07-31 21:12:29 +05:30
MrSquanchee
a93c3d7a8d
Added tests for bandwidth functions
Added tests for
1. commit_max
2. advance_obs
3. add_obs
4. rep_hist_fill_bandwidth_history
5. rep_hist_get_bandwidth_lines

 (Lightly edited by nickm to use new names from bwhist refactoring.)

Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
2020-07-31 21:12:16 +05:30
MrSquanchee
708f51637f
Added tests for bandwidth functions
Added tests for
1. commit_max
2. advance_obs
3. add_obs
4. rep_hist_fill_bandwidth_history
5. rep_hist_get_bandwidth_lines

Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
2020-07-31 21:10:54 +05:30
Nick Mathewson
b5068e4826 Extract bw_array_t and related constants into a header.
This will be used for testing.

Partially reproduces work by MrSquanchee in #33812.
2020-07-31 10:46:52 -04:00
Alexander Færøy
e78a7450a2 Merge branch 'maint-0.4.2' into maint-0.4.3 2020-07-31 02:03:34 +00:00
Alexander Færøy
4e684c8695 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-07-31 02:03:34 +00:00
Nick Mathewson
4c810a6abe Merge branch 'bug40076_044' 2020-07-30 14:35:06 -04:00
Nick Mathewson
b4400e2093 Merge branch 'bug40076_043' into bug40076_044 2020-07-30 14:28:11 -04:00
Nick Mathewson
69d7752937 Merge branch 'bug40076_042' into bug40076_043 2020-07-30 14:27:29 -04:00
Nick Mathewson
c2d5ec5e43 Merge branch 'maint-0.4.2' into bug40076_042 2020-07-30 14:27:29 -04:00
Nick Mathewson
c4742b89b2 Fix a bug in buf_move_all() when the input buffer is empty.
We found this in #40076, after we started using buf_move_all() in
more places.  Fixes bug #40076; bugfix on 0.3.3.1-alpha.  As far as
I know, the crash only affects master, but I think this warrants a
backport, "just in case".
2020-07-30 14:24:25 -04:00
Nick Mathewson
0a588821cb Add unit test for buf_move_all(), including a failing case
The failing case is #if'd out for now, but will be fixed in the next
commit.

Testing for a fix for #40076.
2020-07-30 14:19:32 -04:00
George Kadianakis
155e0dee49 Merge branch 'tor-gitlab/mr/84' 2020-07-30 19:49:25 +03:00
Nick Mathewson
219edc9ab1 Handle ORPort auto when logging about removed orports.
Closes #40075
2020-07-30 19:46:44 +03:00
George Kadianakis
2bb9acca73 Write unittest for #40065.
Make the unit test pass by including an explicit IPv6 port and an
implicit IPv4 port.  See comments for more details.
2020-07-30 19:46:39 +03:00
Nick Mathewson
fc5fe094b1 Fix segfault and logic error in remove_duplicate_orports()
This function tried to modify an array in place, but did it in a
pretty confusing and complicated way.  I've revised it to follow a
much more straightforward approach.

Fixes bug #40065.
2020-07-30 19:46:02 +03:00
Nick Mathewson
fcf4954cc8 Add a unit test for write_str_to_file_if_not_equal() 2020-07-30 10:46:15 -04:00
Nick Mathewson
f3e5b283ad test_util.c: Extract utime() function.
We need this to manipulate mtimes, but only in this file.
2020-07-30 10:46:15 -04:00
Neel Chauhan
67a62ccf51 Use write_str_if_not_equal() for onion services 2020-07-30 10:46:15 -04:00
Neel Chauhan
c212578bf0 Introduce write_str_if_not_equal() 2020-07-30 10:46:15 -04:00
Nick Mathewson
9164d7c75e Merge branch 'maint-0.4.4' 2020-07-29 12:37:08 -04:00
Nick Mathewson
3b8bf743ae Merge branch 'maint-0.4.2' into maint-0.4.3 2020-07-29 12:37:07 -04:00
Nick Mathewson
cdb0e6c252 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-07-29 12:37:07 -04:00
Nick Mathewson
8c92d44622 Merge remote-tracking branch 'tor-gitlab/mr/68' into maint-0.4.4 2020-07-29 12:35:57 -04:00
Nick Mathewson
75f94ea1ec Merge remote-tracking branch 'tor-github/pr/1987/head' 2020-07-29 10:58:47 -04:00
Alexander Færøy
eba2870d18 Merge branch 'maint-0.4.4' 2020-07-29 13:58:14 +00:00
Alexander Færøy
8e690ce736 Merge remote-tracking branch 'tor-gitlab/mr/85' into maint-0.4.4 2020-07-29 13:57:47 +00:00
Alexander Færøy
109063185b Merge branch 'tor-gitlab/mr/73_squashed' 2020-07-29 13:34:24 +00:00
Nick Mathewson
3cb9a9b8ce Remove the connection_t.outbuf_flushlen field
This was once used for rate-limiting, but now it's only for
accounting.  It hasn't served a useful purpose in a long time.

Closes ticket 33097.
2020-07-29 13:33:35 +00:00
Daniel Pinto
eab8e7af52 Fix startup crash with seccomp sandbox enabled #40072
Fix crash introduced in #40020. On startup, tor calls
check_private_dir on the data and key directories. This function
uses open instead of opendir on the received directory. Data and
key directoryes are only opened here, so the seccomp rule added
should be for open instead of opendir, despite the fact that they
are directories.
2020-07-29 00:34:08 +01:00
Nick Mathewson
dcc60294ad Use _lseeki64() on windows.
Fixes bug 31036; bugfix on 0.2.1.8-alpha when we moved the logging
system to use posix fds.
2020-07-28 11:30:47 -04:00
Nick Mathewson
0a38e02fb3 bump to 0.4.4.3-alpha-dev 2020-07-27 19:15:15 -04:00
Nick Mathewson
98d84587a8 Fix documentation of cache_failure_intro_lookup
Closes ticket 17793
2020-07-27 14:22:10 -04:00
Nick Mathewson
31eba7f009 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-07-27 12:56:19 -04:00
Nick Mathewson
64d7b28298 Merge branch 'maint-0.4.4' 2020-07-27 12:56:19 -04:00
Nick Mathewson
97d0cb83ed Merge branch 'maint-0.4.2' into maint-0.4.3 2020-07-27 12:56:18 -04:00
Nick Mathewson
c0bc30b6f0 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-07-27 12:56:18 -04:00
Nick Mathewson
95914ceb57 Bump to 0.4.4.3-alpha 2020-07-27 08:32:56 -04:00
Nick Mathewson
010387e4bd Merge branch '40068_maybe' 2020-07-24 15:15:46 -04:00
David Goulet
564a9a54a1 fallbackdir: Remove all three Digitalcourage3 relays
They are about to be shutdown in September.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-24 14:56:07 -04:00
Nick Mathewson
2299b31f40 Don't let a bad IPv6 orport stop our IPv4 bandwidth test.
Specifically: do not close IPv4 bandwidth-testing circuits just
because our IPv6 orport is unreachable.

Attempted fix for #40068.
2020-07-24 14:50:42 -04:00
David Goulet
ad9806b539 relay: Publish IPv4 descriptor on guessed IPv6 reachability failure
On an IPv6 reachability failure test, if the address was configured, don't
publish the descriptor and log warn. If the address was auto discovered, still
publish the descriptor.

Closes #33247.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-24 12:18:07 -04:00
David Goulet
fda0fa02bf relay: Add a cache that tracks which address was configured
Related to #33247

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-24 11:32:49 -04:00
David Goulet
bf2b1e7a6f relay: Turn find address "method_used" into enum
Enum allows us to easily compare what is being returned but also better
semantic to the code.

Related #33247

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-24 11:32:49 -04:00
Nick Mathewson
9d922b8eaa Merge branch 'maint-0.4.4' 2020-07-23 10:10:32 -04:00
Nick Mathewson
6354b70e49 Merge branch 'maint-0.4.2' into maint-0.4.3 2020-07-23 10:09:14 -04:00
Nick Mathewson
3bcbd69a77 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-07-23 10:09:14 -04:00
Nick Mathewson
07934664c5 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-07-23 10:09:14 -04:00
David Goulet
6f19e67c98 fallbackdir: Update list for 2020
Closes #40061

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-23 10:05:11 -04:00
Nick Mathewson
b3112a6d26 Merge branch 'remove-padding-fix-7869-v2' 2020-07-23 08:26:44 -04:00
Daniel Pinto
d72618eb7f Remove padding from ntor-onion-key #7869 2020-07-23 08:25:22 -04:00
David Goulet
9cd20e8276 Merge branch 'tor-gitlab/mr/75' 2020-07-23 07:16:05 -04:00
David Goulet
884ccd6996 Merge branch 'maint-0.4.4' 2020-07-22 16:14:19 -04:00
David Goulet
1ee164afc2 Merge branch 'tor-gitlab/mr/77' into maint-0.4.4 2020-07-22 16:14:11 -04:00
David Goulet
492625badf Merge branch 'tor-gitlab/mr/74' 2020-07-22 16:09:11 -04:00
David Goulet
053e02a487 addr: Always set addr_out to UNSPEC in find_my_address
Related #40058

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-22 16:09:07 -04:00
David Goulet
65c7d33d33 relay: Support IPv6 when checking if our address changed
Now support IPv4 _and_ IPv6.

This also cleans up nicely the function that was moving IPv4 addresses from
uint32_t to tor_addr_t.

Fixes #40058

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-22 16:09:07 -04:00
Nick Mathewson
ceb6585a4b Treat all extorport connections with un-set addresses as remote
Without this fix, if an PT forgets to send a USERADDR command, that
results in a connection getting treated as local for the purposes of
rate-limiting.

If the PT _does_ use USERADDR, we still believe it.

Closes ticket 33747.
2020-07-22 15:21:56 -04:00
Nick Mathewson
faa752f3c9 Adjust the rules for warning about too many connections.
Previously we tolerated up to 1.5 connections for every relay we
were connected to, and didn't warn if we had fewer than 5
connections total.

Now we tolerate up to 1.5 connections per relay, and up to 4
connections per authority, and we don't warn at all when we have
fewer than 25 connections total.

Fixes bug 33880, which seems to have been provoked by our #17592
change in 0.3.5.
2020-07-22 14:45:03 -04:00
David Goulet
f0da04bb7b relay: Limit Directory Authority Addresses to Address and ORPort
Closes #33239

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-22 14:17:21 -04:00
David Goulet
6de860497e log: Don't use twice fmt_addr() in same logging statement
Fixes #40059

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-22 11:09:21 -04:00
David Goulet
a4c5b7d742 Rename check_server_ports to check_and_prune_server_ports
This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        check_server_ports check_and_prune_server_ports
2020-07-21 15:51:48 -04:00
David Goulet
28c1b60476 relay: Change router_can_extend_over_ipv6() to look at configured port
In routerconf_find_ipv6_or_ap(), we check if the returned ORPort is internal
but not for listening. This means that IPv6 [::] is considered internal.

Thus, we can't use it, we have to look directly at the configured address and
port and if they are valid, we do consider that we have a valid IPv6 ORPort
and that we can thus extend in IPv6.

Related #33246

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-21 15:50:16 -04:00
David Goulet
803e769fb2 relay: Remove possible ORPorts duplicate from parsed list
Now that tor automatically binds to IPv4 _and_ IPv6, in order to avoid
breaking configurations, we sanitize the parsed lists for duplicate ORPorts.
It is possible to happen because we still allow this configuration;

  ORPort 9888
  ORPort [4242::1]:9888

Meaning that the first ORPort value will bind to 0.0.0.0:9888 _and_ [::]:9888
which would lead to an error when attempting to bind on [4242::1]:9888.
However, that configuration is accepted today and thus we must not break it.

To remedy, we now sanitize the parsed list and prioritize an ORPort that has
an explicit address over the global one.

A warning is emitted if such configuration pattern is found. This is only for
the ORPort.

Related to #33246

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-21 15:48:05 -04:00
David Goulet
c3a0f75796 relay: Automatically Enable an IPv6 ORPort
This commit makes it that if the ORPort is set with a single port, it will
bind to both global listen IPv4 and IPv6 addresses.

To pin an "ORPort <PORT>" to be IPv4 or IPv6, the IPv4Only/IPv6Only flags are
honored thus this will _only_ bind on IPv6 for that port value:

  ORPort 9050 IPv6Only
    Results in: [::]:9050

  ORPort 9051 IPv4Only
    Results in: [0.0.0.0]:9051

Attempting to configure an explicit IPv4 address with IPv6Only flag is an
error and vice versa.

Closes #33246

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-21 15:48:05 -04:00
Nick Mathewson
088100d698 Rename router_get_advertised_*() functions.
These now (or_port and dir_port) now have "find" names, since they
look at the portcfg first, then at the actual ports from the
listeners.

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        router_get_advertised_or_port routerconf_find_or_port \
        router_get_advertised_ipv6_or_ap routerconf_find_ipv6_or_ap \
        router_has_advertised_ipv6_orport routerconf_has_ipv6_orport \
        router_get_advertised_dir_port routerconf_find_dir_port
2020-07-21 12:59:03 -04:00
Nick Mathewson
f478080bd0 Combine router_get_advertised_or_port{,by_af_}() functions 2020-07-21 12:47:33 -04:00
Nick Mathewson
39146383fc Rename get_primary_dir_port()
Also, remove get_primary_or_port() -- nothing used it.
2020-07-21 12:47:09 -04:00
Nick Mathewson
f57c31e4be Extract shared parts of portcfg_get_first_advertised_*() 2020-07-21 12:47:09 -04:00
Nick Mathewson
fda9d7f5ed Rename get_first_advertised_{addr,port}_by_type_af().
Rationale: these don't actually give the first advertised
address/port, but instead give us the first such port that we are
_configured_ to advertise.  Putting them in a portconf_ namespace
therefore makes sense.

Similarly, there are no other functions that get the first
configured advertised addr/port, so the "by_type_af()" part is needless.

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        get_first_advertised_addr_by_type_af portconf_get_first_advertised_addr \
        get_first_advertised_port_by_type_af portconf_get_first_advertised_port
2020-07-21 12:02:01 -04:00
Nick Mathewson
e8497bfaa7 Merge remote-tracking branch 'tor-gitlab/mr/64' 2020-07-21 09:33:41 -04:00
Nick Mathewson
7d0e64016e Merge branch 'maint-0.4.4' 2020-07-21 09:29:13 -04:00
Nick Mathewson
5cd85feaa7 Merge remote-tracking branch 'tor-gitlab/mr/68' into maint-0.4.4 2020-07-21 09:29:03 -04:00
Nick Mathewson
2ee33765ae Merge branch 'maint-0.4.4' 2020-07-21 09:24:27 -04:00
Nick Mathewson
95d4bff784 Merge remote-tracking branch 'tor-gitlab/mr/67' into maint-0.4.4 2020-07-21 09:24:15 -04:00
Nick Mathewson
7a2fe93529 Merge remote-tracking branch 'tor-gitlab/mr/70' 2020-07-21 09:03:38 -04:00
David Goulet
c3d113a464 relay: Add AddressDisableIPv6 torrc option
This option controls if a tor relay will attempt address auto discovery and
thus ultimately publish an IPv6 ORPort in the descriptor.

Behavior is from proposal 312 section 3.2.6.

Closes #33245

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-21 08:18:31 -04:00
David Goulet
fbee4d25cc relay: Don't publish IPv6 if found ORPort is 0
The ORPort can be IPv4Only which means that even if we can auto discover an
IPv6 address, we should not publish it because it would have an ORPort of 0.

Fixes #40054

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-21 08:12:47 -04:00
Daniel Pinto
d75e7daaab Fix seccomp sandbox rules for openat #27315
The need for casting negative syscall arguments depends on the
glibc version. This affects the rules for the openat syscall which
uses the constant AT_FDCWD that is defined as a negative number.
This commit adds logic to only apply the cast when necessary, on
glibc versions from 2.27 onwards.
2020-07-20 22:35:05 +01:00
Daniel Pinto
d28bfb2cd5 Fix seccomp sandbox rules for opening directories #40020
Different versions of glibc use either open or openat for the
opendir function. This commit adds logic to use the correct rule
for each glibc version, namely:
- Until 2.14 open is used
- From 2.15 to to 2.21 openat is used
- From 2.22 to 2.26 open is used
- From 2.27 onwards openat is used
2020-07-20 22:30:13 +01:00
Daniel Pinto
c79b4397d3 Fix seccomp sandbox rules for openat #27315
The need for casting negative syscall arguments depends on the
glibc version. This affects the rules for the openat syscall which
uses the constant AT_FDCWD that is defined as a negative number.
This commit adds logic to only apply the cast when necessary, on
glibc versions from 2.27 onwards.
2020-07-20 22:30:00 +01:00
Nick Mathewson
f5d773c600 Merge remote-tracking branch 'tor-gitlab/mr/51' 2020-07-20 16:50:32 -04:00
Nick Mathewson
d6570eaf5d Merge remote-tracking branch 'tor-gitlab/mr/59' 2020-07-20 16:37:11 -04:00
David Goulet
a576f37cfe relay: Don't log at warn level when we find an address
Dirauth code use the warn log severity when calling find_my_address() which
made it that every time we would find an address, it would log a warning.

These are not needed below info level and thus set them to info level. An IP
change is set to notice by default.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
75434a1df1 relay: Use flags in relay_find_addr_to_publish()
Instead of a boolean saying "cache_only" add the concept of flags so we add
semantic through out the code and allow ourselves to have more options in the
future.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
230293c169 control: With GETINFO, don't trigger an address resolve
Tell the relay find address interface to only use the cache so we don't
trigger an address resolve everytime the "GETINFO address" is called.

Related #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
433a1949e8 relay: Handle dir address suggestion with new interface
We now use relay_address_new_suggestion() when a suggested address is received
from a directory.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
0b89eba7d5 addr: Use false/true with relay_find_addr_to_publish()
Previous development introduced the error of using 0/1 for a boolean
parameter. Fix that everywhere

Related #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
a37a027e61 test: Unit test for relay_find_addr_to_publish()
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
c98cffbc07 test: Unit test for relay_address_new_suggestion()
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
8178a34b80 relay: Remove router_pick_published_address()
Unused at this commit.

Closes #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
4a41761101 test: Move unit tests to new find address interface
Remove use of router_pick_published_address() and use
relay_find_addr_to_publish instead.

Related to #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
75a2e7fcb7 control: GETINFO address/ use new find address API
At the moment, this command only returns the IPv4. Do so by using the new
relay_find_addr_to_publish().

New commands to return IPv4 and IPv6 will be done with the work in tor#40039.

Related to #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
1a347b4790 relay: Deciding to fetch from authority, use new find address API
Use the new relay_has_address_set() interface when deciding if we need to
fetch directory information from an authority as a relay.

If no IPv4 address is found, we'll proceed with a fetch so we can learn our
address in the HTTP header or NETINFO cell that a trusted authority will send
us back.

Related to #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
35871e46e8 relay: Don't lookup our address before rebuilding our descriptor
Tor periodic events have moved to a role base model where relays have specific
events. One of those is to rebuild the descriptor and that is ran every
minute.

This removes the call to router_rebuild_descriptor() from
router_get_my_routerinfo_with_err() because that is the only code path that
can call for a rebuild every second.

Instead, when we mark the descriptor as dirty, immediately reschedule the
descriptor check periodic event so it can be rebuilt that way instead of
randomly when router_get_my_routerinfo_with_err() is called.

Related to #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
502f3f5afe relay: Publish IPv4/IPv6 from resolved address cache
When a relay builds a new descriptor, use the new relay_find_addr_to_publish()
interface to find the address to publish per family.

This commit also make the check for address consistency to also work for a
configured IPv6 for which before it was IPv4 only.

Related to #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
9f61a6bdc3 pt: Use new address discovery interface when creating extrainfo
In case the transport has no usable address configured (likely 0.0.0.0 or
[::]), attempt to find the IPv4 and on failure, fallback to the IPv6. If none
are found, a log error is emitted and the transport is skiped.

Related to #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00
David Goulet
b239f178a2 addr: New function to find address to publish
In order for a relay to find which address to publish in its descriptor,
router_pick_published_address() is used. However, that function only supports
AF_INET and uses the directory server suggested address discovery mechanism.

This new function uses a new interface so that the caller can request an
address family and get the tor_addr_t object. Furthermore, it drops the use of
directory servers address discovery (tor#33244) and instead uses the new
suggested cache that is populated at the moment from data in the NETINFO cell
coming from the directory authorities.

At this commit, function is unused.

Related to #40025

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20 14:54:13 -04:00