mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
r13355@catbus: nickm | 2007-06-11 18:19:34 -0400
Make all the digestmaps inside routerlist_t use the new typechecking wrappers, so we can catch any more bugs like the one fixed by 10561. This turned up a bug in routerlist_remove: we were extracting a routerinfo_t from desc_digest_map. Fix that too, though it was probably harmless, since we were only doing a pointer comparison with it. svn:r10563
This commit is contained in:
parent
f45732513e
commit
367a77459a
@ -1351,17 +1351,17 @@ typedef struct networkstatus_vote_t {
|
|||||||
/** Contents of a directory of onion routers. */
|
/** Contents of a directory of onion routers. */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** Map from server identity digest to a member of routers. */
|
/** Map from server identity digest to a member of routers. */
|
||||||
digestmap_t *identity_map;
|
struct digest_ri_map_t *identity_map;
|
||||||
/** Map from server descriptor digest to a signed_descriptor_t from
|
/** Map from server descriptor digest to a signed_descriptor_t from
|
||||||
* routers or old_routers. */
|
* routers or old_routers. */
|
||||||
digestmap_t *desc_digest_map;
|
struct digest_sd_map_t *desc_digest_map;
|
||||||
/** Map from extra-info digest to an extrainfo_t. Only exists for
|
/** Map from extra-info digest to an extrainfo_t. Only exists for
|
||||||
* routers in routers or old_routers. */
|
* routers in routers or old_routers. */
|
||||||
digestmap_t *extra_info_map;
|
struct digest_ei_map_t *extra_info_map;
|
||||||
/** Map from extra-info digests to a signed_descriptor_t for a router
|
/** Map from extra-info digests to a signed_descriptor_t for a router
|
||||||
* descriptor having that extra-info digest. Only exists for
|
* descriptor having that extra-info digest. Only exists for
|
||||||
* routers in routers or old_routers. */
|
* routers in routers or old_routers. */
|
||||||
digestmap_t *desc_by_eid_map;
|
struct digest_sd_map_t *desc_by_eid_map;
|
||||||
/** List of routerinfo_t for all currently live routers we know. */
|
/** List of routerinfo_t for all currently live routers we know. */
|
||||||
smartlist_t *routers;
|
smartlist_t *routers;
|
||||||
/** List of signed_descriptor_t for older router descriptors we're
|
/** List of signed_descriptor_t for older router descriptors we're
|
||||||
|
@ -44,6 +44,10 @@ static local_routerstatus_t *router_get_combined_status_by_nickname(
|
|||||||
static void update_router_have_minimum_dir_info(void);
|
static void update_router_have_minimum_dir_info(void);
|
||||||
static void router_dir_info_changed(void);
|
static void router_dir_info_changed(void);
|
||||||
|
|
||||||
|
DECLARE_TYPED_DIGESTMAP_FNS(sdmap_, digest_sd_map_t, signed_descriptor_t)
|
||||||
|
DECLARE_TYPED_DIGESTMAP_FNS(rimap_, digest_ri_map_t, routerinfo_t)
|
||||||
|
DECLARE_TYPED_DIGESTMAP_FNS(eimap_, digest_ei_map_t, extrainfo_t)
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
/** Global list of a trusted_dir_server_t object for each trusted directory
|
/** Global list of a trusted_dir_server_t object for each trusted directory
|
||||||
@ -414,15 +418,13 @@ router_rebuild_store(int force, int extrainfo)
|
|||||||
/* We sort the routers by age to enhance locality on disk. */
|
/* We sort the routers by age to enhance locality on disk. */
|
||||||
signed_descriptors = smartlist_create();
|
signed_descriptors = smartlist_create();
|
||||||
if (extrainfo) {
|
if (extrainfo) {
|
||||||
digestmap_iter_t *iter;
|
eimap_iter_t *iter;
|
||||||
for (iter = digestmap_iter_init(routerlist->extra_info_map);
|
for (iter = eimap_iter_init(routerlist->extra_info_map);
|
||||||
!digestmap_iter_done(iter);
|
!eimap_iter_done(iter);
|
||||||
iter = digestmap_iter_next(routerlist->extra_info_map, iter)) {
|
iter = eimap_iter_next(routerlist->extra_info_map, iter)) {
|
||||||
const char *key;
|
const char *key;
|
||||||
void *val;
|
|
||||||
extrainfo_t *ei;
|
extrainfo_t *ei;
|
||||||
digestmap_iter_get(iter, &key, &val);
|
eimap_iter_get(iter, &key, &ei);
|
||||||
ei = val;
|
|
||||||
smartlist_add(signed_descriptors, &ei->cache_info);
|
smartlist_add(signed_descriptors, &ei->cache_info);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1470,7 +1472,7 @@ router_get_by_nickname(const char *nickname, int warn_if_unnamed)
|
|||||||
|
|
||||||
if (named_server_map &&
|
if (named_server_map &&
|
||||||
(named_digest = strmap_get_lc(named_server_map, nickname))) {
|
(named_digest = strmap_get_lc(named_server_map, nickname))) {
|
||||||
return digestmap_get(routerlist->identity_map, named_digest);
|
return rimap_get(routerlist->identity_map, named_digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, router,
|
SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, router,
|
||||||
@ -1635,7 +1637,7 @@ router_get_by_digest(const char *digest)
|
|||||||
|
|
||||||
// routerlist_assert_ok(routerlist);
|
// routerlist_assert_ok(routerlist);
|
||||||
|
|
||||||
return digestmap_get(routerlist->identity_map, digest);
|
return rimap_get(routerlist->identity_map, digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the router in our routerlist whose 20-byte descriptor
|
/** Return the router in our routerlist whose 20-byte descriptor
|
||||||
@ -1647,7 +1649,7 @@ router_get_by_descriptor_digest(const char *digest)
|
|||||||
|
|
||||||
if (!routerlist) return NULL;
|
if (!routerlist) return NULL;
|
||||||
|
|
||||||
return digestmap_get(routerlist->desc_digest_map, digest);
|
return sdmap_get(routerlist->desc_digest_map, digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the signed descriptor for the router in our routerlist whose
|
/** Return the signed descriptor for the router in our routerlist whose
|
||||||
@ -1660,7 +1662,7 @@ router_get_by_extrainfo_digest(const char *digest)
|
|||||||
|
|
||||||
if (!routerlist) return NULL;
|
if (!routerlist) return NULL;
|
||||||
|
|
||||||
return digestmap_get(routerlist->desc_by_eid_map, digest);
|
return sdmap_get(routerlist->desc_by_eid_map, digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the signed descriptor for the extrainfo_t in our routerlist whose
|
/** Return the signed descriptor for the extrainfo_t in our routerlist whose
|
||||||
@ -1672,7 +1674,7 @@ extrainfo_get_by_descriptor_digest(const char *digest)
|
|||||||
extrainfo_t *ei;
|
extrainfo_t *ei;
|
||||||
tor_assert(digest);
|
tor_assert(digest);
|
||||||
if (!routerlist) return NULL;
|
if (!routerlist) return NULL;
|
||||||
ei = digestmap_get(routerlist->extra_info_map, digest);
|
ei = eimap_get(routerlist->extra_info_map, digest);
|
||||||
return ei ? &ei->cache_info : NULL;
|
return ei ? &ei->cache_info : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1717,10 +1719,10 @@ router_get_routerlist(void)
|
|||||||
routerlist = tor_malloc_zero(sizeof(routerlist_t));
|
routerlist = tor_malloc_zero(sizeof(routerlist_t));
|
||||||
routerlist->routers = smartlist_create();
|
routerlist->routers = smartlist_create();
|
||||||
routerlist->old_routers = smartlist_create();
|
routerlist->old_routers = smartlist_create();
|
||||||
routerlist->identity_map = digestmap_new();
|
routerlist->identity_map = rimap_new();
|
||||||
routerlist->desc_digest_map = digestmap_new();
|
routerlist->desc_digest_map = sdmap_new();
|
||||||
routerlist->desc_by_eid_map = digestmap_new();
|
routerlist->desc_by_eid_map = sdmap_new();
|
||||||
routerlist->extra_info_map = digestmap_new();
|
routerlist->extra_info_map = eimap_new();
|
||||||
}
|
}
|
||||||
return routerlist;
|
return routerlist;
|
||||||
}
|
}
|
||||||
@ -1802,10 +1804,10 @@ void
|
|||||||
routerlist_free(routerlist_t *rl)
|
routerlist_free(routerlist_t *rl)
|
||||||
{
|
{
|
||||||
tor_assert(rl);
|
tor_assert(rl);
|
||||||
digestmap_free(rl->identity_map, NULL);
|
rimap_free(rl->identity_map, NULL);
|
||||||
digestmap_free(rl->desc_digest_map, NULL);
|
sdmap_free(rl->desc_digest_map, NULL);
|
||||||
digestmap_free(rl->desc_by_eid_map, NULL);
|
sdmap_free(rl->desc_by_eid_map, NULL);
|
||||||
digestmap_free(rl->extra_info_map, _extrainfo_free);
|
eimap_free(rl->extra_info_map, _extrainfo_free);
|
||||||
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,
|
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,
|
||||||
routerinfo_free(r));
|
routerinfo_free(r));
|
||||||
SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd,
|
SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd,
|
||||||
@ -1893,12 +1895,12 @@ routerlist_insert(routerlist_t *rl, routerinfo_t *ri)
|
|||||||
}
|
}
|
||||||
tor_assert(ri->routerlist_index == -1);
|
tor_assert(ri->routerlist_index == -1);
|
||||||
|
|
||||||
ri_old = digestmap_set(rl->identity_map, ri->cache_info.identity_digest, ri);
|
ri_old = rimap_set(rl->identity_map, ri->cache_info.identity_digest, ri);
|
||||||
tor_assert(!ri_old);
|
tor_assert(!ri_old);
|
||||||
digestmap_set(rl->desc_digest_map, ri->cache_info.signed_descriptor_digest,
|
sdmap_set(rl->desc_digest_map, ri->cache_info.signed_descriptor_digest,
|
||||||
&(ri->cache_info));
|
&(ri->cache_info));
|
||||||
if (!tor_digest_is_zero(ri->cache_info.extra_info_digest))
|
if (!tor_digest_is_zero(ri->cache_info.extra_info_digest))
|
||||||
digestmap_set(rl->desc_by_eid_map, ri->cache_info.extra_info_digest,
|
sdmap_set(rl->desc_by_eid_map, ri->cache_info.extra_info_digest,
|
||||||
&ri->cache_info);
|
&ri->cache_info);
|
||||||
smartlist_add(rl->routers, ri);
|
smartlist_add(rl->routers, ri);
|
||||||
ri->routerlist_index = smartlist_len(rl->routers) - 1;
|
ri->routerlist_index = smartlist_len(rl->routers) - 1;
|
||||||
@ -1916,7 +1918,7 @@ static int
|
|||||||
extrainfo_insert(routerlist_t *rl, extrainfo_t *ei)
|
extrainfo_insert(routerlist_t *rl, extrainfo_t *ei)
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
routerinfo_t *ri = digestmap_get(rl->identity_map,
|
routerinfo_t *ri = rimap_get(rl->identity_map,
|
||||||
ei->cache_info.identity_digest);
|
ei->cache_info.identity_digest);
|
||||||
signed_descriptor_t *sd;
|
signed_descriptor_t *sd;
|
||||||
extrainfo_t *ei_tmp;
|
extrainfo_t *ei_tmp;
|
||||||
@ -1935,7 +1937,7 @@ extrainfo_insert(routerlist_t *rl, extrainfo_t *ei)
|
|||||||
if (routerinfo_incompatible_with_extrainfo(ri, ei, NULL)) {
|
if (routerinfo_incompatible_with_extrainfo(ri, ei, NULL)) {
|
||||||
if (ei->bad_sig) /* If the signature didn't check, it's just wrong. */
|
if (ei->bad_sig) /* If the signature didn't check, it's just wrong. */
|
||||||
goto done;
|
goto done;
|
||||||
sd = digestmap_get(rl->desc_by_eid_map,
|
sd = sdmap_get(rl->desc_by_eid_map,
|
||||||
ei->cache_info.signed_descriptor_digest);
|
ei->cache_info.signed_descriptor_digest);
|
||||||
if (!sd ||
|
if (!sd ||
|
||||||
memcmp(sd->identity_digest, ei->cache_info.identity_digest,
|
memcmp(sd->identity_digest, ei->cache_info.identity_digest,
|
||||||
@ -1947,7 +1949,7 @@ extrainfo_insert(routerlist_t *rl, extrainfo_t *ei)
|
|||||||
/* Okay, if we make it here, we definitely have a router corresponding to
|
/* Okay, if we make it here, we definitely have a router corresponding to
|
||||||
* this extrainfo. */
|
* this extrainfo. */
|
||||||
|
|
||||||
ei_tmp = digestmap_set(rl->extra_info_map,
|
ei_tmp = eimap_set(rl->extra_info_map,
|
||||||
ei->cache_info.signed_descriptor_digest,
|
ei->cache_info.signed_descriptor_digest,
|
||||||
ei);
|
ei);
|
||||||
r = 1;
|
r = 1;
|
||||||
@ -1984,13 +1986,13 @@ routerlist_insert_old(routerlist_t *rl, routerinfo_t *ri)
|
|||||||
|
|
||||||
if (get_options()->DirPort &&
|
if (get_options()->DirPort &&
|
||||||
ri->purpose == ROUTER_PURPOSE_GENERAL &&
|
ri->purpose == ROUTER_PURPOSE_GENERAL &&
|
||||||
!digestmap_get(rl->desc_digest_map,
|
!sdmap_get(rl->desc_digest_map,
|
||||||
ri->cache_info.signed_descriptor_digest)) {
|
ri->cache_info.signed_descriptor_digest)) {
|
||||||
signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri);
|
signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri);
|
||||||
digestmap_set(rl->desc_digest_map, sd->signed_descriptor_digest, sd);
|
sdmap_set(rl->desc_digest_map, sd->signed_descriptor_digest, sd);
|
||||||
smartlist_add(rl->old_routers, sd);
|
smartlist_add(rl->old_routers, sd);
|
||||||
if (!tor_digest_is_zero(sd->extra_info_digest))
|
if (!tor_digest_is_zero(sd->extra_info_digest))
|
||||||
digestmap_set(rl->desc_by_eid_map, sd->extra_info_digest, sd);
|
sdmap_set(rl->desc_by_eid_map, sd->extra_info_digest, sd);
|
||||||
} else {
|
} else {
|
||||||
routerinfo_free(ri);
|
routerinfo_free(ri);
|
||||||
}
|
}
|
||||||
@ -2024,7 +2026,7 @@ routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int idx, int make_old)
|
|||||||
r->routerlist_index = idx;
|
r->routerlist_index = idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
ri_tmp = digestmap_remove(rl->identity_map, ri->cache_info.identity_digest);
|
ri_tmp = rimap_remove(rl->identity_map, ri->cache_info.identity_digest);
|
||||||
router_dir_info_changed();
|
router_dir_info_changed();
|
||||||
tor_assert(ri_tmp == ri);
|
tor_assert(ri_tmp == ri);
|
||||||
|
|
||||||
@ -2033,15 +2035,16 @@ routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int idx, int make_old)
|
|||||||
signed_descriptor_t *sd;
|
signed_descriptor_t *sd;
|
||||||
sd = signed_descriptor_from_routerinfo(ri);
|
sd = signed_descriptor_from_routerinfo(ri);
|
||||||
smartlist_add(rl->old_routers, sd);
|
smartlist_add(rl->old_routers, sd);
|
||||||
digestmap_set(rl->desc_digest_map, sd->signed_descriptor_digest, sd);
|
sdmap_set(rl->desc_digest_map, sd->signed_descriptor_digest, sd);
|
||||||
if (!tor_digest_is_zero(sd->extra_info_digest))
|
if (!tor_digest_is_zero(sd->extra_info_digest))
|
||||||
digestmap_set(rl->desc_by_eid_map, sd->extra_info_digest, sd);
|
sdmap_set(rl->desc_by_eid_map, sd->extra_info_digest, sd);
|
||||||
} else {
|
} else {
|
||||||
ri_tmp = digestmap_remove(rl->desc_digest_map,
|
signed_descriptor_t *sd_tmp;
|
||||||
|
sd_tmp = sdmap_remove(rl->desc_digest_map,
|
||||||
ri->cache_info.signed_descriptor_digest);
|
ri->cache_info.signed_descriptor_digest);
|
||||||
tor_assert(ri_tmp == ri);
|
tor_assert(sd_tmp == &(ri->cache_info));
|
||||||
router_store_stats.bytes_dropped += ri->cache_info.signed_descriptor_len;
|
router_store_stats.bytes_dropped += ri->cache_info.signed_descriptor_len;
|
||||||
ei_tmp = digestmap_remove(rl->extra_info_map,
|
ei_tmp = eimap_remove(rl->extra_info_map,
|
||||||
ri->cache_info.extra_info_digest);
|
ri->cache_info.extra_info_digest);
|
||||||
if (ei_tmp) {
|
if (ei_tmp) {
|
||||||
extrainfo_store_stats.bytes_dropped +=
|
extrainfo_store_stats.bytes_dropped +=
|
||||||
@ -2049,7 +2052,7 @@ routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int idx, int make_old)
|
|||||||
extrainfo_free(ei_tmp);
|
extrainfo_free(ei_tmp);
|
||||||
}
|
}
|
||||||
if (!tor_digest_is_zero(ri->cache_info.extra_info_digest))
|
if (!tor_digest_is_zero(ri->cache_info.extra_info_digest))
|
||||||
digestmap_remove(rl->desc_by_eid_map, ri->cache_info.extra_info_digest);
|
sdmap_remove(rl->desc_by_eid_map, ri->cache_info.extra_info_digest);
|
||||||
routerinfo_free(ri);
|
routerinfo_free(ri);
|
||||||
}
|
}
|
||||||
routerlist_check_bug_417();
|
routerlist_check_bug_417();
|
||||||
@ -2071,12 +2074,12 @@ routerlist_remove_old(routerlist_t *rl, signed_descriptor_t *sd, int idx)
|
|||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
return;
|
return;
|
||||||
smartlist_del(rl->old_routers, idx);
|
smartlist_del(rl->old_routers, idx);
|
||||||
sd_tmp = digestmap_remove(rl->desc_digest_map,
|
sd_tmp = sdmap_remove(rl->desc_digest_map,
|
||||||
sd->signed_descriptor_digest);
|
sd->signed_descriptor_digest);
|
||||||
tor_assert(sd_tmp == sd);
|
tor_assert(sd_tmp == sd);
|
||||||
router_store_stats.bytes_dropped += sd->signed_descriptor_len;
|
router_store_stats.bytes_dropped += sd->signed_descriptor_len;
|
||||||
|
|
||||||
ei_tmp = digestmap_remove(rl->extra_info_map,
|
ei_tmp = eimap_remove(rl->extra_info_map,
|
||||||
sd->extra_info_digest);
|
sd->extra_info_digest);
|
||||||
if (ei_tmp) {
|
if (ei_tmp) {
|
||||||
extrainfo_store_stats.bytes_dropped +=
|
extrainfo_store_stats.bytes_dropped +=
|
||||||
@ -2084,7 +2087,7 @@ routerlist_remove_old(routerlist_t *rl, signed_descriptor_t *sd, int idx)
|
|||||||
extrainfo_free(ei_tmp);
|
extrainfo_free(ei_tmp);
|
||||||
}
|
}
|
||||||
if (!tor_digest_is_zero(sd->extra_info_digest))
|
if (!tor_digest_is_zero(sd->extra_info_digest))
|
||||||
digestmap_remove(rl->desc_by_eid_map, sd->extra_info_digest);
|
sdmap_remove(rl->desc_by_eid_map, sd->extra_info_digest);
|
||||||
|
|
||||||
signed_descriptor_free(sd);
|
signed_descriptor_free(sd);
|
||||||
routerlist_check_bug_417();
|
routerlist_check_bug_417();
|
||||||
@ -2130,16 +2133,17 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
|
|||||||
if (memcmp(ri_old->cache_info.identity_digest,
|
if (memcmp(ri_old->cache_info.identity_digest,
|
||||||
ri_new->cache_info.identity_digest, DIGEST_LEN)) {
|
ri_new->cache_info.identity_digest, DIGEST_LEN)) {
|
||||||
/* digests don't match; digestmap_set won't replace */
|
/* digests don't match; digestmap_set won't replace */
|
||||||
digestmap_remove(rl->identity_map, ri_old->cache_info.identity_digest);
|
rimap_remove(rl->identity_map, ri_old->cache_info.identity_digest);
|
||||||
}
|
}
|
||||||
ri_tmp = digestmap_set(rl->identity_map,
|
ri_tmp = rimap_set(rl->identity_map,
|
||||||
ri_new->cache_info.identity_digest, ri_new);
|
ri_new->cache_info.identity_digest, ri_new);
|
||||||
tor_assert(!ri_tmp || ri_tmp == ri_old);
|
tor_assert(!ri_tmp || ri_tmp == ri_old);
|
||||||
digestmap_set(rl->desc_digest_map,
|
sdmap_set(rl->desc_digest_map,
|
||||||
ri_new->cache_info.signed_descriptor_digest, &(ri_new->cache_info));
|
ri_new->cache_info.signed_descriptor_digest,
|
||||||
|
&(ri_new->cache_info));
|
||||||
|
|
||||||
if (!tor_digest_is_zero(ri_new->cache_info.extra_info_digest)) {
|
if (!tor_digest_is_zero(ri_new->cache_info.extra_info_digest)) {
|
||||||
digestmap_set(rl->desc_by_eid_map, ri_new->cache_info.extra_info_digest,
|
sdmap_set(rl->desc_by_eid_map, ri_new->cache_info.extra_info_digest,
|
||||||
&ri_new->cache_info);
|
&ri_new->cache_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2147,19 +2151,19 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
|
|||||||
ri_old->purpose == ROUTER_PURPOSE_GENERAL) {
|
ri_old->purpose == ROUTER_PURPOSE_GENERAL) {
|
||||||
signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri_old);
|
signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri_old);
|
||||||
smartlist_add(rl->old_routers, sd);
|
smartlist_add(rl->old_routers, sd);
|
||||||
digestmap_set(rl->desc_digest_map, sd->signed_descriptor_digest, sd);
|
sdmap_set(rl->desc_digest_map, sd->signed_descriptor_digest, sd);
|
||||||
if (!tor_digest_is_zero(sd->extra_info_digest))
|
if (!tor_digest_is_zero(sd->extra_info_digest))
|
||||||
digestmap_set(rl->desc_by_eid_map, sd->extra_info_digest, sd);
|
sdmap_set(rl->desc_by_eid_map, sd->extra_info_digest, sd);
|
||||||
} else {
|
} else {
|
||||||
if (memcmp(ri_old->cache_info.signed_descriptor_digest,
|
if (memcmp(ri_old->cache_info.signed_descriptor_digest,
|
||||||
ri_new->cache_info.signed_descriptor_digest,
|
ri_new->cache_info.signed_descriptor_digest,
|
||||||
DIGEST_LEN)) {
|
DIGEST_LEN)) {
|
||||||
/* digests don't match; digestmap_set didn't replace */
|
/* digests don't match; digestmap_set didn't replace */
|
||||||
digestmap_remove(rl->desc_digest_map,
|
sdmap_remove(rl->desc_digest_map,
|
||||||
ri_old->cache_info.signed_descriptor_digest);
|
ri_old->cache_info.signed_descriptor_digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
ei_tmp = digestmap_remove(rl->extra_info_map,
|
ei_tmp = eimap_remove(rl->extra_info_map,
|
||||||
ri_old->cache_info.extra_info_digest);
|
ri_old->cache_info.extra_info_digest);
|
||||||
if (ei_tmp) {
|
if (ei_tmp) {
|
||||||
extrainfo_store_stats.bytes_dropped +=
|
extrainfo_store_stats.bytes_dropped +=
|
||||||
@ -2167,7 +2171,7 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
|
|||||||
extrainfo_free(ei_tmp);
|
extrainfo_free(ei_tmp);
|
||||||
}
|
}
|
||||||
if (!tor_digest_is_zero(ri_old->cache_info.extra_info_digest)) {
|
if (!tor_digest_is_zero(ri_old->cache_info.extra_info_digest)) {
|
||||||
digestmap_remove(rl->desc_by_eid_map,
|
sdmap_remove(rl->desc_by_eid_map,
|
||||||
ri_old->cache_info.extra_info_digest);
|
ri_old->cache_info.extra_info_digest);
|
||||||
}
|
}
|
||||||
router_store_stats.bytes_dropped +=
|
router_store_stats.bytes_dropped +=
|
||||||
@ -2358,7 +2362,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
id_digest = router->cache_info.identity_digest;
|
id_digest = router->cache_info.identity_digest;
|
||||||
|
|
||||||
/* Make sure that we haven't already got this exact descriptor. */
|
/* Make sure that we haven't already got this exact descriptor. */
|
||||||
if (digestmap_get(routerlist->desc_digest_map,
|
if (sdmap_get(routerlist->desc_digest_map,
|
||||||
router->cache_info.signed_descriptor_digest)) {
|
router->cache_info.signed_descriptor_digest)) {
|
||||||
log_info(LD_DIR,
|
log_info(LD_DIR,
|
||||||
"Dropping descriptor that we already have for router '%s'",
|
"Dropping descriptor that we already have for router '%s'",
|
||||||
@ -2411,7 +2415,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* If we have a router with the same identity key, choose the newer one. */
|
/* If we have a router with the same identity key, choose the newer one. */
|
||||||
old_router = digestmap_get(routerlist->identity_map,
|
old_router = rimap_get(routerlist->identity_map,
|
||||||
router->cache_info.identity_digest);
|
router->cache_info.identity_digest);
|
||||||
if (old_router) {
|
if (old_router) {
|
||||||
int pos = old_router->routerlist_index;
|
int pos = old_router->routerlist_index;
|
||||||
@ -4745,7 +4749,7 @@ should_download_extrainfo(signed_descriptor_t *sd,
|
|||||||
return (!sd->is_extrainfo &&
|
return (!sd->is_extrainfo &&
|
||||||
!tor_digest_is_zero(d) &&
|
!tor_digest_is_zero(d) &&
|
||||||
sd->ei_dl_status.next_attempt_at <= now &&
|
sd->ei_dl_status.next_attempt_at <= now &&
|
||||||
!digestmap_get(rl->extra_info_map, d) &&
|
!eimap_get(rl->extra_info_map, d) &&
|
||||||
!digestmap_get(pending, d));
|
!digestmap_get(pending, d));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5141,38 +5145,39 @@ getinfo_helper_networkstatus(control_connection_t *conn,
|
|||||||
void
|
void
|
||||||
routerlist_assert_ok(routerlist_t *rl)
|
routerlist_assert_ok(routerlist_t *rl)
|
||||||
{
|
{
|
||||||
digestmap_iter_t *iter;
|
digestmap_iter_t *iter; /* XXXX020 use the appropriate iter type. */
|
||||||
routerinfo_t *r2;
|
routerinfo_t *r2;
|
||||||
signed_descriptor_t *sd2;
|
signed_descriptor_t *sd2;
|
||||||
if (!rl)
|
if (!rl)
|
||||||
return;
|
return;
|
||||||
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,
|
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,
|
||||||
{
|
{
|
||||||
r2 = digestmap_get(rl->identity_map, r->cache_info.identity_digest);
|
r2 = rimap_get(rl->identity_map, r->cache_info.identity_digest);
|
||||||
tor_assert(r == r2);
|
tor_assert(r == r2);
|
||||||
sd2 = digestmap_get(rl->desc_digest_map,
|
sd2 = sdmap_get(rl->desc_digest_map,
|
||||||
r->cache_info.signed_descriptor_digest);
|
r->cache_info.signed_descriptor_digest);
|
||||||
tor_assert(&(r->cache_info) == sd2);
|
tor_assert(&(r->cache_info) == sd2);
|
||||||
tor_assert(r->routerlist_index == r_sl_idx);
|
tor_assert(r->routerlist_index == r_sl_idx);
|
||||||
if (!tor_digest_is_zero(r->cache_info.extra_info_digest)) {
|
if (!tor_digest_is_zero(r->cache_info.extra_info_digest)) {
|
||||||
signed_descriptor_t *sd3 =
|
signed_descriptor_t *sd3 =
|
||||||
digestmap_get(rl->desc_by_eid_map, r->cache_info.extra_info_digest);
|
sdmap_get(rl->desc_by_eid_map, r->cache_info.extra_info_digest);
|
||||||
tor_assert(sd3 == &(r->cache_info));
|
tor_assert(sd3 == &(r->cache_info));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd,
|
SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd,
|
||||||
{
|
{
|
||||||
r2 = digestmap_get(rl->identity_map, sd->identity_digest);
|
r2 = rimap_get(rl->identity_map, sd->identity_digest);
|
||||||
tor_assert(sd != &(r2->cache_info));
|
tor_assert(sd != &(r2->cache_info));
|
||||||
sd2 = digestmap_get(rl->desc_digest_map, sd->signed_descriptor_digest);
|
sd2 = sdmap_get(rl->desc_digest_map, sd->signed_descriptor_digest);
|
||||||
tor_assert(sd == sd2);
|
tor_assert(sd == sd2);
|
||||||
if (!tor_digest_is_zero(sd->extra_info_digest)) {
|
if (!tor_digest_is_zero(sd->extra_info_digest)) {
|
||||||
signed_descriptor_t *sd3 =
|
signed_descriptor_t *sd3 =
|
||||||
digestmap_get(rl->desc_by_eid_map, sd->extra_info_digest);
|
sdmap_get(rl->desc_by_eid_map, sd->extra_info_digest);
|
||||||
tor_assert(sd3 == sd);
|
tor_assert(sd3 == sd);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
iter = digestmap_iter_init(rl->identity_map);
|
|
||||||
|
iter = digestmap_iter_init((digestmap_t*)rl->identity_map);
|
||||||
while (!digestmap_iter_done(iter)) {
|
while (!digestmap_iter_done(iter)) {
|
||||||
const char *d;
|
const char *d;
|
||||||
void *_r;
|
void *_r;
|
||||||
@ -5180,9 +5185,9 @@ routerlist_assert_ok(routerlist_t *rl)
|
|||||||
digestmap_iter_get(iter, &d, &_r);
|
digestmap_iter_get(iter, &d, &_r);
|
||||||
r = _r;
|
r = _r;
|
||||||
tor_assert(!memcmp(r->cache_info.identity_digest, d, DIGEST_LEN));
|
tor_assert(!memcmp(r->cache_info.identity_digest, d, DIGEST_LEN));
|
||||||
iter = digestmap_iter_next(rl->identity_map, iter);
|
iter = digestmap_iter_next((digestmap_t*)rl->identity_map, iter);
|
||||||
}
|
}
|
||||||
iter = digestmap_iter_init(rl->desc_digest_map);
|
iter = digestmap_iter_init((digestmap_t*)rl->desc_digest_map);
|
||||||
while (!digestmap_iter_done(iter)) {
|
while (!digestmap_iter_done(iter)) {
|
||||||
const char *d;
|
const char *d;
|
||||||
void *_sd;
|
void *_sd;
|
||||||
@ -5190,9 +5195,9 @@ routerlist_assert_ok(routerlist_t *rl)
|
|||||||
digestmap_iter_get(iter, &d, &_sd);
|
digestmap_iter_get(iter, &d, &_sd);
|
||||||
sd = _sd;
|
sd = _sd;
|
||||||
tor_assert(!memcmp(sd->signed_descriptor_digest, d, DIGEST_LEN));
|
tor_assert(!memcmp(sd->signed_descriptor_digest, d, DIGEST_LEN));
|
||||||
iter = digestmap_iter_next(rl->desc_digest_map, iter);
|
iter = digestmap_iter_next((digestmap_t*)rl->desc_digest_map, iter);
|
||||||
}
|
}
|
||||||
iter = digestmap_iter_init(rl->desc_by_eid_map);
|
iter = digestmap_iter_init((digestmap_t*)rl->desc_by_eid_map);
|
||||||
while (!digestmap_iter_done(iter)) {
|
while (!digestmap_iter_done(iter)) {
|
||||||
const char *d;
|
const char *d;
|
||||||
void *_sd;
|
void *_sd;
|
||||||
@ -5202,9 +5207,9 @@ routerlist_assert_ok(routerlist_t *rl)
|
|||||||
tor_assert(!tor_digest_is_zero(d));
|
tor_assert(!tor_digest_is_zero(d));
|
||||||
tor_assert(sd);
|
tor_assert(sd);
|
||||||
tor_assert(!memcmp(sd->extra_info_digest, d, DIGEST_LEN));
|
tor_assert(!memcmp(sd->extra_info_digest, d, DIGEST_LEN));
|
||||||
iter = digestmap_iter_next(rl->desc_by_eid_map, iter);
|
iter = digestmap_iter_next((digestmap_t*)rl->desc_by_eid_map, iter);
|
||||||
}
|
}
|
||||||
iter = digestmap_iter_init(rl->extra_info_map);
|
iter = digestmap_iter_init((digestmap_t*)rl->extra_info_map);
|
||||||
while (!digestmap_iter_done(iter)) {
|
while (!digestmap_iter_done(iter)) {
|
||||||
const char *d;
|
const char *d;
|
||||||
void *_ei;
|
void *_ei;
|
||||||
@ -5214,12 +5219,12 @@ routerlist_assert_ok(routerlist_t *rl)
|
|||||||
ei = _ei;
|
ei = _ei;
|
||||||
tor_assert(!memcmp(ei->cache_info.signed_descriptor_digest,
|
tor_assert(!memcmp(ei->cache_info.signed_descriptor_digest,
|
||||||
d, DIGEST_LEN));
|
d, DIGEST_LEN));
|
||||||
sd = digestmap_get(rl->desc_by_eid_map,
|
sd = sdmap_get(rl->desc_by_eid_map,
|
||||||
ei->cache_info.signed_descriptor_digest);
|
ei->cache_info.signed_descriptor_digest);
|
||||||
tor_assert(sd);
|
tor_assert(sd);
|
||||||
tor_assert(!memcmp(ei->cache_info.signed_descriptor_digest,
|
tor_assert(!memcmp(ei->cache_info.signed_descriptor_digest,
|
||||||
sd->extra_info_digest, DIGEST_LEN));
|
sd->extra_info_digest, DIGEST_LEN));
|
||||||
iter = digestmap_iter_next(rl->extra_info_map, iter);
|
iter = digestmap_iter_next((digestmap_t*)rl->extra_info_map, iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5237,7 +5242,7 @@ routerlist_check_bug_417(void)
|
|||||||
if (!ri_generated)
|
if (!ri_generated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
r = digestmap_get(rl->identity_map,
|
r = rimap_get(rl->identity_map,
|
||||||
ri_generated->cache_info.identity_digest);
|
ri_generated->cache_info.identity_digest);
|
||||||
if (r) {
|
if (r) {
|
||||||
idx = r->routerlist_index;
|
idx = r->routerlist_index;
|
||||||
|
@ -900,9 +900,10 @@ router_parse_list_from_string(const char **s, const char *eos,
|
|||||||
|
|
||||||
if (have_extrainfo && want_extrainfo) {
|
if (have_extrainfo && want_extrainfo) {
|
||||||
routerlist_t *rl = router_get_routerlist();
|
routerlist_t *rl = router_get_routerlist();
|
||||||
|
/* XXXX020 fix this cast to digestmap_t* */
|
||||||
extrainfo = extrainfo_parse_entry_from_string(*s, end,
|
extrainfo = extrainfo_parse_entry_from_string(*s, end,
|
||||||
saved_location != SAVED_IN_CACHE,
|
saved_location != SAVED_IN_CACHE,
|
||||||
rl->identity_map);
|
(digestmap_t*)rl->identity_map);
|
||||||
if (extrainfo) {
|
if (extrainfo) {
|
||||||
signed_desc = &extrainfo->cache_info;
|
signed_desc = &extrainfo->cache_info;
|
||||||
elt = extrainfo;
|
elt = extrainfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user