The "ctp" refers to "client transport parameters", but in the code that
supports both client and server, the name is confusing, thus rename.


 src/event/quic/ngx_event_quic.c                |  41 +++++++++++++------------
 src/event/quic/ngx_event_quic_ack.c            |   8 ++--
 src/event/quic/ngx_event_quic_connection.h     |   5 +-
 src/event/quic/ngx_event_quic_connid.c         |   4 +-
 src/event/quic/ngx_event_quic_migration.c      |   7 ++-
 src/event/quic/ngx_event_quic_openssl_compat.c |  11 +++---
 src/event/quic/ngx_event_quic_ssl.c            |   9 +++--
 src/event/quic/ngx_event_quic_streams.c        |   9 +++--
 8 files changed, 51 insertions(+), 43 deletions(-)


# HG changeset patch
# User Vladimir Khomutov <v...@wbsrv.ru>
# Date 1703080262 -10800
#      Wed Dec 20 16:51:02 2023 +0300
# Node ID f30bd37ac6b6b2f051883d0173942794ea73d8fb
# Parent  5ea917e44e03e88a2b6bc935510839a5a14e5dae
QUIC: renamed "ctp" to "peer_tp".

The "ctp" refers to "client transport parameters", but in the code that
supports both client and server, the name is confusing, thus rename.

diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c
--- a/src/event/quic/ngx_event_quic.c
+++ b/src/event/quic/ngx_event_quic.c
@@ -1,5 +1,6 @@
 
 /*
+ * Copyright (C) 2023 Web Server LLC
  * Copyright (C) Nginx, Inc.
  */
 
@@ -122,7 +123,7 @@ ngx_quic_connstate_dbg(ngx_connection_t 
 
 
 ngx_int_t
-ngx_quic_apply_transport_params(ngx_connection_t *c, ngx_quic_tp_t *ctp)
+ngx_quic_apply_transport_params(ngx_connection_t *c, ngx_quic_tp_t *peer_tp)
 {
     ngx_str_t               scid;
     ngx_quic_connection_t  *qc;
@@ -132,16 +133,16 @@ ngx_quic_apply_transport_params(ngx_conn
     scid.data = qc->path->cid->id;
     scid.len = qc->path->cid->len;
 
-    if (scid.len != ctp->initial_scid.len
-        || ngx_memcmp(scid.data, ctp->initial_scid.data, scid.len) != 0)
+    if (scid.len != peer_tp->initial_scid.len
+        || ngx_memcmp(scid.data, peer_tp->initial_scid.data, scid.len) != 0)
     {
         ngx_log_error(NGX_LOG_INFO, c->log, 0,
                       "quic client initial_source_connection_id mismatch");
         return NGX_ERROR;
     }
 
-    if (ctp->max_udp_payload_size < NGX_QUIC_MIN_INITIAL_SIZE
-        || ctp->max_udp_payload_size > NGX_QUIC_MAX_UDP_PAYLOAD_SIZE)
+    if (peer_tp->max_udp_payload_size < NGX_QUIC_MIN_INITIAL_SIZE
+        || peer_tp->max_udp_payload_size > NGX_QUIC_MAX_UDP_PAYLOAD_SIZE)
     {
         qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR;
         qc->error_reason = "invalid maximum packet size";
@@ -151,7 +152,7 @@ ngx_quic_apply_transport_params(ngx_conn
         return NGX_ERROR;
     }
 
-    if (ctp->active_connection_id_limit < 2) {
+    if (peer_tp->active_connection_id_limit < 2) {
         qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR;
         qc->error_reason = "invalid active_connection_id_limit";
 
@@ -160,7 +161,7 @@ ngx_quic_apply_transport_params(ngx_conn
         return NGX_ERROR;
     }
 
-    if (ctp->ack_delay_exponent > 20) {
+    if (peer_tp->ack_delay_exponent > 20) {
         qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR;
         qc->error_reason = "invalid ack_delay_exponent";
 
@@ -169,7 +170,7 @@ ngx_quic_apply_transport_params(ngx_conn
         return NGX_ERROR;
     }
 
-    if (ctp->max_ack_delay >= 16384) {
+    if (peer_tp->max_ack_delay >= 16384) {
         qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR;
         qc->error_reason = "invalid max_ack_delay";
 
@@ -178,16 +179,16 @@ ngx_quic_apply_transport_params(ngx_conn
         return NGX_ERROR;
     }
 
-    if (ctp->max_idle_timeout > 0
-        && ctp->max_idle_timeout < qc->tp.max_idle_timeout)
+    if (peer_tp->max_idle_timeout > 0
+        && peer_tp->max_idle_timeout < qc->tp.max_idle_timeout)
     {
-        qc->tp.max_idle_timeout = ctp->max_idle_timeout;
+        qc->tp.max_idle_timeout = peer_tp->max_idle_timeout;
     }
 
-    qc->streams.server_max_streams_bidi = ctp->initial_max_streams_bidi;
-    qc->streams.server_max_streams_uni = ctp->initial_max_streams_uni;
+    qc->streams.server_max_streams_bidi = peer_tp->initial_max_streams_bidi;
+    qc->streams.server_max_streams_uni = peer_tp->initial_max_streams_uni;
 
-    ngx_memcpy(&qc->ctp, ctp, sizeof(ngx_quic_tp_t));
+    ngx_memcpy(&qc->peer_tp, peer_tp, sizeof(ngx_quic_tp_t));
 
     return NGX_OK;
 }
@@ -226,7 +227,7 @@ ngx_quic_new_connection(ngx_connection_t
     ngx_quic_header_t *pkt)
 {
     ngx_uint_t              i;
-    ngx_quic_tp_t          *ctp;
+    ngx_quic_tp_t          *peer_tp;
     ngx_quic_connection_t  *qc;
 
     qc = ngx_pcalloc(c->pool, sizeof(ngx_quic_connection_t));
@@ -288,13 +289,13 @@ ngx_quic_new_connection(ngx_connection_t
         return NULL;
     }
 
-    ctp = &qc->ctp;
+    peer_tp = &qc->peer_tp;
 
     /* defaults to be used before actual client parameters are received */
-    ctp->max_udp_payload_size = NGX_QUIC_MAX_UDP_PAYLOAD_SIZE;
-    ctp->ack_delay_exponent = NGX_QUIC_DEFAULT_ACK_DELAY_EXPONENT;
-    ctp->max_ack_delay = NGX_QUIC_DEFAULT_MAX_ACK_DELAY;
-    ctp->active_connection_id_limit = 2;
+    peer_tp->max_udp_payload_size = NGX_QUIC_MAX_UDP_PAYLOAD_SIZE;
+    peer_tp->ack_delay_exponent = NGX_QUIC_DEFAULT_ACK_DELAY_EXPONENT;
+    peer_tp->max_ack_delay = NGX_QUIC_DEFAULT_MAX_ACK_DELAY;
+    peer_tp->active_connection_id_limit = 2;
 
     ngx_queue_init(&qc->streams.uninitialized);
     ngx_queue_init(&qc->streams.free);
diff --git a/src/event/quic/ngx_event_quic_ack.c b/src/event/quic/ngx_event_quic_ack.c
--- a/src/event/quic/ngx_event_quic_ack.c
+++ b/src/event/quic/ngx_event_quic_ack.c
@@ -198,10 +198,10 @@ ngx_quic_rtt_sample(ngx_connection_t *c,
     } else {
         qc->min_rtt = ngx_min(qc->min_rtt, latest_rtt);
 
-        ack_delay = (ack->delay << qc->ctp.ack_delay_exponent) / 1000;
+        ack_delay = (ack->delay << qc->peer_tp.ack_delay_exponent) / 1000;
 
         if (c->ssl->handshaked) {
-            ack_delay = ngx_min(ack_delay, qc->ctp.max_ack_delay);
+            ack_delay = ngx_min(ack_delay, qc->peer_tp.max_ack_delay);
         }
 
         adjusted_rtt = latest_rtt;
@@ -534,7 +534,7 @@ ngx_quic_pcg_duration(ngx_connection_t *
 
     duration = qc->avg_rtt;
     duration += ngx_max(4 * qc->rttvar, NGX_QUIC_TIME_GRANULARITY);
-    duration += qc->ctp.max_ack_delay;
+    duration += qc->peer_tp.max_ack_delay;
     duration *= NGX_QUIC_PERSISTENT_CONGESTION_THR;
 
     return duration;
@@ -809,7 +809,7 @@ ngx_quic_pto(ngx_connection_t *c, ngx_qu
     duration += ngx_max(4 * qc->rttvar, NGX_QUIC_TIME_GRANULARITY);
 
     if (ctx->level == ssl_encryption_application && c->ssl->handshaked) {
-        duration += qc->ctp.max_ack_delay;
+        duration += qc->peer_tp.max_ack_delay;
     }
 
     return duration;
diff --git a/src/event/quic/ngx_event_quic_connection.h b/src/event/quic/ngx_event_quic_connection.h
--- a/src/event/quic/ngx_event_quic_connection.h
+++ b/src/event/quic/ngx_event_quic_connection.h
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2023 Web Server LLC
  * Copyright (C) Nginx, Inc.
  */
 
@@ -225,7 +226,7 @@ struct ngx_quic_connection_s {
     uint64_t                          path_seqnum;
 
     ngx_quic_tp_t                     tp;
-    ngx_quic_tp_t                     ctp;
+    ngx_quic_tp_t                     peer_tp;
 
     ngx_quic_send_ctx_t               send_ctx[NGX_QUIC_SEND_CTX_LAST];
 
@@ -290,7 +291,7 @@ struct ngx_quic_connection_s {
 
 
 ngx_int_t ngx_quic_apply_transport_params(ngx_connection_t *c,
-    ngx_quic_tp_t *ctp);
+    ngx_quic_tp_t *peer_tp);
 void ngx_quic_discard_ctx(ngx_connection_t *c,
     enum ssl_encryption_level_t level);
 void ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc);
diff --git a/src/event/quic/ngx_event_quic_connid.c b/src/event/quic/ngx_event_quic_connid.c
--- a/src/event/quic/ngx_event_quic_connid.c
+++ b/src/event/quic/ngx_event_quic_connid.c
@@ -1,5 +1,6 @@
 
 /*
+ * Copyright (C) 2023 Web Server LLC
  * Copyright (C) Nginx, Inc.
  */
 
@@ -410,7 +411,8 @@ ngx_quic_create_sockets(ngx_connection_t
 
     qc = ngx_quic_get_connection(c);
 
-    n = ngx_min(NGX_QUIC_MAX_SERVER_IDS, qc->ctp.active_connection_id_limit);
+    n = ngx_min(NGX_QUIC_MAX_SERVER_IDS,
+                qc->peer_tp.active_connection_id_limit);
 
     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
                    "quic create sockets has:%ui max:%ui", qc->nsockets, n);
diff --git a/src/event/quic/ngx_event_quic_migration.c b/src/event/quic/ngx_event_quic_migration.c
--- a/src/event/quic/ngx_event_quic_migration.c
+++ b/src/event/quic/ngx_event_quic_migration.c
@@ -1,5 +1,6 @@
 
 /*
+ * Copyright (C) 2023 Web Server LLC
  * Copyright (C) Nginx, Inc.
  */
 
@@ -630,9 +631,9 @@ ngx_quic_discover_path_mtu(ngx_connectio
     } else {
         path->mtud = path->mtu * 2;
 
-        if (path->mtud >= qc->ctp.max_udp_payload_size) {
-            path->mtud = qc->ctp.max_udp_payload_size;
-            path->max_mtu = qc->ctp.max_udp_payload_size;
+        if (path->mtud >= qc->peer_tp.max_udp_payload_size) {
+            path->mtud = qc->peer_tp.max_udp_payload_size;
+            path->max_mtu = qc->peer_tp.max_udp_payload_size;
         }
     }
 
diff --git a/src/event/quic/ngx_event_quic_openssl_compat.c b/src/event/quic/ngx_event_quic_openssl_compat.c
--- a/src/event/quic/ngx_event_quic_openssl_compat.c
+++ b/src/event/quic/ngx_event_quic_openssl_compat.c
@@ -1,5 +1,6 @@
 
 /*
+ * Copyright (C) 2023 Web Server LLC
  * Copyright (C) Nginx, Inc.
  */
 
@@ -49,7 +50,7 @@ struct ngx_quic_compat_s {
     ngx_quic_compat_keys_t        keys;
 
     ngx_str_t                     tp;
-    ngx_str_t                     ctp;
+    ngx_str_t                     peer_tp;
 };
 
 
@@ -355,8 +356,8 @@ ngx_quic_compat_parse_transport_params_c
 
     ngx_memcpy(p, in, inlen);
 
-    com->ctp.data = p;
-    com->ctp.len = inlen;
+    com->peer_tp.data = p;
+    com->peer_tp.len = inlen;
 
     return 1;
 }
@@ -644,8 +645,8 @@ SSL_get_peer_quic_transport_params(const
     qc = ngx_quic_get_connection(c);
     com = qc->compat;
 
-    *out_params = com->ctp.data;
-    *out_params_len = com->ctp.len;
+    *out_params = com->peer_tp.data;
+    *out_params_len = com->peer_tp.len;
 }
 
 #endif /* NGX_QUIC_OPENSSL_COMPAT */
diff --git a/src/event/quic/ngx_event_quic_ssl.c b/src/event/quic/ngx_event_quic_ssl.c
--- a/src/event/quic/ngx_event_quic_ssl.c
+++ b/src/event/quic/ngx_event_quic_ssl.c
@@ -1,5 +1,6 @@
 
 /*
+ * Copyright (C) 2023 Web Server LLC
  * Copyright (C) Nginx, Inc.
  */
 
@@ -170,7 +171,7 @@ ngx_quic_add_handshake_data(ngx_ssl_conn
     size_t                  client_params_len;
     ngx_chain_t            *out;
     const uint8_t          *client_params;
-    ngx_quic_tp_t           ctp;
+    ngx_quic_tp_t           peer_tp;
     ngx_quic_frame_t       *frame;
     ngx_connection_t       *c;
     ngx_quic_send_ctx_t    *ctx;
@@ -229,9 +230,9 @@ ngx_quic_add_handshake_data(ngx_ssl_conn
         end = p + client_params_len;
 
         /* defaults for parameters not sent by client */
-        ngx_memcpy(&ctp, &qc->ctp, sizeof(ngx_quic_tp_t));
+        ngx_memcpy(&peer_tp, &qc->peer_tp, sizeof(ngx_quic_tp_t));
 
-        if (ngx_quic_parse_transport_params(p, end, &ctp, c->log)
+        if (ngx_quic_parse_transport_params(p, end, &peer_tp, c->log)
             != NGX_OK)
         {
             qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR;
@@ -240,7 +241,7 @@ ngx_quic_add_handshake_data(ngx_ssl_conn
             return 0;
         }
 
-        if (ngx_quic_apply_transport_params(c, &ctp) != NGX_OK) {
+        if (ngx_quic_apply_transport_params(c, &peer_tp) != NGX_OK) {
             return 0;
         }
 
diff --git a/src/event/quic/ngx_event_quic_streams.c b/src/event/quic/ngx_event_quic_streams.c
--- a/src/event/quic/ngx_event_quic_streams.c
+++ b/src/event/quic/ngx_event_quic_streams.c
@@ -1,5 +1,6 @@
 
 /*
+ * Copyright (C) 2023 Web Server LLC
  * Copyright (C) Nginx, Inc.
  */
 
@@ -765,7 +766,7 @@ ngx_quic_create_stream(ngx_connection_t 
 
     if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) {
         if (id & NGX_QUIC_STREAM_SERVER_INITIATED) {
-            qs->send_max_data = qc->ctp.initial_max_stream_data_uni;
+            qs->send_max_data = qc->peer_tp.initial_max_stream_data_uni;
             qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_READ;
             qs->send_state = NGX_QUIC_STREAM_SEND_READY;
 
@@ -777,11 +778,11 @@ ngx_quic_create_stream(ngx_connection_t 
 
     } else {
         if (id & NGX_QUIC_STREAM_SERVER_INITIATED) {
-            qs->send_max_data = qc->ctp.initial_max_stream_data_bidi_remote;
+            qs->send_max_data = qc->peer_tp.initial_max_stream_data_bidi_remote;
             qs->recv_max_data = qc->tp.initial_max_stream_data_bidi_local;
 
         } else {
-            qs->send_max_data = qc->ctp.initial_max_stream_data_bidi_local;
+            qs->send_max_data = qc->peer_tp.initial_max_stream_data_bidi_local;
             qs->recv_max_data = qc->tp.initial_max_stream_data_bidi_remote;
         }
 
@@ -1019,7 +1020,7 @@ ngx_quic_stream_flush(ngx_quic_stream_t 
     qc = ngx_quic_get_connection(pc);
 
     if (qc->streams.send_max_data == 0) {
-        qc->streams.send_max_data = qc->ctp.initial_max_data;
+        qc->streams.send_max_data = qc->peer_tp.initial_max_data;
     }
 
     limit = ngx_min(qc->streams.send_max_data - qc->streams.send_offset,
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to