aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVladimir Homutov <vl@nginx.com>2021-03-31 14:57:15 +0300
committerVladimir Homutov <vl@nginx.com>2021-03-31 14:57:15 +0300
commit79b66760a19599fa4b2cb3b9aa3c3e7e937df8ae (patch)
tree325af26e1d57bbad96b52073c07360ba25d4fefe /src
parentbd90c0ab796a3a321d17262c189bde334746acc3 (diff)
downloadnginx-79b66760a19599fa4b2cb3b9aa3c3e7e937df8ae.tar.gz
nginx-79b66760a19599fa4b2cb3b9aa3c3e7e937df8ae.zip
QUIC: distinct files for connection migration.
The connection migration-related code from quic.c with dependencies is moved into separate file.
Diffstat (limited to 'src')
-rw-r--r--src/event/quic/ngx_event_quic.c61
-rw-r--r--src/event/quic/ngx_event_quic_connection.h13
-rw-r--r--src/event/quic/ngx_event_quic_migration.c46
-rw-r--r--src/event/quic/ngx_event_quic_migration.h20
4 files changed, 92 insertions, 48 deletions
diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c
index 4fedf755b..4129aa316 100644
--- a/src/event/quic/ngx_event_quic.c
+++ b/src/event/quic/ngx_event_quic.c
@@ -10,21 +10,10 @@
#include <ngx_event_quic_transport.h>
#include <ngx_event_quic_protection.h>
#include <ngx_event_quic_connection.h>
+#include <ngx_event_quic_migration.h>
#include <ngx_sha1.h>
-/* 0-RTT and 1-RTT data exist in the same packet number space,
- * so we have 3 packet number spaces:
- *
- * 0 - Initial
- * 1 - Handshake
- * 2 - 0-RTT and 1-RTT
- */
-#define ngx_quic_get_send_ctx(qc, level) \
- ((level) == ssl_encryption_initial) ? &((qc)->send_ctx[0]) \
- : (((level) == ssl_encryption_handshake) ? &((qc)->send_ctx[1]) \
- : &((qc)->send_ctx[2]))
-
#define ngx_quic_lost_threshold(qc) \
ngx_max(NGX_QUIC_TIME_THR * ngx_max((qc)->latest_rtt, (qc)->avg_rtt), \
NGX_QUIC_TIME_GRANULARITY)
@@ -141,8 +130,6 @@ static ngx_int_t ngx_quic_handle_ack_frame_range(ngx_connection_t *c,
ngx_msec_t *send_time);
static void ngx_quic_rtt_sample(ngx_connection_t *c, ngx_quic_ack_frame_t *ack,
enum ssl_encryption_level_t level, ngx_msec_t send_time);
-static ngx_inline ngx_msec_t ngx_quic_pto(ngx_connection_t *c,
- ngx_quic_send_ctx_t *ctx);
static void ngx_quic_handle_stream_ack(ngx_connection_t *c,
ngx_quic_frame_t *f);
@@ -177,8 +164,6 @@ static ngx_int_t ngx_quic_handle_stop_sending_frame(ngx_connection_t *c,
ngx_quic_header_t *pkt, ngx_quic_stop_sending_frame_t *f);
static ngx_int_t ngx_quic_handle_max_streams_frame(ngx_connection_t *c,
ngx_quic_header_t *pkt, ngx_quic_max_streams_frame_t *f);
-static ngx_int_t ngx_quic_handle_path_challenge_frame(ngx_connection_t *c,
- ngx_quic_header_t *pkt, ngx_quic_path_challenge_frame_t *f);
static ngx_int_t ngx_quic_handle_new_connection_id_frame(ngx_connection_t *c,
ngx_quic_header_t *pkt, ngx_quic_new_conn_id_frame_t *f);
static ngx_int_t ngx_quic_retire_connection_id(ngx_connection_t *c,
@@ -2755,6 +2740,17 @@ ngx_quic_handle_frames(ngx_connection_t *c, ngx_quic_header_t *pkt)
break;
+ case NGX_QUIC_FT_PATH_RESPONSE:
+
+ if (ngx_quic_handle_path_response_frame(c, pkt,
+ &frame.u.path_response)
+ != NGX_OK)
+ {
+ return NGX_ERROR;
+ }
+
+ break;
+
case NGX_QUIC_FT_NEW_CONNECTION_ID:
if (ngx_quic_handle_new_connection_id_frame(c, pkt, &frame.u.ncid)
@@ -2776,13 +2772,6 @@ ngx_quic_handle_frames(ngx_connection_t *c, ngx_quic_header_t *pkt)
break;
- case NGX_QUIC_FT_PATH_RESPONSE:
-
- /* TODO: handle */
- ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "quic frame handler not implemented");
- break;
-
default:
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic missing frame handler");
@@ -3510,7 +3499,7 @@ ngx_quic_rtt_sample(ngx_connection_t *c, ngx_quic_ack_frame_t *ack,
}
-static ngx_inline ngx_msec_t
+ngx_msec_t
ngx_quic_pto(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx)
{
ngx_msec_t duration;
@@ -4378,30 +4367,6 @@ ngx_quic_handle_max_streams_frame(ngx_connection_t *c,
static ngx_int_t
-ngx_quic_handle_path_challenge_frame(ngx_connection_t *c,
- ngx_quic_header_t *pkt, ngx_quic_path_challenge_frame_t *f)
-{
- ngx_quic_frame_t *frame;
- ngx_quic_connection_t *qc;
-
- qc = ngx_quic_get_connection(c);
-
- frame = ngx_quic_alloc_frame(c);
- if (frame == NULL) {
- return NGX_ERROR;
- }
-
- frame->level = pkt->level;
- frame->type = NGX_QUIC_FT_PATH_RESPONSE;
- frame->u.path_response = *f;
-
- ngx_quic_queue_frame(qc, frame);
-
- return NGX_OK;
-}
-
-
-static ngx_int_t
ngx_quic_handle_new_connection_id_frame(ngx_connection_t *c,
ngx_quic_header_t *pkt, ngx_quic_new_conn_id_frame_t *f)
{
diff --git a/src/event/quic/ngx_event_quic_connection.h b/src/event/quic/ngx_event_quic_connection.h
index 298857a83..acbec5133 100644
--- a/src/event/quic/ngx_event_quic_connection.h
+++ b/src/event/quic/ngx_event_quic_connection.h
@@ -19,6 +19,18 @@
typedef struct ngx_quic_connection_s ngx_quic_connection_t;
+/* 0-RTT and 1-RTT data exist in the same packet number space,
+ * so we have 3 packet number spaces:
+ *
+ * 0 - Initial
+ * 1 - Handshake
+ * 2 - 0-RTT and 1-RTT
+ */
+#define ngx_quic_get_send_ctx(qc, level) \
+ ((level) == ssl_encryption_initial) ? &((qc)->send_ctx[0]) \
+ : (((level) == ssl_encryption_handshake) ? &((qc)->send_ctx[1]) \
+ : &((qc)->send_ctx[2]))
+
typedef struct {
ngx_queue_t queue;
@@ -175,5 +187,6 @@ struct ngx_quic_connection_s {
ngx_quic_frame_t *ngx_quic_alloc_frame(ngx_connection_t *c);
void ngx_quic_queue_frame(ngx_quic_connection_t *qc, ngx_quic_frame_t *frame);
void ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc);
+ngx_msec_t ngx_quic_pto(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx);
#endif
diff --git a/src/event/quic/ngx_event_quic_migration.c b/src/event/quic/ngx_event_quic_migration.c
new file mode 100644
index 000000000..de3d6885d
--- /dev/null
+++ b/src/event/quic/ngx_event_quic_migration.c
@@ -0,0 +1,46 @@
+
+/*
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_event.h>
+#include <ngx_event_quic_transport.h>
+#include <ngx_event_quic_connection.h>
+#include <ngx_event_quic_migration.h>
+
+
+ngx_int_t
+ngx_quic_handle_path_challenge_frame(ngx_connection_t *c,
+ ngx_quic_header_t *pkt, ngx_quic_path_challenge_frame_t *f)
+{
+ ngx_quic_frame_t *frame;
+ ngx_quic_connection_t *qc;
+
+ qc = ngx_quic_get_connection(c);
+
+ frame = ngx_quic_alloc_frame(c);
+ if (frame == NULL) {
+ return NGX_ERROR;
+ }
+
+ frame->level = pkt->level;
+ frame->type = NGX_QUIC_FT_PATH_RESPONSE;
+ frame->u.path_response = *f;
+
+ ngx_quic_queue_frame(qc, frame);
+
+ return NGX_OK;
+}
+
+
+ngx_int_t
+ngx_quic_handle_path_response_frame(ngx_connection_t *c,
+ ngx_quic_header_t *pkt, ngx_quic_path_challenge_frame_t *f)
+{
+ /* TODO */
+ return NGX_OK;
+}
+
diff --git a/src/event/quic/ngx_event_quic_migration.h b/src/event/quic/ngx_event_quic_migration.h
new file mode 100644
index 000000000..3231b7e3b
--- /dev/null
+++ b/src/event/quic/ngx_event_quic_migration.h
@@ -0,0 +1,20 @@
+
+/*
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#ifndef _NGX_EVENT_QUIC_MIGRATION_H_INCLUDED_
+#define _NGX_EVENT_QUIC_MIGRATION_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+ngx_int_t ngx_quic_handle_path_challenge_frame(ngx_connection_t *c,
+ ngx_quic_header_t *pkt, ngx_quic_path_challenge_frame_t *f);
+ngx_int_t ngx_quic_handle_path_response_frame(ngx_connection_t *c,
+ ngx_quic_header_t *pkt, ngx_quic_path_challenge_frame_t *f);
+
+#endif