only log "new bridge descriptor" if really new

The bridge descriptor fetching codes ends up fetching a lot of duplicate
bridge descriptors, because this is how we learn when the descriptor
changes.

This commit only changes comments plus whether we log that one line.

It moves us back to the old behavior, before the previous commit for
30496, where we would only log that line when the bridge descriptor
we're talking about is better than the one we already had (if any).
This commit is contained in:
Roger Dingledine 2021-10-28 20:53:26 -04:00
parent d66549c208
commit 867c3c6f89
3 changed files with 18 additions and 7 deletions

View File

@ -943,9 +943,17 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
}
/** We just learned a descriptor for a bridge. See if that
* digest is in our entry guard list, and add it if not. */
* digest is in our entry guard list, and add it if not. Schedule the
* next fetch for a long time from now, and initiate any follow-up
* activities like continuing to bootstrap.
*
* <b>from_cache</b> * tells us whether we fetched it from disk (else
* the network)
*
* <b>desc_is_new</b> tells us if we preferred it to the old version we
* had, if any. */
void
learned_bridge_descriptor(routerinfo_t *ri, int from_cache)
learned_bridge_descriptor(routerinfo_t *ri, int from_cache, int desc_is_new)
{
tor_assert(ri);
tor_assert(ri->purpose == ROUTER_PURPOSE_BRIDGE);
@ -984,8 +992,10 @@ learned_bridge_descriptor(routerinfo_t *ri, int from_cache)
entry_guard_learned_bridge_identity(&bridge->addrport_configured,
(const uint8_t*)ri->cache_info.identity_digest);
log_notice(LD_DIR, "new bridge descriptor '%s' (%s): %s", ri->nickname,
from_cache ? "cached" : "fresh", router_describe(ri));
if (desc_is_new)
log_notice(LD_DIR, "new bridge descriptor '%s' (%s): %s",
ri->nickname,
from_cache ? "cached" : "fresh", router_describe(ri));
/* If we didn't have a reachable bridge before this one, try directory
* documents again. */
if (first) {

View File

@ -46,7 +46,8 @@ void learned_router_identity(const tor_addr_t *addr, uint16_t port,
void bridge_add_from_config(struct bridge_line_t *bridge_line);
void retry_bridge_descriptor_fetch_directly(const char *digest);
void fetch_bridge_descriptors(const or_options_t *options, time_t now);
void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
void learned_bridge_descriptor(routerinfo_t *ri,
int from_cache, int desc_is_new);
const smartlist_t *get_socks_args_by_bridge_addrport(const tor_addr_t *addr,
uint16_t port);

View File

@ -1622,7 +1622,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
* let the bridge descriptor fetch subsystem know that we
* succeeded at getting it -- so we can adjust the retry schedule
* to stop trying for a while. */
learned_bridge_descriptor(router, from_cache);
learned_bridge_descriptor(router, from_cache, 0);
}
log_info(LD_DIR,
"Dropping descriptor that we already have for router %s",
@ -2054,7 +2054,7 @@ routerlist_descriptors_added(smartlist_t *sl, int from_cache)
control_event_descriptors_changed(sl);
SMARTLIST_FOREACH_BEGIN(sl, routerinfo_t *, ri) {
if (ri->purpose == ROUTER_PURPOSE_BRIDGE)
learned_bridge_descriptor(ri, from_cache);
learned_bridge_descriptor(ri, from_cache, 1);
if (ri->needs_retest_if_added) {
ri->needs_retest_if_added = 0;
dirserv_single_reachability_test(approx_time(), ri);