[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #33618 [Core Tor/Tor]: Add IPv6 Support to is_local_addr()
#33618: Add IPv6 Support to is_local_addr()
------------------------------------------+--------------------------------
Reporter: kimimaro | Owner: (none)
Type: enhancement | Status: new
Priority: Medium | Milestone: Tor:
| 0.4.4.x-final
Component: Core Tor/Tor | Version:
Severity: Normal | Resolution:
Keywords: outreachy-ipv6 ipv6 prop312 | Actual Points:
Parent ID: | Points: 1
Reviewer: | Sponsor: Sponsor55-can
------------------------------------------+--------------------------------
Comment (by kimimaro):
Current code changes on commit afbf854ee1ef17622748ec4878e8929df8c9dc0c:
{{{
// includes added
#include "feature/relay/router.h"
/** Return true iff <b>addr</b> is judged to be on the same network as us,
or
* on a private network.
*/
MOCK_IMPL(int,
is_local_addr, (const tor_addr_t *addr))
{
/* Check for an internal IPv4 or IPv6 address */
if (tor_addr_is_internal(addr, 0))
return 1;
/* Check whether ip is on the same /24 as we are. */
if (get_options()->EnforceDistinctSubnets == 0)
return 0;
if (tor_addr_family(addr) == AF_INET) {
uint32_t ip = tor_addr_to_ipv4h(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.
*/
if ((last_resolved_addr & (uint32_t)0xffffff00ul)
== (ip & (uint32_t)0xffffff00ul))
return 1;
}
/* Check for the same IPv6 /48 as the directory server */
if (tor_addr_family(addr) == AF_INET6) {
if (router_get_my_routerinfo() &&
tor_addr_is_valid(router_get_my_routerinfo()->ipv6_addr, true)) {
return tor_addr_compare_masked(addr->addr,
router_get_my_routerinfo()->ipv6_addr, 48, CMP_EXACT);
}
}
return 0;
}
}}}
Here is the error I am getting:
{{{
tor ) make test-network
$CHUTNEY_PATH was not set.
Assuming test-network.sh will find ./../chutney
CC src/app/config/src_core_libtor_app_testing_a-config.o
src/app/config/config.c: In function ‘is_local_addr__real’:
src/app/config/config.c:3024:83: error: dereferencing pointer to
incomplete type ‘routerinfo_t {aka const struct routerinfo_t}’
_addr_is_valid(router_get_my_routerinfo()->ipv6_addr, true)) {
^~
src/app/config/config.c:3025:38: error: incompatible type for argument 1
of ‘tor_addr_compare_masked’
return tor_addr_compare_masked(addr->addr,
router_get_my_routerinfo()->ipv6_addr, 48, CMP_EXACT);
^~~~
In file included from ./src/core/or/or.h:53:0,
from src/app/config/config.c:65:
./src/lib/net/address.h:249:5: note: expected ‘const tor_addr_t * {aka
const struct tor_addr_t *}’ but argument is of type ‘const union
<anonymous>’
int tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t
*addr2,
^~~~~~~~~~~~~~~~~~~~~~~
Makefile:13398: recipe for target 'src/app/config
/src_core_libtor_app_testing_a-config.o' failed
make[1]: *** [src/app/config/src_core_libtor_app_testing_a-config.o] Error
1
Makefile:21570: recipe for target 'test-network' failed
make: *** [test-network] Error 2
}}}
Looks like the only declaration I have found for router_get_my_routerinfo
was this code in router.h:
{{{
MOCK_DECL(const routerinfo_t *, router_get_my_routerinfo, (void));
MOCK_DECL(const routerinfo_t *, router_get_my_routerinfo_with_err,(int
*err));
}}}
I'm not sure what to do next.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/33618#comment:5>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs