summaryrefslogtreecommitdiff
path: root/src/feature
diff options
context:
space:
mode:
Diffstat (limited to 'src/feature')
-rw-r--r--src/feature/dirauth/dirvote.c21
-rw-r--r--src/feature/dirauth/dirvote.h3
-rw-r--r--src/feature/dircache/dircache.c3
-rw-r--r--src/feature/dirclient/dirclient.c8
4 files changed, 25 insertions, 10 deletions
diff --git a/src/feature/dirauth/dirvote.c b/src/feature/dirauth/dirvote.c
index cf1135ba37..fa4d919aa9 100644
--- a/src/feature/dirauth/dirvote.c
+++ b/src/feature/dirauth/dirvote.c
@@ -2975,7 +2975,7 @@ dirvote_perform_vote(void)
if (!contents)
return -1;
- pending_vote = dirvote_add_vote(contents, 0, &msg, &status);
+ pending_vote = dirvote_add_vote(contents, 0, "self", &msg, &status);
tor_free(contents);
if (!pending_vote) {
log_warn(LD_DIR, "Couldn't store my own vote! (I told myself, '%s'.)",
@@ -3169,6 +3169,7 @@ add_new_cert_if_needed(const struct authority_cert_t *cert)
* only) */
pending_vote_t *
dirvote_add_vote(const char *vote_body, time_t time_posted,
+ const char *where_from,
const char **msg_out, int *status_out)
{
networkstatus_t *vote;
@@ -3226,6 +3227,14 @@ dirvote_add_vote(const char *vote_body, time_t time_posted,
goto err;
}
+ if (time_posted) { /* they sent it to me via a POST */
+ log_notice(LD_DIR, "%s posted a vote to me from %s.",
+ vi->nickname, where_from);
+ } else { /* I imported this one myself */
+ log_notice(LD_DIR, "Retrieved %s's vote from %s.",
+ vi->nickname, where_from);
+ }
+
/* Check if we received it, as a post, after the cutoff when we
* start asking other dir auths for it. If we do, the best plan
* is to discard it, because using it greatly increases the chances
@@ -3235,10 +3244,10 @@ dirvote_add_vote(const char *vote_body, time_t time_posted,
char tbuf1[ISO_TIME_LEN+1], tbuf2[ISO_TIME_LEN+1];
format_iso_time(tbuf1, time_posted);
format_iso_time(tbuf2, voting_schedule.fetch_missing_votes);
- log_warn(LD_DIR, "Rejecting posted vote from %s received at %s; "
+ log_warn(LD_DIR, "Rejecting %s's posted vote from %s received at %s; "
"our cutoff for received votes is %s. Check your clock, "
"CPU load, and network load. Also check the authority that "
- "posted the vote.", vi->address, tbuf1, tbuf2);
+ "posted the vote.", vi->nickname, vi->address, tbuf1, tbuf2);
*msg_out = "Posted vote received too late, would be dangerous to count it";
goto err;
}
@@ -3254,8 +3263,8 @@ dirvote_add_vote(const char *vote_body, time_t time_posted,
networkstatus_voter_info_t *vi_old = get_voter(v->vote);
if (fast_memeq(vi_old->vote_digest, vi->vote_digest, DIGEST_LEN)) {
/* Ah, it's the same vote. Not a problem. */
- log_info(LD_DIR, "Discarding a vote we already have (from %s).",
- vi->address);
+ log_notice(LD_DIR, "Discarding a vote we already have (from %s).",
+ vi->address);
if (*status_out < 200)
*status_out = 200;
goto discard;
@@ -3278,6 +3287,8 @@ dirvote_add_vote(const char *vote_body, time_t time_posted,
*msg_out = "OK";
return v;
} else {
+ log_notice(LD_DIR, "Discarding vote from %s because we have "
+ "a newer one already.", vi->address);
*msg_out = "Already have a newer pending vote";
goto err;
}
diff --git a/src/feature/dirauth/dirvote.h b/src/feature/dirauth/dirvote.h
index 4f48e45dc3..f9441773a7 100644
--- a/src/feature/dirauth/dirvote.h
+++ b/src/feature/dirauth/dirvote.h
@@ -99,6 +99,7 @@ void dirvote_dirreq_get_status_vote(const char *url, smartlist_t *items,
/* Storing signatures and votes functions */
struct pending_vote_t * dirvote_add_vote(const char *vote_body,
time_t time_posted,
+ const char *where_from,
const char **msg_out,
int *status_out);
int dirvote_add_signatures(const char *detached_signatures_body,
@@ -149,11 +150,13 @@ dirvote_dirreq_get_status_vote(const char *url, smartlist_t *items,
static inline struct pending_vote_t *
dirvote_add_vote(const char *vote_body,
time_t time_posted,
+ const char *where_from,
const char **msg_out,
int *status_out)
{
(void) vote_body;
(void) time_posted;
+ (void) where_from;
/* If the dirauth module is disabled, this should NEVER be called else we
* failed to safeguard the dirauth module. */
tor_assert_nonfatal_unreached();
diff --git a/src/feature/dircache/dircache.c b/src/feature/dircache/dircache.c
index 7f6452afbb..00bb0abf23 100644
--- a/src/feature/dircache/dircache.c
+++ b/src/feature/dircache/dircache.c
@@ -1708,7 +1708,8 @@ directory_handle_command_post,(dir_connection_t *conn, const char *headers,
!strcmp(url,"/tor/post/vote")) { /* v3 networkstatus vote */
const char *msg = "OK";
int status;
- if (dirvote_add_vote(body, approx_time(), &msg, &status)) {
+ if (dirvote_add_vote(body, approx_time(), TO_CONN(conn)->address,
+ &msg, &status)) {
write_short_http_response(conn, status, "Vote stored");
} else {
tor_assert(msg);
diff --git a/src/feature/dirclient/dirclient.c b/src/feature/dirclient/dirclient.c
index 74e68ac6be..a5dd856729 100644
--- a/src/feature/dirclient/dirclient.c
+++ b/src/feature/dirclient/dirclient.c
@@ -2419,8 +2419,8 @@ handle_response_fetch_status_vote(dir_connection_t *conn,
const char *msg;
int st;
- log_info(LD_DIR,"Got votes (body size %d) from server %s",
- (int)body_len, connection_describe_peer(TO_CONN(conn)));
+ log_notice(LD_DIR,"Got votes (body size %d) from server %s",
+ (int)body_len, connection_describe_peer(TO_CONN(conn)));
if (status_code != 200) {
log_warn(LD_DIR,
"Received http status code %d (%s) from server "
@@ -2430,7 +2430,7 @@ handle_response_fetch_status_vote(dir_connection_t *conn,
conn->requested_resource);
return -1;
}
- dirvote_add_vote(body, 0, &msg, &st);
+ dirvote_add_vote(body, 0, TO_CONN(conn)->address, &msg, &st);
if (st > 299) {
log_warn(LD_DIR, "Error adding retrieved vote: %s", msg);
} else {
@@ -2720,7 +2720,7 @@ handle_response_upload_vote(dir_connection_t *conn,
switch (status_code) {
case 200: {
- log_notice(LD_DIR,"Uploaded a vote to dirserver %s",
+ log_notice(LD_DIR,"Uploaded my vote to dirserver %s",
connection_describe_peer(TO_CONN(conn)));
}
break;