[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] addr: Rename last_resolved_addr to be v4 specific



commit d08d7e1535fe7b47319e67ca31d4b8f64fdea465
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Mon Jun 15 15:31:34 2020 -0400

    addr: Rename last_resolved_addr to be v4 specific
    
    Part of #33233
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/app/config/resolve_addr.c       | 28 ++++++++++++++--------------
 src/app/config/resolve_addr.h       |  4 ++--
 src/core/mainloop/connection.c      |  2 +-
 src/feature/relay/relay_find_addr.c |  4 ++--
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/app/config/resolve_addr.c b/src/app/config/resolve_addr.c
index fe375848d..6b66a7100 100644
--- a/src/app/config/resolve_addr.c
+++ b/src/app/config/resolve_addr.c
@@ -20,20 +20,20 @@
 #include "lib/net/resolve.h"
 
 /** Last value actually set by resolve_my_address. */
-static uint32_t last_resolved_addr = 0;
+static uint32_t last_resolved_addr_v4 = 0;
 
-/** Accessor for last_resolved_addr from outside this file. */
+/** Accessor for last_resolved_addr_v4 from outside this file. */
 uint32_t
-get_last_resolved_addr(void)
+get_last_resolved_addr_v4(void)
 {
-  return last_resolved_addr;
+  return last_resolved_addr_v4;
 }
 
-/** Reset last_resolved_addr from outside this file. */
+/** Reset last_resolved_addr_v4 from outside this file. */
 void
-reset_last_resolved_addr(void)
+reset_last_resolved_addr_v4(void)
 {
-  last_resolved_addr = 0;
+  last_resolved_addr_v4 = 0;
 }
 
 /**
@@ -257,7 +257,7 @@ resolve_my_address_v4(int warn_severity, const or_options_t *options,
    * us up-to-date.
    */
 
-  if (last_resolved_addr && last_resolved_addr != *addr_out) {
+  if (last_resolved_addr_v4 && last_resolved_addr_v4 != *addr_out) {
     /* Leave this as a notice, regardless of the requested severity,
      * at least until dynamic IP address support becomes bulletproof. */
     log_notice(LD_NET,
@@ -269,14 +269,14 @@ resolve_my_address_v4(int warn_severity, const or_options_t *options,
     ip_address_changed(0);
   }
 
-  if (last_resolved_addr != *addr_out) {
+  if (last_resolved_addr_v4 != *addr_out) {
     control_event_server_status(LOG_NOTICE,
                                 "EXTERNAL_ADDRESS ADDRESS=%s METHOD=%s%s%s",
                                 addr_string, method_used,
                                 hostname_used ? " HOSTNAME=" : "",
                                 hostname_used ? hostname_used : "");
   }
-  last_resolved_addr = *addr_out;
+  last_resolved_addr_v4 = *addr_out;
 
   /*
    * And finally, clean up and return success.
@@ -303,11 +303,11 @@ is_local_addr, (const tor_addr_t *addr))
     /* It's possible that this next check will hit before the first time
      * resolve_my_address actually succeeds.  (For clients, it is likely that
      * resolve_my_address will never be called at all).  In those cases,
-     * last_resolved_addr will be 0, and so checking to see whether ip is on
-     * the same /24 as last_resolved_addr will be the same as checking whether
-     * it was on net 0, which is already done by tor_addr_is_internal.
+     * last_resolved_addr_v4 will be 0, and so checking to see whether ip is
+     * on the same /24 as last_resolved_addr_v4 will be the same as checking
+     * whether it was on net 0, which is already done by tor_addr_is_internal.
      */
-    if ((last_resolved_addr & (uint32_t)0xffffff00ul)
+    if ((last_resolved_addr_v4 & (uint32_t)0xffffff00ul)
         == (ip & (uint32_t)0xffffff00ul))
       return 1;
   }
diff --git a/src/app/config/resolve_addr.h b/src/app/config/resolve_addr.h
index 2c8143df5..6c94fe06b 100644
--- a/src/app/config/resolve_addr.h
+++ b/src/app/config/resolve_addr.h
@@ -15,8 +15,8 @@ int resolve_my_address_v4(int warn_severity, const or_options_t *options,
                           uint32_t *addr_out,
                           const char **method_out, char **hostname_out);
 
-uint32_t get_last_resolved_addr(void);
-void reset_last_resolved_addr(void);
+uint32_t get_last_resolved_addr_v4(void);
+void reset_last_resolved_addr_v4(void);
 
 MOCK_DECL(int, is_local_addr, (const tor_addr_t *addr));
 
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c
index a8417e46d..9fff71ee0 100644
--- a/src/core/mainloop/connection.c
+++ b/src/core/mainloop/connection.c
@@ -4870,7 +4870,7 @@ client_check_address_changed(tor_socket_t sock)
     smartlist_clear(outgoing_addrs);
     smartlist_add(outgoing_addrs, tor_memdup(&out_addr, sizeof(tor_addr_t)));
     /* We'll need to resolve ourselves again. */
-    reset_last_resolved_addr();
+    reset_last_resolved_addr_v4();
     /* Okay, now change our keys. */
     ip_address_changed(1);
   }
diff --git a/src/feature/relay/relay_find_addr.c b/src/feature/relay/relay_find_addr.c
index 561ef1507..cc08914f6 100644
--- a/src/feature/relay/relay_find_addr.c
+++ b/src/feature/relay/relay_find_addr.c
@@ -64,7 +64,7 @@ router_new_address_suggestion(const char *suggestion,
   }
 
   /* XXXX ipv6 */
-  cur = get_last_resolved_addr();
+  cur = get_last_resolved_addr_v4();
   if (cur ||
       resolve_my_address_v4(LOG_INFO, options, &cur, NULL, NULL) >= 0) {
     /* We're all set -- we already know our address. Great. */
@@ -112,7 +112,7 @@ router_pick_published_address, (const or_options_t *options, uint32_t *addr,
                                 int cache_only))
 {
   /* First, check the cached output from resolve_my_address(). */
-  *addr = get_last_resolved_addr();
+  *addr = get_last_resolved_addr_v4();
   if (*addr)
     return 0;
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits