My patch #8203 (moved) tried to be clever and copied the IP and port of the control connection into the SOURCE field of STREAM_EVENT_NEW_RESOLVE events. As it turns out, the control connection address can be a unix domain socket, which tor_dup_addr helpfully converts to "".
Previously "(Tor_internal):0" was used, even though it also did not follow the control spec, but the controllers seemed to handle it fine.
My suggestion: If the control connection is via a unix domain socket, use "(Tor_internal)" again. And while we are at it, add (Tor_internal) to the control spec as well.
Trac: Username: Desoxy
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
Hi Desoxy. "(Tor_internal)" is certainly far better than "" (spaces would be a problem), but what about simply omitting the SOURCE field when it's a unix domain socket? It is an optional field, after all.
Removing the SOURCE_ADDR field should work too. We would obviously have to adapt the control spec to mark the field as optional. Do we want to omit the SOURCE_ADDR field for all controller-generated stream events or just when the control connection is via an unix domain socket?
Removing the SOURCE_ADDR field should work too. We would obviously have to adapt the control spec to mark the field as optional.
Actually, it already is (that's what the '[]' means). At least I'm pretty sure that's the case, I don't recall where in the spec it says that - might be good to wait for Nick to confirm. :)
Observation: when we have an AF_UNIX control connection, the address field is the path to the socket before dnsserv_launch_request() does anything to it; do we still want to make this change to "(Tor_internal)" or leave it as the socket path?
I think above we said that the one we wanted to do was the version where we omit the SOURCE address when we don't have one, rather than having it be "(Tor_internal)". desoxy above already had a patch that did that.
Oh hang on; I'd worry that stuff will crash if there are connections with address == NULL flying around the code. Look for ->address in connection.c for example, and consider all the places we use it without checking for whether it's NULL.
What if we took the first version of your patch, and added the control.c changes from the second version, but checked for !strcmp(..,"(Tor_internal)") instead of NULL?
Oh hang on; I'd worry that stuff will crash if there are connections with address == NULL flying around the code. Look for ->address in connection.c for example, and consider all the places we use it without checking for whether it's NULL.
What if we took the first version of your patch, and added the control.c changes from the second version, but checked for !strcmp(..,"(Tor_internal)") instead of NULL?
Ouch, the string form is that widely used? Okay, that would work; how would you feel about an empty string instead for the sake of memory savings?
Ick, it can't be just a string constant because if it isn't NULL something will surely try to free it. Allocating a string per connection just to flag "this is from an AF_UNIX control connection" seems really gross. :(
Either approach is fine with me, though I doubt it's much memory in total. There aren't many AF_UNIX connections in total, and everythin else does have the connection_t.address field set.
If you like, we can open up another ticket with the name "remove connection_t.address" in 0.2.5.x; that would save a few bytes per connection or so.
If you like, we can open up another ticket with the name "remove connection_t.address" in 0.2.5.x; that would save a few bytes per connection or so.
It turns out we already have that ticket as #5528 (moved).
Turns out ticket #5528 (moved) refers to routerinfo_t->address, not connection_t. Doing this for connection_t would be a bit more effort, I think; for routerinfo_t it's problematic for reasons I will describe on #5528 (moved).
Either approach is fine with me, though I doubt it's much memory in total. There aren't many AF_UNIX connections in total, and everythin else does have the connection_t.address field set.
If you like, we can open up another ticket with the name "remove connection_t.address" in 0.2.5.x; that would save a few bytes per connection or so.
I have a new version that keeps "(Tor_internal)" and tests for it in control.c up in my bug8639_v3 branch.