[tor-commits] [tor/master] Sebastian's Changes to #1074
nickm at torproject.org
nickm at torproject.org
Fri Feb 25 17:33:29 UTC 2011
commit 82023f6a1ebb25e48a9ccfd9d68f5ebc5ea8c4c0
Author: AltF4 <altf4 at phx2600.org>
Date: Tue Feb 15 22:32:21 2011 -0700
Sebastian's Changes to #1074
Fixes some small mistakes with AltF4's #1074 fix
---
src/or/command.c | 34 ++++++++++++----------------------
1 files changed, 12 insertions(+), 22 deletions(-)
diff --git a/src/or/command.c b/src/or/command.c
index abe755e..c873516 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -44,8 +44,9 @@ uint64_t stats_n_destroy_cells_processed = 0;
uint64_t stats_n_versions_cells_processed = 0;
/** How many CELL_NETINFO cells have we received, ever? */
uint64_t stats_n_netinfo_cells_processed = 0;
-/** Have we received skew info from a NETINFO cell from a trusted dir, ever? */
-static int received_skew_from_trusted_dir = 0;
+/** Have we received a NETINFO cell from a trusted dir, ever? Used
+ * to decide what to do about time skew. */
+static int received_netinfo_from_trusted_dir = 0;
/* These are the main functions for processing cells */
static void command_process_create_cell(cell_t *cell, or_connection_t *conn);
@@ -620,20 +621,15 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
/* Act on apparent skew. */
/** Warn when we get a netinfo skew with at least this value.
- Ignore if we've already recieved skew info from a trusted dir */
+ Ignore if we've already received skew info from a trusted dir */
#define NETINFO_NOTICE_SKEW 3600
if (labs(apparent_skew) > NETINFO_NOTICE_SKEW &&
router_get_by_digest(conn->identity_digest) &&
- !received_skew_from_trusted_dir) {
+ !received_netinfo_from_trusted_dir) {
char dbuf[64];
- int severity;
/*XXXX be smarter about when everybody says we are skewed. */
- if (router_digest_is_trusted_dir(conn->identity_digest)) {
- severity = LOG_WARN;
- received_skew_from_trusted_dir = 1;
- }
- else
- severity = LOG_INFO;
+ int severity = router_digest_is_trusted_dir(conn->identity_digest) ?
+ LOG_WARN : LOG_INFO;
format_time_interval(dbuf, sizeof(dbuf), apparent_skew);
log_fn(severity, LD_GENERAL, "Received NETINFO cell with skewed time from "
"server at %s:%d. It seems that our clock is %s by %s, or "
@@ -647,25 +643,20 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
"CLOCK_SKEW SKEW=%ld SOURCE=OR:%s:%d",
apparent_skew,
conn->_base.address, conn->_base.port);
- }
- else { /* Connect to a trusted dir to trigger a NETINFO cell*/
+ } else { /* Connect to a trusted dir to trigger a NETINFO cell*/
routerstatus_t *any_trusted_dir =
router_pick_trusteddirserver(NO_AUTHORITY, 0);
- const tor_addr_t trusted_dir_addr;
+ tor_addr_t trusted_dir_addr;
tor_addr_from_ipv4n(&trusted_dir_addr, any_trusted_dir->addr);
connection_or_connect(&trusted_dir_addr,
any_trusted_dir->or_port,
any_trusted_dir->descriptor_digest);
-
}
}
- /* Mark a flag if we get a good skew from a trusted dir */
- if (labs(apparent_skew) < NETINFO_NOTICE_SKEW &&
- router_digest_is_trusted_dir(conn->identity_digest) &&
- !received_skew_from_trusted_dir) {
- received_skew_from_trusted_dir = 1;
- }
+ /* Note that we received a netinfo cell from a trusted directory */
+ if (router_digest_is_trusted_dir(conn->identity_digest))
+ received_netinfo_from_trusted_dir = 1;
/* XXX maybe act on my_apparent_addr, if the source is sufficiently
* trustworthy. */
@@ -679,4 +670,3 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
conn->_base.port, (int)conn->link_proto);
assert_connection_ok(TO_CONN(conn),time(NULL));
}
-
More information about the tor-commits
mailing list