/** Return true iff router1 and router2 have similar enough network addresses * that we should treat them as being in the same family */static INLINE intaddrs_in_same_network_family(const tor_addr_t *a1, const tor_addr_t *a2){ return 0 == tor_addr_compare_masked(a1, a2, 16, CMP_SEMANTIC);}
to determine if an address is in the same family. For an example IPv6 address, 2001:1234::0:1, its /16 representation is 2001::/16, meaning that 2001:ffff:: would be in the same family. A \16 for IPv6 is huge, particularly considering that only one-eighth of all IPv6 space is currently allocated for use on the internet (2000::/3). For the path selection code, using /16 essentially means that no two IPv6 routers in the same country (or possibly even continent) will be in the same path, and might possibly provide extremely increased chance of selection to routers in weird/rare IPv6 subnets.
Trac: Description: When EnforceDistinctSubnets is enabled, tor uses:
/** Return true iff router1 and router2 have similar enough network addresses * that we should treat them as being in the same family */static INLINE intaddrs_in_same_network_family(const tor_addr_t *a1, const tor_addr_t *a2){ return 0 == tor_addr_compare_masked(a1, a2, 16, CMP_SEMANTIC);}
to determine if an address is in the same family. For an example IPv6 address, 2001:1234::0:1, its /16 representation is 2001::/16, meaning that 2001:ffff:: would be in the same family. A \16 for IPv6 is huge, particularly considering that only one-eighth of all IPv6 space is currently allocated for use on the internet (2000::/3).
/** Return true iff router1 and router2 have similar enough network addresses * that we should treat them as being in the same family */static INLINE intaddrs_in_same_network_family(const tor_addr_t *a1, const tor_addr_t *a2){ return 0 == tor_addr_compare_masked(a1, a2, 16, CMP_SEMANTIC);}
to determine if an address is in the same family. For an example IPv6 address, 2001:1234::0:1, its /16 representation is 2001::/16, meaning that 2001:ffff:: would be in the same family. A \16 for IPv6 is huge, particularly considering that only one-eighth of all IPv6 space is currently allocated for use on the internet (2000::/3). for the path selection code, using /16 essentially means that no two IPv6 routers in the same country (or possibly even continent) will be in the same path, and might possibly provide extremely increased chance of selection to routers in weird/rare IPv6 subnets.
Trac: Description: When EnforceDistinctSubnets is enabled, tor uses:
/** Return true iff router1 and router2 have similar enough network addresses * that we should treat them as being in the same family */static INLINE intaddrs_in_same_network_family(const tor_addr_t *a1, const tor_addr_t *a2){ return 0 == tor_addr_compare_masked(a1, a2, 16, CMP_SEMANTIC);}
to determine if an address is in the same family. For an example IPv6 address, 2001:1234::0:1, its /16 representation is 2001::/16, meaning that 2001:ffff:: would be in the same family. A \16 for IPv6 is huge, particularly considering that only one-eighth of all IPv6 space is currently allocated for use on the internet (2000::/3). for the path selection code, using /16 essentially means that no two IPv6 routers in the same country (or possibly even continent) will be in the same path, and might possibly provide extremely increased chance of selection to routers in weird/rare IPv6 subnets.
/** Return true iff router1 and router2 have similar enough network addresses * that we should treat them as being in the same family */static INLINE intaddrs_in_same_network_family(const tor_addr_t *a1, const tor_addr_t *a2){ return 0 == tor_addr_compare_masked(a1, a2, 16, CMP_SEMANTIC);}
to determine if an address is in the same family. For an example IPv6 address, 2001:1234::0:1, its /16 representation is 2001::/16, meaning that 2001:ffff:: would be in the same family. A \16 for IPv6 is huge, particularly considering that only one-eighth of all IPv6 space is currently allocated for use on the internet (2000::/3). For the path selection code, using /16 essentially means that no two IPv6 routers in the same country (or possibly even continent) will be in the same path, and might possibly provide extremely increased chance of selection to routers in weird/rare IPv6 subnets.
Fortunately, that function is only called on the output of node_get_addr(), which calls node_get_prim_orport(), which can only return an IPv4 address. But we should come back to this when we do more with IPv6 addresses, and also when we fix #7193 (moved).
Trac: Milestone: Tor: 0.2.7.x-final to Tor: 0.2.??? Priority: major to normal
I am okay in working with you, as I am a beginner, I'll get to learn in the process. Can you give me a small feedback on how much you have worked. We can communicate via irc or e-mail.
I found tor_addr_compare and tor_addr_compare_masked in address.h which compares the address:
int tor_addr_compare(const tor_addr_t *addr1, const tor_addr_t *addr2,
tor_addr_comparison_t how);
int tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t *addr2,
maskbits_t mask, tor_addr_comparison_t how);
I also came across this snippet in address.c which is below. Is the the block of code which compares for /16 i.e IPv4?
case AF_INET: {
uint32_t a1 = tor_addr_to_ipv4h(addr1);
uint32_t a2 = tor_addr_to_ipv4h(addr2);
if (mbits <= 0)
return 0;
if (mbits > 32)
mbits = 32;
a1 >>= (32-mbits);
a2 >>= (32-mbits);
r = TRISTATE(a1, a2);
return r;
}
Hi,
btw, I already spent time with this. If you can wait, I can help you tomorrow with my solution ;).
I have only been very distracted by other stuff, the last days.
It's a longer thing, and I'm sleepy. >.<
See you.
Some development environments will index C code and let you search it.
Or you can use an editor or search application that looks for a string in all the files in the tor source directory.
Or you can use command line tools to do the search like this:
Are you still interested in this bug report? If not, could I take it?
EDIT: I'm asking because I don't want to steal this bug report. I accidentally reassigned it to myself but then realized you had it so I gave it back to you.
Your pull request has some extra commits a358d29, 438fc91 and a merge commit 81a2829. Next time you're updating a pull request, please add commits that just contain the new changes. (Re-doing all the changes, and doing merges, makes it harder to review your code.)
Here's how you can add changes to an existing branch in a terminal:
git checkout b15518git pull(use your editor to make changes)git add -pgit add new-file-namegit commitgit push origin b15518