Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Goulet
Tor
Commits
ac707ae7
Commit
ac707ae7
authored
Oct 14, 2016
by
Nick Mathewson
⛰
Browse files
Merge branch 'bug20176_v2'
parents
af70e431
cff1274b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/or/networkstatus.c
View file @
ac707ae7
...
...
@@ -43,14 +43,6 @@ static strmap_t *named_server_map = NULL;
* as unnamed for some server in the consensus. */
static
strmap_t
*
unnamed_server_map
=
NULL
;
/** Most recently received and validated v3 consensus network status,
* of whichever type we are using for our own circuits. This will be the same
* as one of current_ns_consensus or current_md_consensus.
*/
#define current_consensus \
(we_use_microdescriptors_for_circuits(get_options()) ? \
current_md_consensus : current_ns_consensus)
/** Most recently received and validated v3 "ns"-flavored consensus network
* status. */
static
networkstatus_t
*
current_ns_consensus
=
NULL
;
...
...
@@ -134,10 +126,8 @@ static int networkstatus_check_required_protocols(const networkstatus_t *ns,
void
networkstatus_reset_warnings
(
void
)
{
if
(
current_consensus
)
{
SMARTLIST_FOREACH
(
nodelist_get_list
(),
node_t
*
,
node
,
node
->
name_lookup_warned
=
0
);
}
SMARTLIST_FOREACH
(
nodelist_get_list
(),
node_t
*
,
node
,
node
->
name_lookup_warned
=
0
);
have_warned_about_old_version
=
0
;
have_warned_about_new_version
=
0
;
...
...
@@ -210,7 +200,7 @@ router_reload_consensus_networkstatus(void)
tor_free
(
filename
);
}
if
(
!
curren
t_consensus
)
{
if
(
!
networkstatus_get_lates
t_consensus
()
)
{
if
(
!
named_server_map
)
named_server_map
=
strmap_new
();
if
(
!
unnamed_server_map
)
...
...
@@ -657,7 +647,7 @@ router_get_mutable_consensus_status_by_descriptor_digest,(
const
char
*
digest
))
{
if
(
!
consensus
)
consensus
=
curren
t_consensus
;
consensus
=
networkstatus_get_lates
t_consensus
()
;
if
(
!
consensus
)
return
NULL
;
if
(
!
consensus
->
desc_digest_map
)
{
...
...
@@ -738,9 +728,11 @@ router_get_dl_status_by_descriptor_digest,(const char *d))
routerstatus_t
*
router_get_mutable_consensus_status_by_id
(
const
char
*
digest
)
{
if
(
!
current_consensus
)
const
networkstatus_t
*
ns
=
networkstatus_get_latest_consensus
();
if
(
!
ns
)
return
NULL
;
return
smartlist_bsearch
(
current_consensus
->
routerstatus_list
,
digest
,
smartlist_t
*
rslist
=
ns
->
routerstatus_list
;
return
smartlist_bsearch
(
rslist
,
digest
,
compare_digest_to_routerstatus_entry
);
}
...
...
@@ -1290,7 +1282,10 @@ networkstatus_get_dl_status_by_flavor_running,(consensus_flavor_t flavor))
MOCK_IMPL
(
networkstatus_t
*
,
networkstatus_get_latest_consensus
,(
void
))
{
return
current_consensus
;
if
(
we_use_microdescriptors_for_circuits
(
get_options
()))
return
current_md_consensus
;
else
return
current_ns_consensus
;
}
/** Return the latest consensus we have whose flavor matches <b>f</b>, or NULL
...
...
@@ -1313,10 +1308,10 @@ networkstatus_get_latest_consensus_by_flavor,(consensus_flavor_t f))
MOCK_IMPL
(
networkstatus_t
*
,
networkstatus_get_live_consensus
,(
time_t
now
))
{
if
(
curren
t_consensus
&&
curren
t_consensus
->
valid_after
<=
now
&&
now
<=
curren
t_consensus
->
valid_until
)
return
curren
t_consensus
;
if
(
networkstatus_get_lates
t_consensus
()
&&
networkstatus_get_lates
t_consensus
()
->
valid_after
<=
now
&&
now
<=
networkstatus_get_lates
t_consensus
()
->
valid_until
)
return
networkstatus_get_lates
t_consensus
()
;
else
return
NULL
;
}
...
...
@@ -1822,13 +1817,14 @@ networkstatus_set_current_consensus(const char *consensus,
const
int
is_usable_flavor
=
flav
==
usable_consensus_flavor
();
if
(
is_usable_flavor
)
{
notify_control_networkstatus_changed
(
current_consensus
,
c
);
notify_control_networkstatus_changed
(
networkstatus_get_latest_consensus
(),
c
);
}
if
(
flav
==
FLAV_NS
)
{
if
(
current_ns_consensus
)
{
networkstatus_copy_old_consensus_info
(
c
,
current_ns_consensus
);
networkstatus_vote_free
(
current_ns_consensus
);
/* Defensive programming : we should set current_consensus very soon
,
/* Defensive programming : we should set current_
ns_
consensus very soon
* but we're about to call some stuff in the meantime, and leaving this
* dangling pointer around has proven to be trouble. */
current_ns_consensus
=
NULL
;
...
...
@@ -1876,7 +1872,7 @@ networkstatus_set_current_consensus(const char *consensus,
/* Update ewma and adjust policy if needed; first cache the old value */
old_ewma_enabled
=
cell_ewma_enabled
();
/* Change the cell EWMA settings */
cell_ewma_set_scale_factor
(
options
,
networkstatus_get_latest_consensus
()
);
cell_ewma_set_scale_factor
(
options
,
c
);
/* If we just enabled ewma, set the cmux policy on all active channels */
if
(
cell_ewma_enabled
()
&&
!
old_ewma_enabled
)
{
channel_set_cmux_policy_everywhere
(
&
ewma_policy
);
...
...
@@ -1889,8 +1885,8 @@ networkstatus_set_current_consensus(const char *consensus,
* current consensus really alter our view of any OR's rate limits? */
connection_or_update_token_buckets
(
get_connection_array
(),
options
);
circuit_build_times_new_consensus_params
(
get_circuit_build_times_mutable
(),
current_consensus
);
circuit_build_times_new_consensus_params
(
get_circuit_build_times_mutable
(),
c
);
}
/* Reset the failure count only if this consensus is actually valid. */
...
...
@@ -2040,15 +2036,16 @@ routers_update_all_from_networkstatus(time_t now, int dir_version)
static
void
routerstatus_list_update_named_server_map
(
void
)
{
if
(
!
current_consensus
)
networkstatus_t
*
ns
=
networkstatus_get_latest_consensus
();
if
(
!
ns
)
return
;
strmap_free
(
named_server_map
,
tor_free_
);
named_server_map
=
strmap_new
();
strmap_free
(
unnamed_server_map
,
NULL
);
unnamed_server_map
=
strmap_new
();
SMARTLIST_FOREACH_BEGIN
(
current_consensu
s
->
routerstatus_list
,
const
routerstatus_t
*
,
rs
)
{
smartlist_t
*
rslist
=
n
s
->
routerstatus_list
;
SMARTLIST_FOREACH_BEGIN
(
rslist
,
const
routerstatus_t
*
,
rs
)
{
if
(
rs
->
is_named
)
{
strmap_set_lc
(
named_server_map
,
rs
->
nickname
,
tor_memdup
(
rs
->
identity_digest
,
DIGEST_LEN
));
...
...
@@ -2068,7 +2065,7 @@ routers_update_status_from_consensus_networkstatus(smartlist_t *routers,
{
const
or_options_t
*
options
=
get_options
();
int
authdir
=
authdir_mode_v3
(
options
);
networkstatus_t
*
ns
=
curren
t_consensus
;
networkstatus_t
*
ns
=
networkstatus_get_lates
t_consensus
()
;
if
(
!
ns
||
!
smartlist_len
(
ns
->
routerstatus_list
))
return
;
...
...
@@ -2384,14 +2381,14 @@ getinfo_helper_networkstatus(control_connection_t *conn,
const
routerstatus_t
*
status
;
(
void
)
conn
;
if
(
!
curren
t_consensus
)
{
if
(
!
networkstatus_get_lates
t_consensus
()
)
{
*
answer
=
tor_strdup
(
""
);
return
0
;
}
if
(
!
strcmp
(
question
,
"ns/all"
))
{
smartlist_t
*
statuses
=
smartlist_new
();
SMARTLIST_FOREACH
(
curren
t_consensus
->
routerstatus_list
,
SMARTLIST_FOREACH
(
networkstatus_get_lates
t_consensus
()
->
routerstatus_list
,
const
routerstatus_t
*
,
rs
,
{
smartlist_add
(
statuses
,
networkstatus_getinfo_helper_single
(
rs
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment