relay: Clarify reachability status check functions

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        check_whether_orport_reachable router_skip_orport_reachability_check \
        check_whether_dirport_reachable router_skip_dirport_reachability_check

It was generated with --no-verify, so it probably breaks some commit hooks.
The commiter should be sure to fix them up in a subsequent commit.

Part of 33222.
This commit is contained in:
teor 2020-04-30 15:11:50 +10:00
parent a202f03c64
commit c5ee3d7eb8
8 changed files with 23 additions and 23 deletions

View File

@ -1050,7 +1050,7 @@ circuit_build_no_more_hops(origin_circuit_t *circ)
control_event_bootstrap(BOOTSTRAP_STATUS_DONE, 0); control_event_bootstrap(BOOTSTRAP_STATUS_DONE, 0);
control_event_client_status(LOG_NOTICE, "CIRCUIT_ESTABLISHED"); control_event_client_status(LOG_NOTICE, "CIRCUIT_ESTABLISHED");
clear_broken_connection_map(1); clear_broken_connection_map(1);
if (server_mode(options) && !check_whether_orport_reachable(options)) { if (server_mode(options) && !router_skip_orport_reachability_check(options)) {
inform_testing_reachability(); inform_testing_reachability();
router_do_reachability_checks(1, 1); router_do_reachability_checks(1, 1);
} }

View File

@ -1641,7 +1641,7 @@ static void
circuit_testing_opened(origin_circuit_t *circ) circuit_testing_opened(origin_circuit_t *circ)
{ {
if (have_performed_bandwidth_test || if (have_performed_bandwidth_test ||
!check_whether_orport_reachable(get_options())) { !router_skip_orport_reachability_check(get_options())) {
/* either we've already done everything we want with testing circuits, /* either we've already done everything we want with testing circuits,
* or this testing circuit became open due to a fluke, e.g. we picked * or this testing circuit became open due to a fluke, e.g. we picked
* a last hop where we already had the connection open due to an * a last hop where we already had the connection open due to an
@ -1659,7 +1659,7 @@ static void
circuit_testing_failed(origin_circuit_t *circ, int at_last_hop) circuit_testing_failed(origin_circuit_t *circ, int at_last_hop)
{ {
const or_options_t *options = get_options(); const or_options_t *options = get_options();
if (server_mode(options) && check_whether_orport_reachable(options)) if (server_mode(options) && router_skip_orport_reachability_check(options))
return; return;
log_info(LD_GENERAL, log_info(LD_GENERAL,

View File

@ -1276,15 +1276,15 @@ getinfo_helper_events(control_connection_t *control_conn,
*answer = tor_strdup(directories_have_accepted_server_descriptor() *answer = tor_strdup(directories_have_accepted_server_descriptor()
? "1" : "0"); ? "1" : "0");
} else if (!strcmp(question, "status/reachability-succeeded/or")) { } else if (!strcmp(question, "status/reachability-succeeded/or")) {
*answer = tor_strdup(check_whether_orport_reachable(options) ? *answer = tor_strdup(router_skip_orport_reachability_check(options) ?
"1" : "0"); "1" : "0");
} else if (!strcmp(question, "status/reachability-succeeded/dir")) { } else if (!strcmp(question, "status/reachability-succeeded/dir")) {
*answer = tor_strdup(check_whether_dirport_reachable(options) ? *answer = tor_strdup(router_skip_dirport_reachability_check(options) ?
"1" : "0"); "1" : "0");
} else if (!strcmp(question, "status/reachability-succeeded")) { } else if (!strcmp(question, "status/reachability-succeeded")) {
tor_asprintf(answer, "OR=%d DIR=%d", tor_asprintf(answer, "OR=%d DIR=%d",
check_whether_orport_reachable(options) ? 1 : 0, router_skip_orport_reachability_check(options) ? 1 : 0,
check_whether_dirport_reachable(options) ? 1 : 0); router_skip_dirport_reachability_check(options) ? 1 : 0);
} else if (!strcmp(question, "status/bootstrap-phase")) { } else if (!strcmp(question, "status/bootstrap-phase")) {
*answer = control_event_boot_last_msg(); *answer = control_event_boot_last_msg();
} else if (!strcmpstart(question, "status/version/")) { } else if (!strcmpstart(question, "status/version/")) {

View File

@ -201,7 +201,7 @@ reachability_warnings_callback(time_t now, const or_options_t *options)
have_completed_a_circuit()) { have_completed_a_circuit()) {
/* every 20 minutes, check and complain if necessary */ /* every 20 minutes, check and complain if necessary */
const routerinfo_t *me = router_get_my_routerinfo(); const routerinfo_t *me = router_get_my_routerinfo();
if (me && !check_whether_orport_reachable(options)) { if (me && !router_skip_orport_reachability_check(options)) {
char *address = tor_dup_ip(me->addr); char *address = tor_dup_ip(me->addr);
log_warn(LD_CONFIG,"Your server (%s:%d) has not managed to confirm that " log_warn(LD_CONFIG,"Your server (%s:%d) has not managed to confirm that "
"its ORPort is reachable. Relays do not publish descriptors " "its ORPort is reachable. Relays do not publish descriptors "
@ -214,7 +214,7 @@ reachability_warnings_callback(time_t now, const or_options_t *options)
tor_free(address); tor_free(address);
} }
if (me && !check_whether_dirport_reachable(options)) { if (me && !router_skip_dirport_reachability_check(options)) {
char *address = tor_dup_ip(me->addr); char *address = tor_dup_ip(me->addr);
log_warn(LD_CONFIG, log_warn(LD_CONFIG,
"Your server (%s:%d) has not managed to confirm that its " "Your server (%s:%d) has not managed to confirm that its "

View File

@ -1361,14 +1361,14 @@ decide_if_publishable_server(void)
return 1; return 1;
if (!router_get_advertised_or_port(options)) if (!router_get_advertised_or_port(options))
return 0; return 0;
if (!check_whether_orport_reachable(options)) if (!router_skip_orport_reachability_check(options))
return 0; return 0;
if (router_have_consensus_path() == CONSENSUS_PATH_INTERNAL) { if (router_have_consensus_path() == CONSENSUS_PATH_INTERNAL) {
/* All set: there are no exits in the consensus (maybe this is a tiny /* All set: there are no exits in the consensus (maybe this is a tiny
* test network), so we can't check our DirPort reachability. */ * test network), so we can't check our DirPort reachability. */
return 1; return 1;
} else { } else {
return check_whether_dirport_reachable(options); return router_skip_dirport_reachability_check(options);
} }
} }

View File

@ -70,7 +70,7 @@ router_reachability_checks_disabled(const or_options_t *options)
* - the network is disabled. * - the network is disabled.
*/ */
int int
check_whether_orport_reachable(const or_options_t *options) router_skip_orport_reachability_check(const or_options_t *options)
{ {
int reach_checks_disabled = router_reachability_checks_disabled(options); int reach_checks_disabled = router_reachability_checks_disabled(options);
return reach_checks_disabled || return reach_checks_disabled ||
@ -87,7 +87,7 @@ check_whether_orport_reachable(const or_options_t *options)
* - the network is disabled. * - the network is disabled.
*/ */
int int
check_whether_dirport_reachable(const or_options_t *options) router_skip_dirport_reachability_check(const or_options_t *options)
{ {
int reach_checks_disabled = router_reachability_checks_disabled(options) || int reach_checks_disabled = router_reachability_checks_disabled(options) ||
!options->DirPort_set; !options->DirPort_set;
@ -171,7 +171,7 @@ router_do_reachability_checks(int test_or, int test_dir)
{ {
const routerinfo_t *me = router_get_my_routerinfo(); const routerinfo_t *me = router_get_my_routerinfo();
const or_options_t *options = get_options(); const or_options_t *options = get_options();
int orport_reachable = check_whether_orport_reachable(options); int orport_reachable = router_skip_orport_reachability_check(options);
tor_addr_t addr; tor_addr_t addr;
if (router_should_check_reachability(test_or, test_dir)) { if (router_should_check_reachability(test_or, test_dir)) {
@ -188,7 +188,7 @@ router_do_reachability_checks(int test_or, int test_dir)
/* XXX IPv6 self testing */ /* XXX IPv6 self testing */
tor_addr_from_ipv4h(&addr, me->addr); tor_addr_from_ipv4h(&addr, me->addr);
if (test_dir && !check_whether_dirport_reachable(options) && if (test_dir && !router_skip_dirport_reachability_check(options) &&
!connection_get_by_type_addr_port_purpose( !connection_get_by_type_addr_port_purpose(
CONN_TYPE_DIR, &addr, me->dir_port, CONN_TYPE_DIR, &addr, me->dir_port,
DIR_PURPOSE_FETCH_SERVERDESC)) { DIR_PURPOSE_FETCH_SERVERDESC)) {
@ -258,7 +258,7 @@ router_orport_found_reachable(void)
log_notice(LD_OR,"Self-testing indicates your ORPort is reachable from " log_notice(LD_OR,"Self-testing indicates your ORPort is reachable from "
"the outside. Excellent.%s", "the outside. Excellent.%s",
options->PublishServerDescriptor_ != NO_DIRINFO options->PublishServerDescriptor_ != NO_DIRINFO
&& check_whether_dirport_reachable(options) ? && router_skip_dirport_reachability_check(options) ?
" Publishing server descriptor." : ""); " Publishing server descriptor." : "");
can_reach_or_port = 1; can_reach_or_port = 1;
mark_my_descriptor_dirty("ORPort found reachable"); mark_my_descriptor_dirty("ORPort found reachable");
@ -285,7 +285,7 @@ router_dirport_found_reachable(void)
log_notice(LD_DIRSERV,"Self-testing indicates your DirPort is reachable " log_notice(LD_DIRSERV,"Self-testing indicates your DirPort is reachable "
"from the outside. Excellent.%s", "from the outside. Excellent.%s",
options->PublishServerDescriptor_ != NO_DIRINFO options->PublishServerDescriptor_ != NO_DIRINFO
&& check_whether_orport_reachable(options) ? && router_skip_orport_reachability_check(options) ?
" Publishing server descriptor." : ""); " Publishing server descriptor." : "");
can_reach_dir_port = 1; can_reach_dir_port = 1;
if (router_should_advertise_dirport(options, me->dir_port)) { if (router_should_advertise_dirport(options, me->dir_port)) {

View File

@ -15,8 +15,8 @@
#ifdef HAVE_MODULE_RELAY #ifdef HAVE_MODULE_RELAY
struct or_options_t; struct or_options_t;
int check_whether_orport_reachable(const struct or_options_t *options); int router_skip_orport_reachability_check(const struct or_options_t *options);
int check_whether_dirport_reachable(const struct or_options_t *options); int router_skip_dirport_reachability_check(const struct or_options_t *options);
void router_do_reachability_checks(int test_or, int test_dir); void router_do_reachability_checks(int test_or, int test_dir);
void router_perform_bandwidth_test(int num_circs, time_t now); void router_perform_bandwidth_test(int num_circs, time_t now);
@ -29,9 +29,9 @@ void router_reset_reachability(void);
#else /* !defined(HAVE_MODULE_RELAY) */ #else /* !defined(HAVE_MODULE_RELAY) */
#define check_whether_orport_reachable(opts) \ #define router_skip_orport_reachability_check(opts) \
((void)(opts), 0) ((void)(opts), 0)
#define check_whether_dirport_reachable(opts) \ #define router_skip_dirport_reachability_check(opts) \
((void)(opts), 0) ((void)(opts), 0)
static inline void static inline void

View File

@ -270,10 +270,10 @@ rep_hist_circbuilding_dormant(time_t now)
/* see if we'll still need to build testing circuits */ /* see if we'll still need to build testing circuits */
if (server_mode(options) && if (server_mode(options) &&
(!check_whether_orport_reachable(options) || (!router_skip_orport_reachability_check(options) ||
!circuit_enough_testing_circs())) !circuit_enough_testing_circs()))
return 0; return 0;
if (!check_whether_dirport_reachable(options)) if (!router_skip_dirport_reachability_check(options))
return 0; return 0;
return 1; return 1;