From f2a344e3974eeba860434884bd70f8d11cca94ea Mon Sep 17 00:00:00 2001 From: "teor (Tim Wilson-Brown)" Date: Thu, 24 Mar 2016 10:38:07 +1100 Subject: [PATCH 1/2] Downgrade IP version warnings to avoid filling logs Downgrade logs and backtraces about IP versions to info-level. Only log backtraces once each time tor runs. Assists in diagnosing bug 18351; bugfix on c3cc8e16e in tor-0.2.8.1-alpha. Reported by "sysrqb" and "Christian", patch by "teor". --- changes/bug18351 | 6 ++++++ src/or/connection.c | 8 ++++++-- src/or/directory.c | 21 ++++++++++++++++----- src/or/routerlist.c | 9 ++++++--- 4 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 changes/bug18351 diff --git a/changes/bug18351 b/changes/bug18351 new file mode 100644 index 0000000000..f2e21eabd9 --- /dev/null +++ b/changes/bug18351 @@ -0,0 +1,6 @@ + o Minor bugfixes (logging): + - Downgrade logs and backtraces about IP versions to + info-level. Only log backtraces once each time tor runs. + Assists in diagnosing bug 18351; bugfix on c3cc8e16e in + tor-0.2.8.1-alpha. + Reported by "sysrqb" and "Christian", patch by "teor". diff --git a/src/or/connection.c b/src/or/connection.c index 4e915f1213..fc9ec13c41 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -1793,11 +1793,15 @@ connection_connect_log_client_use_ip_version(const connection_t *conn) /* Check if we broke a mandatory address family restriction */ if ((must_ipv4 && tor_addr_family(&real_addr) == AF_INET6) || (must_ipv6 && tor_addr_family(&real_addr) == AF_INET)) { - log_warn(LD_BUG, "%s connection to %s violated ClientUseIPv%s 0.", + static int logged_backtrace = 0; + log_info(LD_BUG, "%s connection to %s violated ClientUseIPv%s 0.", conn->type == CONN_TYPE_OR ? "OR" : "Dir", fmt_addr(&real_addr), options->ClientUseIPv4 == 0 ? "4" : "6"); - log_backtrace(LOG_WARN, LD_BUG, "Address came from"); + if (!logged_backtrace) { + log_backtrace(LOG_INFO, LD_BUG, "Address came from"); + logged_backtrace = 1; + } } /* Bridges are allowed to break IPv4/IPv6 ORPort preferences to connect to diff --git a/src/or/directory.c b/src/or/directory.c index e4feda44fc..c95944b6f2 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -674,13 +674,17 @@ directory_choose_address_routerstatus(const routerstatus_t *status, /* We rejected both addresses. This isn't great. */ if (!have_or && !have_dir) { - log_warn(LD_BUG, "Rejected all OR and Dir addresses from %s when " + static int logged_backtrace = 0; + log_info(LD_BUG, "Rejected all OR and Dir addresses from %s when " "launching a directory connection to: IPv4 %s OR %d Dir %d " "IPv6 %s OR %d Dir %d", routerstatus_describe(status), fmt_addr32(status->addr), status->or_port, status->dir_port, fmt_addr(&status->ipv6_addr), status->ipv6_orport, status->dir_port); - log_backtrace(LOG_WARN, LD_BUG, "Addresses came from"); + if (!logged_backtrace) { + log_backtrace(LOG_INFO, LD_BUG, "Addresses came from"); + logged_backtrace = 1; + } return -1; } @@ -1100,14 +1104,21 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port, if (or_connection && (!or_addr_port->port || tor_addr_is_null(&or_addr_port->addr))) { + static int logged_backtrace = 0; log_warn(LD_DIR, "Cannot make an OR connection without an OR port."); - log_backtrace(LOG_WARN, LD_BUG, "Address came from"); + if (!logged_backtrace) { + log_backtrace(LOG_INFO, LD_BUG, "Address came from"); + logged_backtrace = 1; + } return; } else if (!or_connection && (!dir_addr_port->port || tor_addr_is_null(&dir_addr_port->addr))) { + static int logged_backtrace = 0; log_warn(LD_DIR, "Cannot make a Dir connection without a Dir port."); - log_backtrace(LOG_WARN, LD_BUG, "Address came from"); - + if (!logged_backtrace) { + log_backtrace(LOG_INFO, LD_BUG, "Address came from"); + logged_backtrace = 1; + } return; } diff --git a/src/or/routerlist.c b/src/or/routerlist.c index bc5e2e9133..f065c3c202 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1560,9 +1560,13 @@ router_picked_poor_directory_log(const routerstatus_t *rs) /* We couldn't find a node, or the one we have doesn't fit our preferences. * This might be a bug. */ if (!rs) { - log_warn(LD_BUG, "Firewall denied all OR and Dir addresses for all relays " + static int logged_backtrace = 0; + log_info(LD_BUG, "Firewall denied all OR and Dir addresses for all relays " "when searching for a directory."); - log_backtrace(LOG_WARN, LD_BUG, "Node search initiated by"); + if (!logged_backtrace) { + log_backtrace(LOG_INFO, LD_BUG, "Node search initiated by"); + logged_backtrace = 1; + } } else if (!fascist_firewall_allows_rs(rs, FIREWALL_OR_CONNECTION, 1) && !fascist_firewall_allows_rs(rs, FIREWALL_DIR_CONNECTION, 1) ) { @@ -1573,7 +1577,6 @@ router_picked_poor_directory_log(const routerstatus_t *rs) fmt_addr32(rs->addr), rs->or_port, rs->dir_port, fmt_addr(&rs->ipv6_addr), rs->ipv6_orport, rs->dir_port); - log_backtrace(LOG_INFO, LD_BUG, "Node search initiated by"); } } From 355f78364a7d1fa3c2de0a93e68153ae65526e02 Mon Sep 17 00:00:00 2001 From: "teor (Tim Wilson-Brown)" Date: Thu, 24 Mar 2016 20:59:49 +1100 Subject: [PATCH 2/2] Clarify ReachableAddress log messages Make it clearer that they are about outgoing connection attempts. Specify the options involved where they were missing from one log message. Clarify a comment. --- src/or/connection.c | 9 +++++---- src/or/directory.c | 13 ++++++++----- src/or/routerlist.c | 7 ++++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/or/connection.c b/src/or/connection.c index fc9ec13c41..82fc1ba8b7 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -1794,7 +1794,7 @@ connection_connect_log_client_use_ip_version(const connection_t *conn) if ((must_ipv4 && tor_addr_family(&real_addr) == AF_INET6) || (must_ipv6 && tor_addr_family(&real_addr) == AF_INET)) { static int logged_backtrace = 0; - log_info(LD_BUG, "%s connection to %s violated ClientUseIPv%s 0.", + log_info(LD_BUG, "Outgoing %s connection to %s violated ClientUseIPv%s 0.", conn->type == CONN_TYPE_OR ? "OR" : "Dir", fmt_addr(&real_addr), options->ClientUseIPv4 == 0 ? "4" : "6"); @@ -1814,9 +1814,10 @@ connection_connect_log_client_use_ip_version(const connection_t *conn) /* Check if we couldn't satisfy an address family preference */ if ((!pref_ipv6 && tor_addr_family(&real_addr) == AF_INET6) || (pref_ipv6 && tor_addr_family(&real_addr) == AF_INET)) { - log_info(LD_NET, "Connection to %s doesn't satisfy ClientPreferIPv6%sPort " - "%d, with ClientUseIPv4 %d, and fascist_firewall_use_ipv6 %d " - "(ClientUseIPv6 %d and UseBridges %d).", + log_info(LD_NET, "Outgoing connection to %s doesn't satisfy " + "ClientPreferIPv6%sPort %d, with ClientUseIPv4 %d, and " + "fascist_firewall_use_ipv6 %d (ClientUseIPv6 %d and UseBridges " + "%d).", fmt_addr(&real_addr), conn->type == CONN_TYPE_OR ? "OR" : "Dir", conn->type == CONN_TYPE_OR ? options->ClientPreferIPv6ORPort diff --git a/src/or/directory.c b/src/or/directory.c index c95944b6f2..7f307267e3 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -672,12 +672,13 @@ directory_choose_address_routerstatus(const routerstatus_t *status, FIREWALL_DIR_CONNECTION, 0, use_dir_ap); - /* We rejected both addresses. This isn't great. */ + /* We rejected all addresses in the relay's status. This means we can't + * connect to it. */ if (!have_or && !have_dir) { static int logged_backtrace = 0; log_info(LD_BUG, "Rejected all OR and Dir addresses from %s when " - "launching a directory connection to: IPv4 %s OR %d Dir %d " - "IPv6 %s OR %d Dir %d", routerstatus_describe(status), + "launching an outgoing directory connection to: IPv4 %s OR %d " + "Dir %d IPv6 %s OR %d Dir %d", routerstatus_describe(status), fmt_addr32(status->addr), status->or_port, status->dir_port, fmt_addr(&status->ipv6_addr), status->ipv6_orport, status->dir_port); @@ -1105,7 +1106,8 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port, if (or_connection && (!or_addr_port->port || tor_addr_is_null(&or_addr_port->addr))) { static int logged_backtrace = 0; - log_warn(LD_DIR, "Cannot make an OR connection without an OR port."); + log_warn(LD_DIR, "Cannot make an outgoing OR connection without an OR " + "port."); if (!logged_backtrace) { log_backtrace(LOG_INFO, LD_BUG, "Address came from"); logged_backtrace = 1; @@ -1114,7 +1116,8 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port, } else if (!or_connection && (!dir_addr_port->port || tor_addr_is_null(&dir_addr_port->addr))) { static int logged_backtrace = 0; - log_warn(LD_DIR, "Cannot make a Dir connection without a Dir port."); + log_warn(LD_DIR, "Cannot make an outgoing Dir connection without a Dir " + "port."); if (!logged_backtrace) { log_backtrace(LOG_INFO, LD_BUG, "Address came from"); logged_backtrace = 1; diff --git a/src/or/routerlist.c b/src/or/routerlist.c index f065c3c202..10246230f3 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1561,8 +1561,9 @@ router_picked_poor_directory_log(const routerstatus_t *rs) * This might be a bug. */ if (!rs) { static int logged_backtrace = 0; - log_info(LD_BUG, "Firewall denied all OR and Dir addresses for all relays " - "when searching for a directory."); + log_info(LD_BUG, "Wanted to make an outgoing directory connection, but " + "all OR and Dir addresses for all relays were not reachable. " + "Check ReachableAddresses, ClientUseIPv4, and similar options."); if (!logged_backtrace) { log_backtrace(LOG_INFO, LD_BUG, "Node search initiated by"); logged_backtrace = 1; @@ -1571,7 +1572,7 @@ router_picked_poor_directory_log(const routerstatus_t *rs) && !fascist_firewall_allows_rs(rs, FIREWALL_DIR_CONNECTION, 1) ) { log_info(LD_BUG, "Selected a directory %s with non-preferred OR and Dir " - "addresses for launching a connection: " + "addresses for launching an outgoing connection: " "IPv4 %s OR %d Dir %d IPv6 %s OR %d Dir %d", routerstatus_describe(rs), fmt_addr32(rs->addr), rs->or_port,