]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge remote branch 'origin/maint-0.2.2'
authorNick Mathewson <nickm@torproject.org>
Mon, 14 Mar 2011 20:34:33 +0000 (16:34 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 14 Mar 2011 20:34:33 +0000 (16:34 -0400)
Resolved nontrivial conflict around rewrite_x_address_for_bridge and
learned_bridge_descriptor.  Now, since leanred_bridge_descriptor works
on nodes, we must make sure that rewrite_node_address_for_bridge also
works on nodes.

Conflicts:
src/or/circuitbuild.c

1  2 
src/or/circuitbuild.c
src/or/or.h
src/or/routerlist.c

index 7ad3b07500c9dde395ebf2f01bec4ab59897a639,a54f232f5124480682f70be009b0347f1211bfd9..e2b5f138d96a508215a7dd3c1219c2e5d3203043
@@@ -4688,6 -4671,29 +4688,55 @@@ fetch_bridge_descriptors(or_options_t *
    SMARTLIST_FOREACH_END(bridge);
  }
  
 - * the bridge gives in its routerinfo <b>ri</b>, rewrite the routerinfo
+ /** If our <b>bridge</b> is configured to be a different address than
 -rewrite_routerinfo_address_for_bridge(bridge_info_t *bridge, routerinfo_t *ri)
++ * the bridge gives in <b>node</b>, rewrite the routerinfo
+  * we received to use the address we meant to use. Now we handle
+  * multihomed bridges better.
+  */
+ static void
 -  tor_addr_from_ipv4h(&addr, ri->addr);
++rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
+ {
++  /* XXXX move this function. */
++  /* XXXX overridden addresses should really live in the node_t, so that the
++   *   routerinfo_t and the microdesc_t can be immutable.  But we can only
++   *   do that safely if
++   */
+   tor_addr_t addr;
 -  if (!tor_addr_compare(&bridge->addr, &addr, CMP_EXACT) &&
 -      bridge->port == ri->or_port)
 -    return; /* they match, so no need to do anything */
 -  ri->addr = tor_addr_to_ipv4h(&bridge->addr);
 -  tor_free(ri->address);
 -  ri->address = tor_dup_ip(ri->addr);
 -  ri->or_port = bridge->port;
 -  log_info(LD_DIR, "Adjusted bridge '%s' to match configured address %s:%d.",
 -           ri->nickname, ri->address, ri->or_port);
++  if (node->ri) {
++    routerinfo_t *ri = node->ri;
++    tor_addr_from_ipv4h(&addr, ri->addr);
++
++    if (!tor_addr_compare(&bridge->addr, &addr, CMP_EXACT) &&
++        bridge->port == ri->or_port) {
++      /* they match, so no need to do anything */
++    } else {
++      ri->addr = tor_addr_to_ipv4h(&bridge->addr);
++      tor_free(ri->address);
++      ri->address = tor_dup_ip(ri->addr);
++      ri->or_port = bridge->port;
++      log_info(LD_DIR,
++               "Adjusted bridge '%s' to match configured address %s:%d.",
++               ri->nickname, ri->address, ri->or_port);
++    }
++  }
++  if (node->rs) {
++    routerstatus_t *rs = node->rs;
++    tor_addr_from_ipv4h(&addr, rs->addr);
++    if (!tor_addr_compare(&bridge->addr, &addr, CMP_EXACT) &&
++        bridge->port == rs->or_port) {
++      /* they match, so no need to do anything */
++    } else {
++      rs->addr = tor_addr_to_ipv4h(&bridge->addr);
++      rs->or_port = bridge->port;
++      log_info(LD_DIR,
++               "Adjusted bridge '%s' to match configured address %s:%d.",
++               rs->nickname, fmt_addr(&bridge->addr), rs->or_port);
++    }
++  }
+ }
  /** We just learned a descriptor for a bridge. See if that
   * digest is in our entry guard list, and add it if not. */
  void
@@@ -4699,17 -4705,16 +4748,19 @@@ learned_bridge_descriptor(routerinfo_t 
      int first = !any_bridge_descriptors_known();
      bridge_info_t *bridge = get_configured_bridge_by_routerinfo(ri);
      time_t now = time(NULL);
 -    ri->is_running = 1;
 +    router_set_status(ri->cache_info.identity_digest, 1);
  
      if (bridge) { /* if we actually want to use this one */
-       const node_t *node;
++      node_t *node;
        /* it's here; schedule its re-fetch for a long time from now. */
        if (!from_cache)
          download_status_reset(&bridge->fetch_status);
  
-       node = node_get_by_id(ri->cache_info.identity_digest);
 -      rewrite_routerinfo_address_for_bridge(bridge, ri);
++      node = node_get_mutable_by_id(ri->cache_info.identity_digest);
 +      tor_assert(node);
++      rewrite_node_address_for_bridge(bridge, node);
 +      add_an_entry_guard(node, 1);
 -      add_an_entry_guard(ri, 1);
        log_notice(LD_DIR, "new bridge descriptor '%s' (%s)", ri->nickname,
                   from_cache ? "cached" : "fresh");
        /* set entry->made_contact so if it goes down we don't drop it from
diff --cc src/or/or.h
Simple merge
Simple merge