From d1874b433953f64b13a2feb0edc4bbff8940d503 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 26 Mar 2018 09:56:12 -0400 Subject: [PATCH 1/2] Make extend_info_from_node() more picky about node contents This update is needed to make it consistent with the behavior of node_awaiting_ipv6(), which doesn't believe in the addresses from routerinfos unless it actually plans to use those routerinfos. Fixes bug 25213; bugfix on b66b62fb7525cac1e1 in 0.3.3.1-alpha, which tightened up the definition of node_awaiting_ipv6(). --- changes/bug25213 | 5 +++++ src/or/circuitbuild.c | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 changes/bug25213 diff --git a/changes/bug25213 b/changes/bug25213 new file mode 100644 index 000000000..bb196ca72 --- /dev/null +++ b/changes/bug25213 @@ -0,0 +1,5 @@ + o Minor bugfixes (warnings, ipv6): + - Avoid a bug warning that could occur when trying to connect to + a relay over IPv6 on a Tor instance that downloads router descriptors, + but prefers to use microdescriptors. Fixes bug 25213; bugfix on + 0.3.3.1-alpha. diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 8fe6ba0e6..01921bac1 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -2857,8 +2857,18 @@ extend_info_from_node(const node_t *node, int for_direct_connect) tor_addr_port_t ap; int valid_addr = 0; - if (node->ri == NULL && (node->rs == NULL || node->md == NULL)) - return NULL; + const int is_bridge = node_is_a_configured_bridge(node); + const int we_use_mds = we_use_microdescriptors_for_circuits(get_options()); + + if (is_bridge || !we_use_mds) { + /* We need an ri in this case. */ + if (!node->ri) + return NULL; + } else { + /* Otherwise we need an md. */ + if (node->rs == NULL || node->md == NULL) + return NULL; + } /* Choose a preferred address first, but fall back to an allowed address. * choose_address returns 1 on success, but get_prim_orport returns 0. */ From 969a38a375f4e71fcb27bb24e36047824d0f3cc9 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 26 Mar 2018 09:57:39 -0400 Subject: [PATCH 2/2] Fix a unit test which was broken by the previous commit This test was expecting Tor to find and use routerinfos, but hadn't cleared the UseMicrodescriptors flag. Part of the fix for 25213. --- src/test/test_hs_service.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c index d62fcc8ca..2e5280610 100644 --- a/src/test/test_hs_service.c +++ b/src/test/test_hs_service.c @@ -1237,6 +1237,10 @@ test_build_update_descriptors(void *arg) node->is_running = node->is_valid = node->is_fast = node->is_stable = 1; } + /* We have to set thise, or the lack of microdescriptors for these + * nodes will make them unusable. */ + get_options_mutable()->UseMicrodescriptors = 0; + /* We expect to pick only one intro point from the node above. */ setup_full_capture_of_logs(LOG_INFO); update_all_descriptors(now);