From 0c41ae18329644828ff247b00a7f4e99e3f38312 Mon Sep 17 00:00:00 2001 From: "teor (Tim Wilson-Brown)" Date: Mon, 9 May 2016 14:26:13 -0400 Subject: [PATCH 1/3] Add a comment to have_enough_path_info() Comment only change --- src/or/circuituse.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 31003ea095..fa6c666ea1 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -1674,7 +1674,11 @@ circuit_launch(uint8_t purpose, int flags) return circuit_launch_by_extend_info(purpose, NULL, flags); } -/* DOCDOC */ +/* Do we have enough descriptors to build paths? + * If need_exit is true, return 1 if we can build exit paths. + * (We need at least one Exit in the consensus to build exit paths.) + * If need_exit is false, return 0 if we can build internal paths. + */ static int have_enough_path_info(int need_exit) { From c2817774c28a40f76890b68775097596d14e035e Mon Sep 17 00:00:00 2001 From: "teor (Tim Wilson-Brown)" Date: Mon, 9 May 2016 14:29:07 -0400 Subject: [PATCH 2/3] Allow directories in small networks to bootstrap Skip DirPort checks when the consensus has no exits. Resolves #19003, bugfix on #18050 in 0.2.8.1-alpha. --- changes/bug19003 | 5 +++++ src/or/router.c | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 changes/bug19003 diff --git a/changes/bug19003 b/changes/bug19003 new file mode 100644 index 0000000000..d9ef23d24c --- /dev/null +++ b/changes/bug19003 @@ -0,0 +1,5 @@ + o Minor bugfixes (small networks): + - Allow directories in small networks to bootstrap by + skipping DirPort checks when the consensus has no exits. + Resolves #19003, bugfix on #18050 in 0.2.8.1-alpha. + Patch by teor. diff --git a/src/or/router.c b/src/or/router.c index 68bcf1326e..dd8421094d 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1551,6 +1551,8 @@ proxy_mode(const or_options_t *options) * and * - We believe both our ORPort and DirPort (if present) are reachable from * the outside; or + * - We believe both our ORPort is reachable from the outside, and we can't + * check our DirPort because the consensus has no exits; or * - We are an authoritative directory server. */ static int @@ -1568,7 +1570,13 @@ decide_if_publishable_server(void) return 1; if (!router_get_advertised_or_port(options)) return 0; + /* If there are no exits in the consensus, but have enough descriptors to + * build internal paths, we can't possibly verify our DirPort. + * This only happens in small networks without exits. */ + if (router_have_consensus_path() == CONSENSUS_PATH_INTERNAL) + return check_whether_orport_reachable(); + /* If there are exits in the consensus, use an exit to check our DirPort. */ return check_whether_orport_reachable() && check_whether_dirport_reachable(); } From b8b5bccfd9f350cd796a8bcd6b79b9d303a79e11 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Wed, 11 May 2016 13:03:49 -0400 Subject: [PATCH 3/3] refactor the #19003 patches fix the logic in one of the comments --- src/or/circuituse.c | 2 +- src/or/router.c | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/or/circuituse.c b/src/or/circuituse.c index fa6c666ea1..a4b580104f 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -1677,7 +1677,7 @@ circuit_launch(uint8_t purpose, int flags) /* Do we have enough descriptors to build paths? * If need_exit is true, return 1 if we can build exit paths. * (We need at least one Exit in the consensus to build exit paths.) - * If need_exit is false, return 0 if we can build internal paths. + * If need_exit is false, return 1 if we can build internal paths. */ static int have_enough_path_info(int need_exit) diff --git a/src/or/router.c b/src/or/router.c index dd8421094d..3f94703a26 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1549,9 +1549,9 @@ proxy_mode(const or_options_t *options) * and * - We have ORPort set * and - * - We believe both our ORPort and DirPort (if present) are reachable from + * - We believe our ORPort and DirPort (if present) are reachable from * the outside; or - * - We believe both our ORPort is reachable from the outside, and we can't + * - We believe our ORPort is reachable from the outside, and we can't * check our DirPort because the consensus has no exits; or * - We are an authoritative directory server. */ @@ -1570,14 +1570,15 @@ decide_if_publishable_server(void) return 1; if (!router_get_advertised_or_port(options)) return 0; - /* If there are no exits in the consensus, but have enough descriptors to - * build internal paths, we can't possibly verify our DirPort. - * This only happens in small networks without exits. */ - if (router_have_consensus_path() == CONSENSUS_PATH_INTERNAL) - return check_whether_orport_reachable(); - - /* If there are exits in the consensus, use an exit to check our DirPort. */ - return check_whether_orport_reachable() && check_whether_dirport_reachable(); + if (!check_whether_orport_reachable()) + return 0; + if (router_have_consensus_path() == CONSENSUS_PATH_INTERNAL) { + /* All set: there are no exits in the consensus (maybe this is a tiny + * test network), so we can't check our DirPort reachability. */ + return 1; + } else { + return check_whether_dirport_reachable(); + } } /** Initiate server descriptor upload as reasonable (if server is publishable,