From 2503cfad240bfd59b033b4380b0ebd4a8a148802 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 31 Jul 2012 10:48:35 -0400 Subject: Allow microdescs to be up to 2k. Partial fix for 6404. --- changes/bug6404 | 7 +++++++ src/or/dirvote.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changes/bug6404 diff --git a/changes/bug6404 b/changes/bug6404 new file mode 100644 index 0000000000..d01964d1e5 --- /dev/null +++ b/changes/bug6404 @@ -0,0 +1,7 @@ + o Minor bugfixes: + + - Increase the maximum length of microdescriptor we are willing to + generate from 1K to 2K. Occasionally this is needed for routers + with complex policies or family declarations. Partial fix for + bug 6404; fix on 0.2.2.6-alpha. + diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 79958739a5..85ea85ce73 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -3502,7 +3502,7 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) { microdesc_t *result = NULL; char *key = NULL, *summary = NULL, *family = NULL; - char buf[1024]; + char buf[2048]; size_t keylen; char *out = buf, *end = buf+sizeof(buf); -- cgit v1.2.3-54-g00ecf From 7143d112a69806bde4a29bf8da94704cfb435fe3 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 31 Jul 2012 10:54:14 -0400 Subject: Don't include a router in an md consensus if we can't find a md for it. The spec requires that every router in a microdesc consensus have an m line; we weren't obeying that spec. This creates a new consensus method (13) to allow voting to continue to work right. Partial fix for bug 6404; fix on 0.2.2.6-alpha. --- changes/bug6404 | 5 +++++ src/or/dirvote.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/changes/bug6404 b/changes/bug6404 index d01964d1e5..64d459418f 100644 --- a/changes/bug6404 +++ b/changes/bug6404 @@ -5,3 +5,8 @@ with complex policies or family declarations. Partial fix for bug 6404; fix on 0.2.2.6-alpha. + - Authorities no longer include any router in their + microdescriptor consensuses for which they couldn't generate or + agree on a microdescriptor. Partial fix for bug 6404; fix on + 0.2.2.6-alpha. + diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 85ea85ce73..87af5becf7 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -54,7 +54,7 @@ static int dirvote_publish_consensus(void); static char *make_consensus_method_list(int low, int high, const char *sep); /** The highest consensus method that we currently support. */ -#define MAX_SUPPORTED_CONSENSUS_METHOD 12 +#define MAX_SUPPORTED_CONSENSUS_METHOD 13 /** Lowest consensus method that contains a 'directory-footer' marker */ #define MIN_METHOD_FOR_FOOTER 9 @@ -72,6 +72,10 @@ static char *make_consensus_method_list(int low, int high, const char *sep); * for a param. */ #define MIN_METHOD_FOR_MAJORITY_PARAMS 12 +/** Lowest consensus method where microdesc consensuses omit any entry + * with no microdesc. */ +#define MIN_METHOD_FOR_MANDATORY_MICRODESC 13 + /* ===== * Voting * =====*/ @@ -1935,6 +1939,13 @@ networkstatus_compute_consensus(smartlist_t *votes, } } + if (flavor == FLAV_MICRODESC && + consensus_method >= MIN_METHOD_FOR_MANDATORY_MICRODESC && + tor_digest256_is_zero(microdesc_digest)) { + /* With no microdescriptor digest, we omit the entry entirely. */ + continue; + } + { char buf[4096]; /* Okay!! Now we can write the descriptor... */ -- cgit v1.2.3-54-g00ecf From 063138e001d3608b1e8b6619661d906cfea74ae0 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 31 Jul 2012 11:00:18 -0400 Subject: Warn at parse time for routerstatus entry missing a microdesc consensus In 0.2.3.18-rc, we started warning on this case while building a list of missing microdescriptor digests. That turned out to spam the logs; instead let's warn at parse time. Partial fix for bug 6404. --- changes/bug6404 | 4 ++++ src/or/microdesc.c | 7 +------ src/or/routerparse.c | 5 +++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/changes/bug6404 b/changes/bug6404 index 64d459418f..77081481ce 100644 --- a/changes/bug6404 +++ b/changes/bug6404 @@ -10,3 +10,7 @@ agree on a microdescriptor. Partial fix for bug 6404; fix on 0.2.2.6-alpha. + - Move log message when unable to find a microdesc in a + routerstatus entry to parse time. Previously we'd spam this + warning every time we tried to figure out which microdescriptors + to download. Partial fix for bug 6404; fix on 0.2.3.18-rc. diff --git a/src/or/microdesc.c b/src/or/microdesc.c index 9395a9a051..c1ac1c3758 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -643,13 +643,8 @@ microdesc_list_missing_digest256(networkstatus_t *ns, microdesc_cache_t *cache, continue; if (skip && digestmap_get(skip, rs->descriptor_digest)) continue; - if (tor_mem_is_zero(rs->descriptor_digest, DIGEST256_LEN)) { - log_info(LD_BUG, "Found an entry in networkstatus with no " - "microdescriptor digest. (Router %s=%s at %s:%d.)", - rs->nickname, hex_str(rs->identity_digest, DIGEST_LEN), - fmt_addr32(rs->addr), rs->or_port); + if (tor_mem_is_zero(rs->descriptor_digest, DIGEST256_LEN)) continue; - } /* XXXX Also skip if we're a noncache and wouldn't use this router. * XXXX NM Microdesc */ diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 4231a17c67..8b69ad1d13 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -2201,6 +2201,11 @@ routerstatus_parse_entry_from_string(memarea_t *area, escaped(tok->args[0])); goto err; } + } else { + log_info(LD_BUG, "Found an entry in networkstatus with no " + "microdescriptor digest. (Router %s=%s at %s:%d.)", + rs->nickname, hex_str(rs->identity_digest, DIGEST_LEN), + fmt_addr32(rs->addr), rs->or_port); } } -- cgit v1.2.3-54-g00ecf From d3e1e458e11715a9fea2fea2cb228ff925c72851 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 31 Jul 2012 13:12:07 -0400 Subject: Remove the upper limit on the size of MD we can generate. --- src/or/dirvote.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 87af5becf7..dc1ba7e8c4 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -3513,9 +3513,9 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) { microdesc_t *result = NULL; char *key = NULL, *summary = NULL, *family = NULL; - char buf[2048]; size_t keylen; - char *out = buf, *end = buf+sizeof(buf); + smartlist_t *chunks = smartlist_new(); + char *output; if (crypto_pk_write_public_key_to_string(ri->onion_pkey, &key, &keylen)<0) goto done; @@ -3523,23 +3523,19 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) if (ri->declared_family) family = smartlist_join_strings(ri->declared_family, " ", 0, NULL); - if (tor_snprintf(out, end-out, "onion-key\n%s", key)<0) - goto done; - out += strlen(out); - if (family) { - if (tor_snprintf(out, end-out, "family %s\n", family)<0) - goto done; - out += strlen(out); - } - if (summary && strcmp(summary, "reject 1-65535")) { - if (tor_snprintf(out, end-out, "p %s\n", summary)<0) - goto done; - out += strlen(out); - } - *out = '\0'; /* Make sure it's nul-terminated. This should be a no-op */ + smartlist_add_asprintf(chunks, "onion-key\n%s", key); + + if (family) + smartlist_add_asprintf(chunks, "family %s\n", family); + + if (summary && strcmp(summary, "reject 1-65535")) + smartlist_add_asprintf(chunks, "p %s\n", summary); + + output = smartlist_join_strings(chunks, "", 0, NULL); { - smartlist_t *lst = microdescs_parse_from_string(buf, out, 0, 1); + smartlist_t *lst = microdescs_parse_from_string(output, + output+strlen(output), 0, 1); if (smartlist_len(lst) != 1) { log_warn(LD_DIR, "We generated a microdescriptor we couldn't parse."); SMARTLIST_FOREACH(lst, microdesc_t *, md, microdesc_free(md)); @@ -3554,6 +3550,10 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) tor_free(key); tor_free(summary); tor_free(family); + if (chunks) { + SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp)); + smartlist_free(chunks); + } return result; } -- cgit v1.2.3-54-g00ecf From a9eed33111173d9f7c7fbff74ab1573c4c12e634 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 14 Aug 2012 03:06:47 -0400 Subject: Fix memory leak in dirvote_create_microdescriptor Found by George, who gets a cookie. --- src/or/dirvote.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/or/dirvote.c b/src/or/dirvote.c index dc1ba7e8c4..a7fea0a75e 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -3515,7 +3515,7 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) char *key = NULL, *summary = NULL, *family = NULL; size_t keylen; smartlist_t *chunks = smartlist_new(); - char *output; + char *output = NULL; if (crypto_pk_write_public_key_to_string(ri->onion_pkey, &key, &keylen)<0) goto done; @@ -3547,6 +3547,7 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) } done: + tor_free(output); tor_free(key); tor_free(summary); tor_free(family); -- cgit v1.2.3-54-g00ecf From a4fbfa81b3fb732687efcefce851e2cd089ea6c1 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 14 Aug 2012 03:10:14 -0400 Subject: Update description of what we did to upper limit on md size Spotted by asn --- changes/bug6404 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changes/bug6404 b/changes/bug6404 index 77081481ce..948f00b92e 100644 --- a/changes/bug6404 +++ b/changes/bug6404 @@ -1,7 +1,7 @@ o Minor bugfixes: - - Increase the maximum length of microdescriptor we are willing to - generate from 1K to 2K. Occasionally this is needed for routers + - Remove the maximum length of microdescriptor we are willing to + generate. Occasionally this is needed for routers with complex policies or family declarations. Partial fix for bug 6404; fix on 0.2.2.6-alpha. -- cgit v1.2.3-54-g00ecf