From 95ac3ea5946f723ddab474fe229a872669aee47f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 17 May 2011 21:42:35 -0400 Subject: [PATCH 1/2] Don't build descriptors if ORPort auto is set and we have no OR listener This situation can happen easily if you set 'ORPort auto' and 'AccountingMax'. Doing so means that when you have no ORPort, you won't be able to set an ORPort in a descriptor, so instead you would just generate lots of invalid descriptors, freaking out all the time. Possible fix for 3216; fix on 0.2.2.26-beta. --- changes/bug3216 | 4 ++++ src/or/router.c | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 changes/bug3216 diff --git a/changes/bug3216 b/changes/bug3216 new file mode 100644 index 0000000000..599b5e162f --- /dev/null +++ b/changes/bug3216 @@ -0,0 +1,4 @@ + o Major bugfixes: + - Don't try to build descriptors if "ORPort auto" is set and we + don't know our actual ORPort yet. Fix for bug 3216; bugfix on + 0.2.2.26-beta. diff --git a/src/or/router.c b/src/or/router.c index 184715b750..464cba0dba 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -802,6 +802,8 @@ decide_to_advertise_dirport(or_options_t *options, uint16_t dir_port) return 0; if (!check_whether_dirport_reachable()) return 0; + if (!router_get_advertised_dir_port(options)) + return 0; /* Section two: reasons to publish or not publish that the user * might find surprising. These are generally config options that @@ -1136,6 +1138,8 @@ decide_if_publishable_server(void) return 0; if (authdir_mode(options)) return 1; + if (!router_get_advertised_or_port(options)) + return 0; return check_whether_orport_reachable(); } From 0e1fad648d22923d7455b94734df36585b8f624f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 24 May 2011 11:55:08 -0400 Subject: [PATCH 2/2] Don't try to build descriptors when router_get_advertised_or_port()==0 The previous attempt was incomplete: it told us not to publish a descriptor, but didn't stop us from generating one. Now we treat an absent OR port the same as not knowing our address. (This means that when we _do_ get an OR port, we need to mark the descriptor dirty.) More attempt to fix bug3216. --- src/or/connection.c | 26 +++++++++++++++++++------- src/or/router.c | 3 ++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/or/connection.c b/src/or/connection.c index 4d3e897185..a0330e90d7 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -1949,37 +1949,40 @@ retry_all_listeners(smartlist_t *replaced_conns, smartlist_t *new_conns) { or_options_t *options = get_options(); + int retval = 0; + const uint16_t old_or_port = router_get_advertised_or_port(options); + const uint16_t old_dir_port = router_get_advertised_dir_port(options); if (retry_listeners(CONN_TYPE_OR_LISTENER, options->ORListenAddress, options->ORPort, "0.0.0.0", replaced_conns, new_conns, options->ClientOnly, AF_INET)<0) - return -1; + retval = -1; if (retry_listeners(CONN_TYPE_DIR_LISTENER, options->DirListenAddress, options->DirPort, "0.0.0.0", replaced_conns, new_conns, options->ClientOnly, AF_INET)<0) - return -1; + retval = -1; if (retry_listeners(CONN_TYPE_AP_LISTENER, options->SocksListenAddress, options->SocksPort, "127.0.0.1", replaced_conns, new_conns, 0, AF_INET)<0) - return -1; + retval = -1; if (retry_listeners(CONN_TYPE_AP_TRANS_LISTENER, options->TransListenAddress, options->TransPort, "127.0.0.1", replaced_conns, new_conns, 0, AF_INET)<0) - return -1; + retval = -1; if (retry_listeners(CONN_TYPE_AP_NATD_LISTENER, options->NATDListenAddress, options->NATDPort, "127.0.0.1", replaced_conns, new_conns, 0, AF_INET)<0) - return -1; + retval = -1; if (retry_listeners(CONN_TYPE_AP_DNS_LISTENER, options->DNSListenAddress, options->DNSPort, "127.0.0.1", replaced_conns, new_conns, 0, AF_INET)<0) - return -1; + retval = -1; if (retry_listeners(CONN_TYPE_CONTROL_LISTENER, options->ControlListenAddress, options->ControlPort, "127.0.0.1", @@ -1993,7 +1996,16 @@ retry_all_listeners(smartlist_t *replaced_conns, AF_UNIX)<0) return -1; - return 0; + if (old_or_port != router_get_advertised_or_port(options) || + old_dir_port != router_get_advertised_dir_port(options)) { + /* Our chosen ORPort or DirPort is not what it used to be: the + * descriptor we had (if any) should be regenerated. (We won't + * automatically notice this because of changes in the option, + * since the value could be "auto".) */ + mark_my_descriptor_dirty("Chosen Or/DirPort changed"); + } + + return retval; } /** Return 1 if we should apply rate limiting to conn, diff --git a/src/or/router.c b/src/or/router.c index 464cba0dba..5fd7b06afa 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1423,7 +1423,8 @@ router_rebuild_descriptor(int force) if (desc_clean_since && !force) return 0; - if (router_pick_published_address(options, &addr) < 0) { + if (router_pick_published_address(options, &addr) < 0 || + router_get_advertised_or_port(options) == 0) { /* Stop trying to rebuild our descriptor every second. We'll * learn that it's time to try again when ip_address_changed() * marks it dirty. */