@@ -74,18 +74,14 @@ static void connection_wake(qd_connection_t *ctx)
74
74
}
75
75
76
76
77
- static void decorate_connection (qd_connection_t * ctx , const qd_server_config_t * config )
77
+ /** Setup connection capabilities and properties.
78
+ * These are communicated to the peer via the Open performative.
79
+ */
80
+ static void decorate_connection (qd_connection_t * ctx )
78
81
{
79
- qd_server_t * qd_server = ctx -> server ;
80
- pn_connection_t * conn = ctx -> pn_conn ;
81
- //
82
- // Set the container name
83
- //
84
- pn_connection_set_container (conn , qd_server_get_container_name (qd_server ));
82
+ pn_connection_t * conn = ctx -> pn_conn ;
83
+ const qd_server_config_t * config = qd_connection_config (ctx );
85
84
86
- //
87
- // Advertise our container capabilities.
88
- //
89
85
{
90
86
// offered: extension capabilities this router supports
91
87
pn_data_t * ocaps = pn_connection_offered_capabilities (conn );
@@ -151,10 +147,17 @@ static void decorate_connection(qd_connection_t *ctx, const qd_server_config_t *
151
147
}
152
148
153
149
if (ctx -> connector && (ctx -> connector -> is_data_connector || !!ctx -> connector -> ctor_config -> data_connection_count )) {
150
+ uint64_t tls_ordinal ;
154
151
pn_data_put_symbol (pn_connection_properties (conn ),
155
152
pn_bytes (strlen (QD_CONNECTION_PROPERTY_GROUP_CORRELATOR_KEY ), QD_CONNECTION_PROPERTY_GROUP_CORRELATOR_KEY ));
156
153
pn_data_put_string (pn_connection_properties (conn ),
157
154
pn_bytes (strnlen (ctx -> group_correlator , QD_DISCRIMINATOR_SIZE - 1 ), ctx -> group_correlator ));
155
+
156
+ if (qd_connection_get_tls_ordinal (qd_conn , & tls_ordinal )) {
157
+ pn_data_put_symbol (pn_connection_properties (conn ),
158
+ pn_bytes (strlen (QD_CONNECTION_PROPERTY_TLS_ORDINAL ), QD_CONNECTION_PROPERTY_TLS_ORDINAL ));
159
+ pn_data_put_ulong (pn_connection_properties (conn ), tls_ordinal );
160
+ }
158
161
}
159
162
160
163
if (ctx -> listener && !!ctx -> listener -> vflow_record ) {
@@ -246,6 +249,8 @@ void qd_connection_init(qd_connection_t *ctx, qd_server_t *server, const qd_serv
246
249
{
247
250
ctx -> pn_conn = pn_connection ();
248
251
assert (ctx -> pn_conn );
252
+
253
+ pn_connection_set_container (ctx -> pn_conn , qd_server_get_container_name (server ));
249
254
sys_mutex_init (& ctx -> deferred_call_lock );
250
255
ctx -> role = qd_strdup (config -> role );
251
256
ctx -> server = server ;
@@ -262,18 +267,13 @@ void qd_connection_init(qd_connection_t *ctx, qd_server_t *server, const qd_serv
262
267
DEQ_INIT (ctx -> free_link_list );
263
268
DEQ_INIT (ctx -> child_sessions );
264
269
265
- // note: setup connector or listener before decorating the connection since
266
- // decoration involves accessing the connection's parent.
267
-
268
270
if (!!connector ) {
269
271
assert (!listener );
270
272
qd_connector_add_connection (connector , ctx );
271
273
} else if (!!listener ) {
272
274
qd_listener_add_connection (listener , ctx );
273
275
}
274
276
275
- decorate_connection (ctx , config );
276
-
277
277
sys_mutex_lock (& amqp_adaptor .lock );
278
278
DEQ_INSERT_TAIL (amqp_adaptor .conn_list , ctx );
279
279
sys_mutex_unlock (& amqp_adaptor .lock );
@@ -619,13 +619,15 @@ static bool setup_ssl_sasl_and_open(qd_connection_t *ctx)
619
619
pn_sasl_allowed_mechs (sasl , config -> sasl_mechanisms );
620
620
pn_sasl_set_allow_insecure_mechs (sasl , config -> allowInsecureAuthentication );
621
621
622
+ decorate_connection (ctx );
622
623
pn_connection_open (ctx -> pn_conn );
623
624
return true;
624
625
}
625
626
626
627
627
628
/* Configure the transport once it is bound to the connection */
628
- static void on_connection_bound (qd_server_t * server , pn_event_t * e ) {
629
+ static void on_connection_bound (qd_server_t * server , pn_event_t * e )
630
+ {
629
631
pn_connection_t * pn_conn = pn_event_connection (e );
630
632
qd_connection_t * ctx = pn_connection_get_context (pn_conn );
631
633
pn_transport_t * tport = pn_connection_transport (pn_conn );
@@ -643,9 +645,21 @@ static void on_connection_bound(qd_server_t *server, pn_event_t *e) {
643
645
pn_transport_set_tracer (tport , transport_tracer );
644
646
}
645
647
646
- const qd_server_config_t * config = NULL ;
648
+ const qd_server_config_t * config = qd_connection_config (ctx );
649
+ assert (config );
650
+
651
+ //
652
+ // Common transport configuration.
653
+ //
654
+ pn_transport_set_max_frame (tport , config -> max_frame_size );
655
+ pn_transport_set_idle_timeout (tport , config -> idle_timeout_seconds * 1000 );
656
+ // pn_transport_set_channel_max sets the maximum session *identifier*, not the total number of sessions. Thus Proton
657
+ // will allow sessions with identifiers [0..max_sessions], which is one greater than the value we pass to
658
+ // pn_transport_set_channel_max. So to limit the maximum number of simultaineous sessions to config->max_sessions we
659
+ // have to decrement it by one for Proton.
660
+ pn_transport_set_channel_max (tport , config -> max_sessions - 1 );
661
+
647
662
if (ctx -> listener ) { /* Accepting an incoming connection */
648
- config = & ctx -> listener -> config ;
649
663
const char * name = config -> host_port ;
650
664
pn_transport_set_server (tport );
651
665
set_rhost_port (ctx );
@@ -676,13 +690,14 @@ static void on_connection_bound(qd_server_t *server, pn_event_t *e) {
676
690
pn_transport_require_auth (tport , config -> requireAuthentication );
677
691
pn_transport_require_encryption (tport , config -> requireEncryption );
678
692
pn_sasl_set_allow_insecure_mechs (sasl , config -> allowInsecureAuthentication );
693
+ decorate_connection (ctx );
679
694
680
695
// This log statement is kept at INFO level because this shows the inter-router
681
696
// connections and that is useful when debugging router issues.
682
697
qd_log (LOG_SERVER , QD_LOG_INFO , "[C%" PRIu64 "] Accepted connection to %s from %s" ,
683
698
ctx -> connection_id , name , ctx -> rhost_port );
699
+
684
700
} else if (ctx -> connector ) { /* Establishing an outgoing connection */
685
- config = & ctx -> connector -> ctor_config -> config ;
686
701
if (!setup_ssl_sasl_and_open (ctx )) {
687
702
qd_log (LOG_SERVER , QD_LOG_ERROR , "[C%" PRIu64 "] Connection aborted due to internal setup error" ,
688
703
ctx -> connection_id );
@@ -695,17 +710,6 @@ static void on_connection_bound(qd_server_t *server, pn_event_t *e) {
695
710
connect_fail (ctx , QD_AMQP_COND_INTERNAL_ERROR , "unknown Connection" );
696
711
return ;
697
712
}
698
-
699
- //
700
- // Common transport configuration.
701
- //
702
- pn_transport_set_max_frame (tport , config -> max_frame_size );
703
- pn_transport_set_idle_timeout (tport , config -> idle_timeout_seconds * 1000 );
704
- // pn_transport_set_channel_max sets the maximum session *identifier*, not the total number of sessions. Thus Proton
705
- // will allow sessions with identifiers [0..max_sessions], which is one greater than the value we pass to
706
- // pn_transport_set_channel_max. So to limit the maximum number of simultaineous sessions to config->max_sessions we
707
- // have to decrement it by one for Proton.
708
- pn_transport_set_channel_max (tport , config -> max_sessions - 1 );
709
713
}
710
714
711
715
void qd_container_handle_event (qd_container_t * container , pn_event_t * event , pn_connection_t * pn_conn , qd_connection_t * qd_conn );
@@ -848,3 +852,14 @@ void qd_amqp_connection_set_tracing(bool enable_tracing)
848
852
sys_mutex_unlock (& amqp_adaptor .lock );
849
853
}
850
854
}
855
+
856
+
857
+ bool qd_connection_get_tls_ordinal (const qd_connection_t * qd_conn , uint64_t * tls_ordinal )
858
+ {
859
+ if (qd_conn -> ssl ) {
860
+ * tls_ordinal = qd_tls_session_get_profile_ordinal (qd_conn -> ssl );
861
+ return true;
862
+ }
863
+ * tls_ordinal = 0 ;
864
+ return false;
865
+ }
0 commit comments