--- /dev/null
+ o Minor features (logging):
+ - Give more visibility to directory authority operators during the
+ consensus voting process and while processing relay descriptors.
+ Closes ticket 40245.
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'.)",
* 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;
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
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;
}
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;
*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;
}
/* 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,
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();
!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);
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 "
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 {
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;
const char *msg_out = NULL;
int status_out = 0;
- struct pending_vote_t *pv = dirvote_add_vote(VOTE_BODY_V3, 0,
+ struct pending_vote_t *pv = dirvote_add_vote(VOTE_BODY_V3, 0, "foo",
&msg_out, &status_out);
tt_assert(pv);
time_t now = 1441223455 -1;
dirauth_sched_recalculate_timing(mock_options, now);
- struct pending_vote_t *vote = dirvote_add_vote(VOTE_BODY_V3, 0,
+ struct pending_vote_t *vote = dirvote_add_vote(VOTE_BODY_V3, 0, "foo",
&msg_out, &status_out);
tt_assert(vote);
time_t now = 1441223455;
dirauth_sched_recalculate_timing(mock_options, now-1);
- struct pending_vote_t *vote = dirvote_add_vote(VOTE_BODY_V3, 0,
+ struct pending_vote_t *vote = dirvote_add_vote(VOTE_BODY_V3, 0, "foo",
&msg_out, &status_out);
tt_assert(vote);
/* Next voting interval */
vote = dirvote_add_vote(VOTE_BODY_V3,
- fetch_missing + vote_interval,
+ fetch_missing + vote_interval, "foo",
&msg_out, &status_out);
tt_assert(!vote);
tt_int_op(status_out, OP_EQ, 400);
/* Just after fetch missing */
vote = dirvote_add_vote(VOTE_BODY_V3,
- fetch_missing + 1,
+ fetch_missing + 1, "foo",
&msg_out, &status_out);
tt_assert(!vote);
tt_int_op(status_out, OP_EQ, 400);
/* On fetch missing */
vote = dirvote_add_vote(VOTE_BODY_V3,
- fetch_missing,
+ fetch_missing, "foo",
&msg_out, &status_out);
tt_assert(vote);
/* Between voting starts and fetch missing */
vote = dirvote_add_vote(VOTE_BODY_V3,
- voting_starts + 1,
+ voting_starts + 1, "foo",
&msg_out, &status_out);
tt_assert(vote);
/* On voting starts */
vote = dirvote_add_vote(VOTE_BODY_V3,
- voting_starts,
+ voting_starts, "foo",
&msg_out, &status_out);
tt_assert(vote);
/* Just before voting starts */
vote = dirvote_add_vote(VOTE_BODY_V3,
- voting_starts - 1,
+ voting_starts - 1, "foo",
&msg_out, &status_out);
tt_assert(vote);