From 9c242e950b45ac67b2b741bc4e0c920a9a57cb43 Mon Sep 17 00:00:00 2001 From: rl1987 Date: Wed, 8 Aug 2018 18:47:43 +0300 Subject: [PATCH 1/3] Consider all routerinfo errors other than "not a server" transient --- src/feature/relay/router.c | 22 ++++++---------------- src/test/test_policy.c | 2 +- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index 0cc4887232..40839f2605 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -164,22 +164,12 @@ routerinfo_err_to_string(int err) int routerinfo_err_is_transient(int err) { - switch (err) { - case TOR_ROUTERINFO_ERROR_NO_EXT_ADDR: - return 1; - case TOR_ROUTERINFO_ERROR_CANNOT_PARSE: - return 1; - case TOR_ROUTERINFO_ERROR_NOT_A_SERVER: - return 0; - case TOR_ROUTERINFO_ERROR_DIGEST_FAILED: - return 0; // XXX: bug? - case TOR_ROUTERINFO_ERROR_CANNOT_GENERATE: - return 1; - case TOR_ROUTERINFO_ERROR_DESC_REBUILDING: - return 1; - } - - return 0; + /** + * For simplicity, we consider all errors other than + * "not a server" transient - see discussion on + * https://trac.torproject.org/projects/tor/ticket/27034 + */ + return err != TOR_ROUTERINFO_ERROR_NOT_A_SERVER; } /** Replace the current onion key with k. Does not affect diff --git a/src/test/test_policy.c b/src/test/test_policy.c index 4b1adc91f0..6a07e5b1f8 100644 --- a/src/test/test_policy.c +++ b/src/test/test_policy.c @@ -1706,7 +1706,7 @@ test_policies_getinfo_helper_policies(void *arg) rv = getinfo_helper_policies(NULL, "exit-policy/full", &answer, &errmsg); - tt_int_op(rv, OP_EQ, 0); + tt_int_op(rv, OP_EQ, -1); tt_ptr_op(answer, OP_EQ, NULL); tt_ptr_op(errmsg, OP_NE, NULL); tt_str_op(errmsg, OP_EQ, "Key digest failed"); From 7a1007861f978abe0703a8fe062ed3c983bccd49 Mon Sep 17 00:00:00 2001 From: rl1987 Date: Wed, 8 Aug 2018 18:56:27 +0300 Subject: [PATCH 2/3] Print stacktrace when crypto_pk_get_digest() fails in router_build_fresh_descriptor() --- src/feature/relay/router.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index 40839f2605..e4ec01af24 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -2350,8 +2350,8 @@ router_build_fresh_descriptor(routerinfo_t **r, extrainfo_t **e) } ri->identity_pkey = crypto_pk_dup_key(get_server_identity_key()); - if (crypto_pk_get_digest(ri->identity_pkey, - ri->cache_info.identity_digest)<0) { + if (BUG(crypto_pk_get_digest(ri->identity_pkey, + ri->cache_info.identity_digest) < 0)) { routerinfo_free(ri); return TOR_ROUTERINFO_ERROR_DIGEST_FAILED; } From 5f2e00241a35f7658bde4f9afb0a758588217e40 Mon Sep 17 00:00:00 2001 From: rl1987 Date: Wed, 8 Aug 2018 19:07:50 +0300 Subject: [PATCH 3/3] Add changes file --- changes/bug27034 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changes/bug27034 diff --git a/changes/bug27034 b/changes/bug27034 new file mode 100644 index 0000000000..bdb7d29c11 --- /dev/null +++ b/changes/bug27034 @@ -0,0 +1,6 @@ + o Minor bugfixes (controller): + - Consider all routerinfo errors other than "not a server" + to be transient for the purpose of "GETINFO exit-policy/*" + controller request. Print stacktrace in the unlikely case + of failing to recompute routerinfo digest. Fixes bug 27034; + bugfix on 0.3.4.1-alpha.