diff options
-rw-r--r-- | changes/ticket32190 | 4 | ||||
-rw-r--r-- | src/core/or/connection_edge.c | 16 | ||||
-rw-r--r-- | src/core/or/connection_edge.h | 2 | ||||
-rw-r--r-- | src/feature/control/control_cmd.c | 3 | ||||
-rw-r--r-- | src/feature/control/control_events.c | 2 | ||||
-rw-r--r-- | src/feature/control/control_events.h | 8 |
6 files changed, 27 insertions, 8 deletions
diff --git a/changes/ticket32190 b/changes/ticket32190 new file mode 100644 index 0000000000..a34fd51c60 --- /dev/null +++ b/changes/ticket32190 @@ -0,0 +1,4 @@ + o Minor features (control port): + - When a stream enters the AP_CONN_STATE_CONTROLLER_WAIT status, + send a control port event CONTROLLER_WAIT. Closes ticket 32190. + Patch by Neel Chauhan. diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c index ed27fb1b57..25337f0720 100644 --- a/src/core/or/connection_edge.c +++ b/src/core/or/connection_edge.c @@ -1553,6 +1553,16 @@ circuit_discard_optional_exit_enclaves(extend_info_t *info) } SMARTLIST_FOREACH_END(conn); } +/** Set the connection state to CONTROLLER_WAIT and send an control port event. + */ +void +connection_entry_set_controller_wait(entry_connection_t *conn) +{ + CONNECTION_AP_EXPECT_NONPENDING(conn); + ENTRY_TO_CONN(conn)->state = AP_CONN_STATE_CONTROLLER_WAIT; + control_event_stream_status(conn, STREAM_EVENT_CONTROLLER_WAIT, 0); +} + /** The AP connection <b>conn</b> has just failed while attaching or * sending a BEGIN or resolving on <b>circ</b>, but another circuit * might work. Detach the circuit, and either reattach it, launch a @@ -1584,8 +1594,7 @@ connection_ap_detach_retriable(entry_connection_t *conn, circuit_detach_stream(TO_CIRCUIT(circ),ENTRY_TO_EDGE_CONN(conn)); connection_ap_mark_as_pending_circuit(conn); } else { - CONNECTION_AP_EXPECT_NONPENDING(conn); - ENTRY_TO_CONN(conn)->state = AP_CONN_STATE_CONTROLLER_WAIT; + connection_entry_set_controller_wait(conn); circuit_detach_stream(TO_CIRCUIT(circ),ENTRY_TO_EDGE_CONN(conn)); } return 0; @@ -1738,8 +1747,7 @@ connection_ap_rewrite_and_attach_if_allowed,(entry_connection_t *conn, const or_options_t *options = get_options(); if (options->LeaveStreamsUnattached) { - CONNECTION_AP_EXPECT_NONPENDING(conn); - ENTRY_TO_CONN(conn)->state = AP_CONN_STATE_CONTROLLER_WAIT; + connection_entry_set_controller_wait(conn); return 0; } return connection_ap_handshake_rewrite_and_attach(conn, circ, cpath); diff --git a/src/core/or/connection_edge.h b/src/core/or/connection_edge.h index 9b2cbb8532..c9433adade 100644 --- a/src/core/or/connection_edge.h +++ b/src/core/or/connection_edge.h @@ -98,6 +98,8 @@ int connection_edge_flushed_some(edge_connection_t *conn); int connection_edge_finished_flushing(edge_connection_t *conn); int connection_edge_finished_connecting(edge_connection_t *conn); +void connection_entry_set_controller_wait(entry_connection_t *conn); + void connection_ap_about_to_close(entry_connection_t *edge_conn); void connection_exit_about_to_close(edge_connection_t *edge_conn); diff --git a/src/feature/control/control_cmd.c b/src/feature/control/control_cmd.c index 301a4872b6..5b75c24692 100644 --- a/src/feature/control/control_cmd.c +++ b/src/feature/control/control_cmd.c @@ -981,8 +981,7 @@ handle_control_attachstream(control_connection_t *conn, edge_conn->end_reason = 0; if (tmpcirc) circuit_detach_stream(tmpcirc, edge_conn); - CONNECTION_AP_EXPECT_NONPENDING(ap_conn); - TO_CONN(edge_conn)->state = AP_CONN_STATE_CONTROLLER_WAIT; + connection_entry_set_controller_wait(ap_conn); } if (circ && (circ->base_.state != CIRCUIT_STATE_OPEN)) { diff --git a/src/feature/control/control_events.c b/src/feature/control/control_events.c index 8e69c772f6..f97130d020 100644 --- a/src/feature/control/control_events.c +++ b/src/feature/control/control_events.c @@ -109,6 +109,7 @@ const struct control_event_t control_event_table[] = { { EVENT_HS_DESC, "HS_DESC" }, { EVENT_HS_DESC_CONTENT, "HS_DESC_CONTENT" }, { EVENT_NETWORK_LIVENESS, "NETWORK_LIVENESS" }, + { EVENT_CONTROLLER_WAIT, "CONTROLLER_WAIT" }, { 0, NULL }, }; @@ -818,6 +819,7 @@ control_event_stream_status(entry_connection_t *conn, stream_status_event_t tp, case STREAM_EVENT_NEW_RESOLVE: status = "NEWRESOLVE"; break; case STREAM_EVENT_FAILED_RETRIABLE: status = "DETACHED"; break; case STREAM_EVENT_REMAP: status = "REMAP"; break; + case STREAM_EVENT_CONTROLLER_WAIT: status = "CONTROLLER_WAIT"; break; default: log_warn(LD_BUG, "Unrecognized status code %d", (int)tp); return 0; diff --git a/src/feature/control/control_events.h b/src/feature/control/control_events.h index 0c8448e0f8..82c665ac71 100644 --- a/src/feature/control/control_events.h +++ b/src/feature/control/control_events.h @@ -36,7 +36,8 @@ typedef enum stream_status_event_t { STREAM_EVENT_NEW = 5, STREAM_EVENT_NEW_RESOLVE = 6, STREAM_EVENT_FAILED_RETRIABLE = 7, - STREAM_EVENT_REMAP = 8 + STREAM_EVENT_REMAP = 8, + STREAM_EVENT_CONTROLLER_WAIT = 9 } stream_status_event_t; /** Used to indicate the type of a buildtime event */ @@ -226,6 +227,8 @@ void control_event_hs_descriptor_content(const char *onion_address, void cbt_control_event_buildtimeout_set(const circuit_build_times_t *cbt, buildtimeout_set_event_t type); +int control_event_enter_controller_wait(void); + void control_events_free_all(void); #ifdef CONTROL_MODULE_PRIVATE @@ -284,7 +287,8 @@ typedef uint64_t event_mask_t; #define EVENT_NETWORK_LIVENESS 0x0023 #define EVENT_PT_LOG 0x0024 #define EVENT_PT_STATUS 0x0025 -#define EVENT_MAX_ 0x0025 +#define EVENT_CONTROLLER_WAIT 0x0026 +#define EVENT_MAX_ 0x0026 /* sizeof(control_connection_t.event_mask) in bits, currently a uint64_t */ #define EVENT_CAPACITY_ 0x0040 |