Commit Graph

9128 Commits

Author SHA1 Message Date
Nick Mathewson
a45760b53b Make very sure to handle cells in-order on channels.
Fix on code for 6465, not yet in any release.
2012-10-11 00:35:58 -04:00
Nick Mathewson
7ea904cbc0 Merge branch 'bug7011'
Conflicts:
	src/or/circuitbuild.c

The conflict was trivial, since no line of code actually changed in
both branches: There was a fmt_addr() that turned into fmt_addrport()
in bug7011, and a "if (!n_conn)" that turned into "if (!n_chan)" in
master.
2012-10-10 22:31:06 -04:00
David Fifield
8b3f3fb86e Use fmt_addrport in pt_get_extra_info_descriptor_string.
This patch is by asn.
https://trac.torproject.org/projects/tor/ticket/7011#comment:11
2012-10-10 22:25:30 -04:00
David Fifield
8419d18441 Use fmt_addrport where appropriate.
This is mostly a conversion from this pattern:
	log("... %s:%d ...", fmt_and_decorate_addr(&addr), port);
to this:
	log("... %s ...", fmt_addrport(&addr, port));

The output is the same in all cases.
2012-10-10 22:25:30 -04:00
David Fifield
4b0a039cb8 Use fmt_and_decorate_addr in extra-info "transport" lines.
Apparently BridgeDB is already expecting transport lines to be formatted
thus; see https://trac.torproject.org/projects/tor/ticket/7011#comment:12 ff.
It may be that there are no extant IPv6 pluggable transport bridges yet,
so this didn't cause a problem.
2012-10-10 22:25:29 -04:00
David Fifield
5cbf0f2106 Use fmt_and_decorate_addr in TransportProxy statefile entry.
state_transport_line_is_valid calls tor_addr_port_lookup, which expects
brackets around an IPv6 address. Without this, cached transport
addresses can't be parsed later:

[warn] state: Could not parse addrport.
[warn] state: State file seems to be broken.

See #7011.
2012-10-10 22:25:29 -04:00
David Fifield
41328c7009 Decorate addresses given to a HTTP CONNECT proxy.
This affects the Request-URI and the value of the Host header. RFC 2616
doesn't directly address the formatting of IPv6 addresses, but it
delegates some productions to RFC 2396 "Uniform Resource Identifiers
(URI): Generic Syntax," which is obsoleted by RFC 3986, which requires
square brackets for IPv6 addresses in both places.

I tested this with
	HTTPSProxy 127.0.0.1:8000
	Bridge <IPv6 bridge>
	UseBridges 1
and an Ncat HTTP proxy:
	ncat --proxy-type http -l 8000 -vvv

https://tools.ietf.org/html/rfc2616#section-3.2.1
https://tools.ietf.org/html/rfc2616#section-5.1.2
https://tools.ietf.org/html/rfc2616#section-14.23
https://tools.ietf.org/html/rfc3986#section-3.2.2
2012-10-10 22:25:29 -04:00
David Fifield
34c6ee7e9b Use fmt_and_decorate_addr in log messages. 2012-10-10 22:25:29 -04:00
Andrea Shepard
8b36d4cc2a Merge branch 'bug6816_squashed_nowarn' of git://git.torproject.org/nickm/tor 2012-10-10 18:53:38 -07:00
Nick Mathewson
bd28322d38 Remove variables; fix gcc 4.7 warnings
My GCC warns when variables are assigned to but never used.  There
were a few like that in the 6816/6465 branches.
2012-10-10 21:25:52 -04:00
Andrea Shepard
5543c5b202
Fix formatting in various places after 6465/6816 work 2012-10-10 00:48:36 -07:00
Andrea Shepard
217352c362 Make channel_flush_some_cells() compile cleanly on machines with ssize_t larger than int per sjumrdoch comment 2012-10-10 00:44:47 -07:00
Andrea Shepard
bec776480d Don't remove circuitmux hash table entries in circuitmux_detach_circuit() until after circuitmux_make_circuit_inactive() 2012-10-10 00:44:47 -07:00
Andrea Shepard
1bc9a040f7 Fix 'warning: circuit was already inactive' and assert in circuitmux_make_circuit_inactive() during circuitmux_detach_all_circuits() 2012-10-10 00:44:47 -07:00
Andrea Shepard
c9e48ded5d Bring summary comment block in circuitmux.c up to date 2012-10-10 00:44:47 -07:00
Andrea Shepard
49d534e524 New and improved circuitmux_detach_all_circuits(), now without the stupid 2012-10-10 00:44:47 -07:00
Andrea Shepard
c9607694c9 Correctly set magic numbers on ewma policy data/circuit data when allocating 2012-10-10 00:44:47 -07:00
Andrea Shepard
9d615cc5c0 Set circuitmux policy on existing active channels when ewma_enabled changes 2012-10-10 00:44:47 -07:00
Andrea Shepard
bb62281ba4 Set circuitmux policy on new channels in channeltls.c 2012-10-10 00:44:47 -07:00
Andrea Shepard
0c4f717b3e Implement cell_ewma_enabled() 2012-10-10 00:44:47 -07:00
Andrea Shepard
8afe41b481 Implement channel_set_cmux_policy_everywhere() 2012-10-10 00:44:46 -07:00
Andrea Shepard
13972aee78 Fix broken circuitmux_move_active_circ_to_tail(); don't assume n_chan is not NULL in circuitmux_detach_circuit() 2012-10-10 00:44:46 -07:00
Andrea Shepard
903cc8acd1 Allow n_chan to be NULL in circuitmux_find_map_entry(); it can be but with non-NULL p_chan when extending a circuit 2012-10-10 00:44:46 -07:00
Andrea Shepard
a0200c1f6e Use circuit_get_by_circid_channel_even_if_marked() and fix some asserts in circuitmux.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
1498a6e84a Fix some circuitmux-related asserts in relay.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
b28119e6a8 Fix detach when setting circuit ID to 0 bug in circuit_set_circid_chan_helper() and add circuit_get_by_circid_channel_even_if_marked() 2012-10-10 00:44:46 -07:00
Andrea Shepard
c097fb33fc Detach circuits from circuitmux early when freeing channel so they can find the channel by ID 2012-10-10 00:44:46 -07:00
Andrea Shepard
3d092ffbdd Handle closing circuits correctly with circuitmux_t 2012-10-10 00:44:46 -07:00
Andrea Shepard
6830c9c232 Add a bunch of paranoid-mode expensive asserts incircuitmux.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
7598e669e8 Adjust the circuitmux_t counter correctly in circuitmux_notify_xmit_cells() 2012-10-10 00:44:46 -07:00
Andrea Shepard
96a6eff8fe Fix circuitmux attach/detach logic in circuit_set_circid_chan_helper(); it's possible for id to be zero (not assigned yet) and shouldn't be attached then 2012-10-10 00:44:46 -07:00
Andrea Shepard
60ec46a2ec Update circuitmux-related TODOs in channeltls.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
2565710fd7 Fix comment on circuit_t.n_hop and remove circuitmux TODO in or.h 2012-10-10 00:44:46 -07:00
Andrea Shepard
bbb2c31d26 Move all EWMA code into circuitmux.c and implement circuitmux_policy_t methods using it 2012-10-10 00:44:46 -07:00
Andrea Shepard
0af2eab9a2 Add circuitmux.h, circuitmux_ewma.h includes now necessary in networkstatus.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
d194b8602a Remove cell_ewma_t from or.h and from circuit_t/or_circuit_t; all that goes to the new circuitmux_ewma.c now 2012-10-10 00:44:46 -07:00
Andrea Shepard
5f9d37e74e Add circuitmux.h, circuitmux_ewma.h includes now necessary in config.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
14fe0d5859 Remove EWMA code from relay.{c,h}; it goes to a circuitmux policy now 2012-10-10 00:44:46 -07:00
Andrea Shepard
b7d5784c54 Remove ewma setup code in init_circuit_base()/or_circuit_new() of circuitlist.c; it gets allocated when the circuit is attached to a circuitmux_t with that policy now 2012-10-10 00:44:46 -07:00
Andrea Shepard
e1de2f1437 Add upcasts for circuitmux_policy_data_t and circuitmux_policy_circ_data_t to circuitmux.h 2012-10-10 00:44:46 -07:00
Andrea Shepard
184560c4f6 Add initial circuitmux_ewma.{c,h} 2012-10-10 00:44:46 -07:00
Andrea Shepard
34591c61ef Implement circuitmux_assert_okay() and helper functions in circuitmux.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
4a14c6aa67 Implement circuitmux_get_first_active_circuit() in circuitmux.c; add pick_active_circuit() to circuitmux_policy_t in circuitmux.h 2012-10-10 00:44:46 -07:00
Andrea Shepard
c4e5e4727d Add comment for circuitmux_notify_xmit_cells() in circuitmux.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
741bc97b24 Add comment for circuitmux_move_active_circ_to_tail() in circuitmux.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
aff77eb1a9 Implement circuitmux_notify_xmit_cells() and circuitmux_move_active_circ_to_tail() helper in circuitmux.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
debef8f0cd Consistently allow policy alloc_cmux_data() and alloc_circ_data() functions to return NULL if the policy does not use this in circuitmux.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
86d9d85dfc Implement circuitmux_clear_policy(), circuitmux_get_policy() and circuitmux_set_policy() in circuitmux.c 2012-10-10 00:44:45 -07:00
Andrea Shepard
eade7a37cd Add cmux policy notify_set_n_cells() and notify_xmit_cells() callbacks 2012-10-10 00:44:45 -07:00
Andrea Shepard
930e3d611a Allocate and free circuit-specific policy data in the right places 2012-10-10 00:44:45 -07:00
Andrea Shepard
851734d324 Implement circuitmux policy basic notifications mechanism 2012-10-10 00:44:45 -07:00
Andrea Shepard
35f5259df4 Eliminate linked list helper functions in relay.c which are no longer used 2012-10-10 00:44:45 -07:00
Andrea Shepard
38fa3b7e44 Implement circuitmux_make_circuit_inactive(), circuitmux_make_circuit_active() and linked list helper functions in circuitmux.c 2012-10-10 00:44:45 -07:00
Andrea Shepard
fd31dd440c Implement circuitmux_detach_all_circuits() in circuitmux.c 2012-10-10 00:43:18 -07:00
Andrea Shepard
9da04141e2 Implement circuitmux_is_circuit_active(), circuitmux_num_cells_for_circuit(), circuitmux_num_cells(), circuitmux_num_active_circuits() and circuitmux_num_circuits() in circuitmux.c 2012-10-10 00:43:18 -07:00
Andrea Shepard
a9deec3550 Implement circuitmux_clear_num_cells() and circuitmux_set_num_cells() in circuitmux.c, remove unneeded circuitmux_add_to_num_cells() from circuitmux.h 2012-10-10 00:43:18 -07:00
Andrea Shepard
8004448635 Handle n_mux/p_mux properly in circuitmux.c 2012-10-10 00:43:18 -07:00
Andrea Shepard
c3ebd0340c Implement circuitmux_detach_circuit() in circuitmux.c 2012-10-10 00:43:17 -07:00
Andrea Shepard
7e5c358d38 Implement circuitmux_attached_circuit_direction(), circuitmux_find_map_entry() and circuitmux_is_circuit_attached() in circuitmux.c 2012-10-10 00:41:55 -07:00
Andrea Shepard
3c41d7f414 Implement circuitmux_attach_circuit() in circuitmux.c 2012-10-10 00:41:49 -07:00
Andrea Shepard
e4a11b890e Implement circuitmux_alloc()/circuitmux_free() and chanid/circid->muxinfo hash table 2012-10-10 00:40:10 -07:00
Andrea Shepard
b208539b80 Use circuitmux_t in channels and when relaying cells 2012-10-10 00:40:06 -07:00
Andrea Shepard
c684076fc7 Add circuitmux.c, circuitmux.h 2012-10-10 00:39:11 -07:00
Andrea Shepard
bddfb9ffa8 Add magic number for type-checking channel casts 2012-10-09 23:19:53 -07:00
Andrea Shepard
f00b44ef8c Improve comments on channel_write_*() 2012-10-09 23:19:53 -07:00
Andrea Shepard
1c3362dcdc Use cell_queue_entry_new/free() functions in channel.c 2012-10-09 23:19:53 -07:00
Andrea Shepard
53454fad95 Set reason_for_closing when erroring out of channel_tls_connect() 2012-10-09 23:19:53 -07:00
Andrea Shepard
3f4b95b1a3 Split channel_t into channel_t and channel_listener_t; get rid of that big union 2012-10-09 23:19:53 -07:00
George Kadianakis
634d24c588 Don't call fmt_addr() twice in a parameter list. 2012-10-09 23:49:56 -04:00
George Kadianakis
721f99e495 Don't call fmt_addr() twice in a parameter list. 2012-10-09 23:46:04 -04:00
Andrea Shepard
6391f963fb
Conform to existing Doxygen style 2012-10-08 21:30:07 -07:00
Andrea Shepard
06a76d1db4
Refactor channel_write_cell()/channel_write_packed_cell()/channel_write_var_cell() to eliminate redundant code 2012-10-08 21:16:59 -07:00
Andrea Shepard
89a00ee63a
Use typedefs for function pointer return values and s/listener/listener_fn/ for distinctness 2012-10-08 20:49:19 -07:00
Andrea Shepard
ee4e88e4d9
s/cell_queue/incoming_queue/g in channel.c for consistency with outgoing_queue 2012-10-08 20:20:28 -07:00
Andrea Shepard
4686638743
Fix typo in comment 2012-10-08 20:15:09 -07:00
Andrea Shepard
d61e58e1ba
s/channel_request_close()/channel_mark_for_close()/g for consistency 2012-10-08 20:14:04 -07:00
Andrea Shepard
8a41dd20cb
Make channel_force_free() static 2012-10-08 20:10:13 -07:00
Andrea Shepard
123a08e4a3
Simplify channel_next_with_digest() in channel.c 2012-10-08 20:08:18 -07:00
Andrea Shepard
e877d02fdd
Eliminate unnecessary channel_set_cell_handler(), channel_set_var_cell_handler() in channel.c 2012-10-08 20:06:40 -07:00
Andrea Shepard
17356fe7fd
Eliminate unnecessary SMARTLIST_DEL_CURRENT() invocations in channel.c, channeltls.c 2012-10-08 20:02:42 -07:00
Andrea Shepard
bb92a2d7a8
Remove orphaned comment in channel_flush_some_cells_from_outgoing_queue() 2012-10-08 19:54:47 -07:00
Andrea Shepard
341928c807
Simplify channel_find_by_remote_digest() 2012-10-08 19:53:05 -07:00
Andrea Shepard
965c9de498
Abolish superfluous channel_find_by_remote_nickname() 2012-10-08 19:52:04 -07:00
Andrea Shepard
64e6f6687c
channel_free() should be a no-op 2012-10-08 19:50:41 -07:00
Andrea Shepard
e709fe320a Use U64_FORMAT/U64_PRINTF_ARG rather than %lu for channel_t 2012-10-08 19:48:06 -07:00
Andrea Shepard
71ba517e0c
Check return value from connection_or_connect() in channel_tls_connect()
It's possible for connection_or_connect() to fail and return NULL after it
sets tlschan->conn, so not checking leaves a channel hanging around in
CHANNEL_STATE_OPENING with a pointer to a freed or_connection_t forever.
2012-10-08 18:24:04 -07:00
Andrea Shepard
7138a4adac Keep better statistics about channels and dump them from dumpstats() on SIGUSR1 2012-10-08 03:06:09 -07:00
Andrea Shepard
a9a75ee59a Call channel_tls_free_all() and channel_free_all() from tor_free_all in main.c 2012-10-08 03:06:09 -07:00
Andrea Shepard
72251385b0 Call connection_or_close_normally() rather than using connection_mark_for_close()/connection_mark_and_flush() in run_connection_housekeeping() of main.c so that channels get sent to the CLOSING state correctly (avoids an assert otherwise) 2012-10-08 03:06:09 -07:00
Andrea Shepard
07f9e8fc7d Call channel_run_cleanup() in main.c, and include a comment explaining how closing or_connections related to channels 2012-10-08 03:06:09 -07:00
Andrea Shepard
cb62a0b69a Use channel_is_bad_for_new_circs(), connection_or_get_num_circs() in main.c 2012-10-08 03:06:09 -07:00
Andrea Shepard
9ad7ba9f22 Use connection_or_get_num_circuits() in control.c 2012-10-08 03:06:09 -07:00
Andrea Shepard
f0f87cb68a Convert rendmid.c to channel_t 2012-10-08 03:06:09 -07:00
Andrea Shepard
28f108bcce Use dirreq_id from channel_t when appropriate 2012-10-08 03:06:09 -07:00
Andrea Shepard
8b14db9628 Switch onion.c over to channel_t 2012-10-08 03:06:09 -07:00
Andrea Shepard
77dac97354 Use channel_t in cpuworker.c
Note: this is a squashed commit; see branch bug6465_rebased_v2 of user/andrea/tor.git for full history of the following 2 commits:

Use channel_t in cpuworker.c
Fix bug in channel_t usage in cpuworker.c that was killing relaying on channel_t-ized Tor.  The tags passed to the worker now have a channel ID, not a connection ID.
2012-10-08 03:06:09 -07:00
Andrea Shepard
6cce6241dd Query circuit count from associated channel of or_conn in control.c 2012-10-08 03:06:09 -07:00
Andrea Shepard
35924435d2 Make reachabiity test in dirserv.c use channel_t 2012-10-08 03:06:07 -07:00
Andrea Shepard
e136f7ccb4 Convert relay.c/relay.h to channel_t
Note: this is a squashed commit; see branch bug6465_rebased_v2 of user/andrea/tor.git for full history of the following 10 commits:

Convert relay.c/relay.h to channel_t
Updating the timestamp if n_flushed > 0 at the end of channel_flush_from_first_active_circuit() was redundant since channel_write_cell() et al. do it themselves.
Get rid of now-unnecessary time parameter in channel_flush_from_first_active_circuit()
Get rid of now-unnecessary time parameter in channel_flush_from_first_active_circuit() in connection_or.c
Add non-inlined external call for channeltls.c to free a packed_cell_t
Appease make check-spaces in relay.c
Replace channel_get_write_queue_len() with sufficient and easier to implement channel_has_queued_writes() in relay.c
Rename channel_touched_by_client() and client_used field for consistency with other timestamps in relay.c
Don't double-free packed cells in relay.c (channel_t Tor now bootstraps and works as a client)
Rearrange channel_t struct to use a union distinguishing listener from cell-bearing channels in relay.c
2012-10-08 03:05:26 -07:00
Andrea Shepard
4768c0efe3 Support channel_t in connection_edge.c 2012-10-08 03:05:00 -07:00