Loading changes/prop275 0 → 100644 +12 −0 Original line number Diff line number Diff line o Minor features (directory authority): - Add a new consensus method in which the "published" times on router entries in a microdesc consensus are all set to a meaningless fixed date. Doing this will make the download size for compressed microdesc consensus diffs much smaller. Part of ticket 40130; implements proposal 275. o Minor features (network documents): - Clients and relays no longer track the "published on" time declared for relays in any consensus documents. When reporting this time on the control port, they instead report a fixed date in the future. Part of ticket 40130. src/feature/dirauth/dirvote.c +26 −10 Original line number Diff line number Diff line Loading @@ -390,7 +390,8 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key, rsf = routerstatus_format_entry(&vrs->status, vrs->version, vrs->protocols, NS_V3_VOTE, vrs); vrs, -1); if (rsf) smartlist_add(chunks, rsf); Loading Loading @@ -618,8 +619,8 @@ compare_vote_rs(const vote_routerstatus_t *a, const vote_routerstatus_t *b) * the descriptor digests matched, so somebody is making SHA1 collisions. */ #define CMP_FIELD(utype, itype, field) do { \ utype aval = (utype) (itype) a->status.field; \ utype bval = (utype) (itype) b->status.field; \ utype aval = (utype) (itype) a->field; \ utype bval = (utype) (itype) b->field; \ utype u = bval - aval; \ itype r2 = (itype) u; \ if (r2 < 0) { \ Loading @@ -638,8 +639,8 @@ compare_vote_rs(const vote_routerstatus_t *a, const vote_routerstatus_t *b) CMP_EXACT))) { return r; } CMP_FIELD(unsigned, int, ipv4_orport); CMP_FIELD(unsigned, int, ipv4_dirport); CMP_FIELD(unsigned, int, status.ipv4_orport); CMP_FIELD(unsigned, int, status.ipv4_dirport); return 0; } Loading Loading @@ -692,10 +693,10 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method, } else { if (cur && (cur_n > most_n || (cur_n == most_n && cur->status.published_on > most_published))) { cur->published_on > most_published))) { most = cur; most_n = cur_n; most_published = cur->status.published_on; most_published = cur->published_on; } cur_n = 1; cur = rs; Loading @@ -703,7 +704,7 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method, } SMARTLIST_FOREACH_END(rs); if (cur_n > most_n || (cur && cur_n == most_n && cur->status.published_on > most_published)) { (cur && cur_n == most_n && cur->published_on > most_published)) { most = cur; // most_n = cur_n; // unused after this point. // most_published = cur->status.published_on; // unused after this point. Loading Loading @@ -2047,7 +2048,6 @@ networkstatus_compute_consensus(smartlist_t *votes, memcpy(rs_out.descriptor_digest, rs->status.descriptor_digest, DIGEST_LEN); tor_addr_copy(&rs_out.ipv4_addr, &rs->status.ipv4_addr); rs_out.published_on = rs->status.published_on; rs_out.ipv4_dirport = rs->status.ipv4_dirport; rs_out.ipv4_orport = rs->status.ipv4_orport; tor_addr_copy(&rs_out.ipv6_addr, &alt_orport.addr); Loading @@ -2055,6 +2055,21 @@ networkstatus_compute_consensus(smartlist_t *votes, rs_out.has_bandwidth = 0; rs_out.has_exitsummary = 0; time_t published_on = rs->published_on; /* Starting with this consensus method, we no longer include a meaningful published_on time for microdescriptor consensuses. This makes their diffs smaller and more compressible. We need to keep including a meaningful published_on time for NS consensuses, however, until 035 relays are all obsolete. (They use it for a purpose similar to the current StaleDesc flag.) */ if (consensus_method >= MIN_METHOD_TO_SUPPRESS_MD_PUBLISHED && flavor == FLAV_MICRODESC) { published_on = -1; } if (chosen_name && !naming_conflict) { strlcpy(rs_out.nickname, chosen_name, sizeof(rs_out.nickname)); } else { Loading Loading @@ -2276,7 +2291,7 @@ networkstatus_compute_consensus(smartlist_t *votes, /* Okay!! Now we can write the descriptor... */ /* First line goes into "buf". */ buf = routerstatus_format_entry(&rs_out, NULL, NULL, rs_format, NULL); rs_format, NULL, published_on); if (buf) smartlist_add(chunks, buf); } Loading Loading @@ -4745,6 +4760,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key, dirauth_set_routerstatus_from_routerinfo(rs, node, ri, now, list_bad_exits, list_middle_only); vrs->published_on = ri->cache_info.published_on; if (ri->cache_info.signing_key_cert) { memcpy(vrs->ed25519_id, Loading src/feature/dirauth/dirvote.h +7 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ #define MIN_SUPPORTED_CONSENSUS_METHOD 28 /** The highest consensus method that we currently support. */ #define MAX_SUPPORTED_CONSENSUS_METHOD 32 #define MAX_SUPPORTED_CONSENSUS_METHOD 33 /** * Lowest consensus method where microdescriptor lines are put in canonical Loading @@ -74,6 +74,12 @@ */ #define MIN_METHOD_FOR_MIDDLEONLY 32 /** * Lowest consensus method for which we suppress the published time in * microdescriptor consensuses. */ #define MIN_METHOD_TO_SUPPRESS_MD_PUBLISHED 33 /** Default bandwidth to clip unmeasured bandwidths to using method >= * MIN_METHOD_TO_CLIP_UNMEASURED_BW. (This is not a consensus method; do not * get confused with the above macros.) */ Loading src/feature/dirparse/ns_parse.c +4 −1 Original line number Diff line number Diff line Loading @@ -371,14 +371,17 @@ routerstatus_parse_entry_from_string(memarea_t *area, } } time_t published_on; if (tor_snprintf(timebuf, sizeof(timebuf), "%s %s", tok->args[3+offset], tok->args[4+offset]) < 0 || parse_iso_time(timebuf, &rs->published_on)<0) { parse_iso_time(timebuf, &published_on)<0) { log_warn(LD_DIR, "Error parsing time '%s %s' [%d %d]", tok->args[3+offset], tok->args[4+offset], offset, (int)flav); goto err; } if (vote_rs) vote_rs->published_on = published_on; if (tor_inet_aton(tok->args[5+offset], &in) == 0) { log_warn(LD_DIR, "Error parsing router address in network-status %s", Loading src/feature/nodelist/fmt_routerstatus.c +14 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ /** Helper: write the router-status information in <b>rs</b> into a newly * allocated character buffer. Use the same format as in network-status * documents. If <b>version</b> is non-NULL, add a "v" line for the platform. * If <b>declared_publish_time</b> is nonnegative, we declare it as the * publication time. Otherwise we look for a publication time in <b>vrs</b>, * and fall back to a default (not useful) publication time. * * Return 0 on success, -1 on failure. * Loading @@ -38,12 +41,14 @@ * NS_V3_VOTE - Output a complete V3 NS vote. If <b>vrs</b> is present, * it contains additional information for the vote. * NS_CONTROL_PORT - Output a NS document for the control port. * */ char * routerstatus_format_entry(const routerstatus_t *rs, const char *version, const char *protocols, routerstatus_format_type_t format, const vote_routerstatus_t *vrs) const vote_routerstatus_t *vrs, time_t declared_publish_time) { char *summary; char *result = NULL; Loading @@ -53,11 +58,18 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version, char digest64[BASE64_DIGEST_LEN+1]; smartlist_t *chunks = smartlist_new(); if (declared_publish_time >= 0) { format_iso_time(published, declared_publish_time); } else if (vrs) { format_iso_time(published, vrs->published_on); } else { strlcpy(published, "2038-01-01 00:00:00", sizeof(published)); } const char *ip_str = fmt_addr(&rs->ipv4_addr); if (ip_str[0] == '\0') goto err; format_iso_time(published, rs->published_on); digest_to_base64(identity64, rs->identity_digest); digest_to_base64(digest64, rs->descriptor_digest); Loading Loading
changes/prop275 0 → 100644 +12 −0 Original line number Diff line number Diff line o Minor features (directory authority): - Add a new consensus method in which the "published" times on router entries in a microdesc consensus are all set to a meaningless fixed date. Doing this will make the download size for compressed microdesc consensus diffs much smaller. Part of ticket 40130; implements proposal 275. o Minor features (network documents): - Clients and relays no longer track the "published on" time declared for relays in any consensus documents. When reporting this time on the control port, they instead report a fixed date in the future. Part of ticket 40130.
src/feature/dirauth/dirvote.c +26 −10 Original line number Diff line number Diff line Loading @@ -390,7 +390,8 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key, rsf = routerstatus_format_entry(&vrs->status, vrs->version, vrs->protocols, NS_V3_VOTE, vrs); vrs, -1); if (rsf) smartlist_add(chunks, rsf); Loading Loading @@ -618,8 +619,8 @@ compare_vote_rs(const vote_routerstatus_t *a, const vote_routerstatus_t *b) * the descriptor digests matched, so somebody is making SHA1 collisions. */ #define CMP_FIELD(utype, itype, field) do { \ utype aval = (utype) (itype) a->status.field; \ utype bval = (utype) (itype) b->status.field; \ utype aval = (utype) (itype) a->field; \ utype bval = (utype) (itype) b->field; \ utype u = bval - aval; \ itype r2 = (itype) u; \ if (r2 < 0) { \ Loading @@ -638,8 +639,8 @@ compare_vote_rs(const vote_routerstatus_t *a, const vote_routerstatus_t *b) CMP_EXACT))) { return r; } CMP_FIELD(unsigned, int, ipv4_orport); CMP_FIELD(unsigned, int, ipv4_dirport); CMP_FIELD(unsigned, int, status.ipv4_orport); CMP_FIELD(unsigned, int, status.ipv4_dirport); return 0; } Loading Loading @@ -692,10 +693,10 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method, } else { if (cur && (cur_n > most_n || (cur_n == most_n && cur->status.published_on > most_published))) { cur->published_on > most_published))) { most = cur; most_n = cur_n; most_published = cur->status.published_on; most_published = cur->published_on; } cur_n = 1; cur = rs; Loading @@ -703,7 +704,7 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method, } SMARTLIST_FOREACH_END(rs); if (cur_n > most_n || (cur && cur_n == most_n && cur->status.published_on > most_published)) { (cur && cur_n == most_n && cur->published_on > most_published)) { most = cur; // most_n = cur_n; // unused after this point. // most_published = cur->status.published_on; // unused after this point. Loading Loading @@ -2047,7 +2048,6 @@ networkstatus_compute_consensus(smartlist_t *votes, memcpy(rs_out.descriptor_digest, rs->status.descriptor_digest, DIGEST_LEN); tor_addr_copy(&rs_out.ipv4_addr, &rs->status.ipv4_addr); rs_out.published_on = rs->status.published_on; rs_out.ipv4_dirport = rs->status.ipv4_dirport; rs_out.ipv4_orport = rs->status.ipv4_orport; tor_addr_copy(&rs_out.ipv6_addr, &alt_orport.addr); Loading @@ -2055,6 +2055,21 @@ networkstatus_compute_consensus(smartlist_t *votes, rs_out.has_bandwidth = 0; rs_out.has_exitsummary = 0; time_t published_on = rs->published_on; /* Starting with this consensus method, we no longer include a meaningful published_on time for microdescriptor consensuses. This makes their diffs smaller and more compressible. We need to keep including a meaningful published_on time for NS consensuses, however, until 035 relays are all obsolete. (They use it for a purpose similar to the current StaleDesc flag.) */ if (consensus_method >= MIN_METHOD_TO_SUPPRESS_MD_PUBLISHED && flavor == FLAV_MICRODESC) { published_on = -1; } if (chosen_name && !naming_conflict) { strlcpy(rs_out.nickname, chosen_name, sizeof(rs_out.nickname)); } else { Loading Loading @@ -2276,7 +2291,7 @@ networkstatus_compute_consensus(smartlist_t *votes, /* Okay!! Now we can write the descriptor... */ /* First line goes into "buf". */ buf = routerstatus_format_entry(&rs_out, NULL, NULL, rs_format, NULL); rs_format, NULL, published_on); if (buf) smartlist_add(chunks, buf); } Loading Loading @@ -4745,6 +4760,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key, dirauth_set_routerstatus_from_routerinfo(rs, node, ri, now, list_bad_exits, list_middle_only); vrs->published_on = ri->cache_info.published_on; if (ri->cache_info.signing_key_cert) { memcpy(vrs->ed25519_id, Loading
src/feature/dirauth/dirvote.h +7 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ #define MIN_SUPPORTED_CONSENSUS_METHOD 28 /** The highest consensus method that we currently support. */ #define MAX_SUPPORTED_CONSENSUS_METHOD 32 #define MAX_SUPPORTED_CONSENSUS_METHOD 33 /** * Lowest consensus method where microdescriptor lines are put in canonical Loading @@ -74,6 +74,12 @@ */ #define MIN_METHOD_FOR_MIDDLEONLY 32 /** * Lowest consensus method for which we suppress the published time in * microdescriptor consensuses. */ #define MIN_METHOD_TO_SUPPRESS_MD_PUBLISHED 33 /** Default bandwidth to clip unmeasured bandwidths to using method >= * MIN_METHOD_TO_CLIP_UNMEASURED_BW. (This is not a consensus method; do not * get confused with the above macros.) */ Loading
src/feature/dirparse/ns_parse.c +4 −1 Original line number Diff line number Diff line Loading @@ -371,14 +371,17 @@ routerstatus_parse_entry_from_string(memarea_t *area, } } time_t published_on; if (tor_snprintf(timebuf, sizeof(timebuf), "%s %s", tok->args[3+offset], tok->args[4+offset]) < 0 || parse_iso_time(timebuf, &rs->published_on)<0) { parse_iso_time(timebuf, &published_on)<0) { log_warn(LD_DIR, "Error parsing time '%s %s' [%d %d]", tok->args[3+offset], tok->args[4+offset], offset, (int)flav); goto err; } if (vote_rs) vote_rs->published_on = published_on; if (tor_inet_aton(tok->args[5+offset], &in) == 0) { log_warn(LD_DIR, "Error parsing router address in network-status %s", Loading
src/feature/nodelist/fmt_routerstatus.c +14 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ /** Helper: write the router-status information in <b>rs</b> into a newly * allocated character buffer. Use the same format as in network-status * documents. If <b>version</b> is non-NULL, add a "v" line for the platform. * If <b>declared_publish_time</b> is nonnegative, we declare it as the * publication time. Otherwise we look for a publication time in <b>vrs</b>, * and fall back to a default (not useful) publication time. * * Return 0 on success, -1 on failure. * Loading @@ -38,12 +41,14 @@ * NS_V3_VOTE - Output a complete V3 NS vote. If <b>vrs</b> is present, * it contains additional information for the vote. * NS_CONTROL_PORT - Output a NS document for the control port. * */ char * routerstatus_format_entry(const routerstatus_t *rs, const char *version, const char *protocols, routerstatus_format_type_t format, const vote_routerstatus_t *vrs) const vote_routerstatus_t *vrs, time_t declared_publish_time) { char *summary; char *result = NULL; Loading @@ -53,11 +58,18 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version, char digest64[BASE64_DIGEST_LEN+1]; smartlist_t *chunks = smartlist_new(); if (declared_publish_time >= 0) { format_iso_time(published, declared_publish_time); } else if (vrs) { format_iso_time(published, vrs->published_on); } else { strlcpy(published, "2038-01-01 00:00:00", sizeof(published)); } const char *ip_str = fmt_addr(&rs->ipv4_addr); if (ip_str[0] == '\0') goto err; format_iso_time(published, rs->published_on); digest_to_base64(identity64, rs->identity_digest); digest_to_base64(digest64, rs->descriptor_digest); Loading