Roman Arutyunyan
November 17, 2021 02:32AM
# HG changeset patch
# User Roman Arutyunyan <arut@nginx.com>
# Date 1637086755 -10800
# Tue Nov 16 21:19:15 2021 +0300
# Branch quic
# Node ID 0fb2613594f6bd8dd8f07a30c69900866b573158
# Parent 4e3a7fc0533192f51a01042a1e9dd2b595881420
QUIC: handle DATA_BLOCKED frame from client.

Previously the frame was not handled and connection was closed with an error.
Now, after receiving this frame, global flow control is updated and new
flow control credit is sent to client.

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
@@ -1252,6 +1252,17 @@ ngx_quic_handle_frames(ngx_connection_t

break;

+ case NGX_QUIC_FT_DATA_BLOCKED:
+
+ if (ngx_quic_handle_data_blocked_frame(c, pkt,
+ &frame.u.data_blocked)
+ != NGX_OK)
+ {
+ return NGX_ERROR;
+ }
+
+ break;
+
case NGX_QUIC_FT_STREAM_DATA_BLOCKED:

if (ngx_quic_handle_stream_data_blocked_frame(c, pkt,
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
@@ -32,6 +32,7 @@ static void ngx_quic_stream_cleanup_hand
static ngx_int_t ngx_quic_control_flow(ngx_connection_t *c, uint64_t last);
static ngx_int_t ngx_quic_update_flow(ngx_connection_t *c, uint64_t last);
static ngx_int_t ngx_quic_update_max_stream_data(ngx_connection_t *c);
+static ngx_int_t ngx_quic_update_max_data(ngx_connection_t *c);


ngx_connection_t *
@@ -1188,6 +1189,14 @@ ngx_quic_handle_streams_blocked_frame(ng


ngx_int_t
+ngx_quic_handle_data_blocked_frame(ngx_connection_t *c,
+ ngx_quic_header_t *pkt, ngx_quic_data_blocked_frame_t *f)
+{
+ return ngx_quic_update_max_data(c);
+}
+
+
+ngx_int_t
ngx_quic_handle_stream_data_blocked_frame(ngx_connection_t *c,
ngx_quic_header_t *pkt, ngx_quic_stream_data_blocked_frame_t *f)
{
@@ -1544,7 +1553,6 @@ ngx_quic_update_flow(ngx_connection_t *c
uint64_t len;
ngx_event_t *rev;
ngx_connection_t *pc;
- ngx_quic_frame_t *frame;
ngx_quic_stream_t *qs;
ngx_quic_connection_t *qc;

@@ -1577,22 +1585,9 @@ ngx_quic_update_flow(ngx_connection_t *c
if (qc->streams.recv_max_data
<= qc->streams.recv_offset + qc->streams.recv_window / 2)
{
- qc->streams.recv_max_data = qc->streams.recv_offset
- + qc->streams.recv_window;
-
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0,
- "quic flow update md:%uL", qc->streams.recv_max_data);
-
- frame = ngx_quic_alloc_frame(pc);
- if (frame == NULL) {
+ if (ngx_quic_update_max_data(pc) != NGX_OK) {
return NGX_ERROR;
}
-
- frame->level = ssl_encryption_application;
- frame->type = NGX_QUIC_FT_MAX_DATA;
- frame->u.max_data.max_data = qc->streams.recv_max_data;
-
- ngx_quic_queue_frame(qc, frame);
}

return NGX_OK;
@@ -1637,6 +1632,41 @@ ngx_quic_update_max_stream_data(ngx_conn
}


+static ngx_int_t
+ngx_quic_update_max_data(ngx_connection_t *c)
+{
+ uint64_t recv_max_data;
+ ngx_quic_frame_t *frame;
+ ngx_quic_connection_t *qc;
+
+ qc = ngx_quic_get_connection(c);
+
+ recv_max_data = qc->streams.recv_offset + qc->streams.recv_window;
+
+ if (qc->streams.recv_max_data == recv_max_data) {
+ return NGX_OK;
+ }
+
+ qc->streams.recv_max_data = recv_max_data;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
+ "quic flow update md:%uL", qc->streams.recv_max_data);
+
+ frame = ngx_quic_alloc_frame(c);
+ if (frame == NULL) {
+ return NGX_ERROR;
+ }
+
+ frame->level = ssl_encryption_application;
+ frame->type = NGX_QUIC_FT_MAX_DATA;
+ frame->u.max_data.max_data = qc->streams.recv_max_data;
+
+ ngx_quic_queue_frame(qc, frame);
+
+ return NGX_OK;
+}
+
+
ngx_int_t
ngx_quic_handle_read_event(ngx_event_t *rev, ngx_uint_t flags)
{
diff --git a/src/event/quic/ngx_event_quic_streams.h b/src/event/quic/ngx_event_quic_streams.h
--- a/src/event/quic/ngx_event_quic_streams.h
+++ b/src/event/quic/ngx_event_quic_streams.h
@@ -20,6 +20,8 @@ ngx_int_t ngx_quic_handle_max_data_frame
ngx_quic_max_data_frame_t *f);
ngx_int_t ngx_quic_handle_streams_blocked_frame(ngx_connection_t *c,
ngx_quic_header_t *pkt, ngx_quic_streams_blocked_frame_t *f);
+ngx_int_t ngx_quic_handle_data_blocked_frame(ngx_connection_t *c,
+ ngx_quic_header_t *pkt, ngx_quic_data_blocked_frame_t *f);
ngx_int_t ngx_quic_handle_stream_data_blocked_frame(ngx_connection_t *c,
ngx_quic_header_t *pkt, ngx_quic_stream_data_blocked_frame_t *f);
ngx_int_t ngx_quic_handle_max_stream_data_frame(ngx_connection_t *c,
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 0 of 2] QUIC flow control update

Roman Arutyunyan 387 November 17, 2021 02:32AM

[PATCH 1 of 2] QUIC: update stream flow control credit on STREAM_DATA_BLOCKED

Roman Arutyunyan 144 November 17, 2021 02:32AM

Re: [PATCH 1 of 2] QUIC: update stream flow control credit on STREAM_DATA_BLOCKED

Roman Arutyunyan 222 November 17, 2021 03:22AM

Re: [PATCH 1 of 2] QUIC: update stream flow control credit on STREAM_DATA_BLOCKED

Vladimir Homutov 134 November 22, 2021 03:22AM

Re: [PATCH 1 of 2] QUIC: update stream flow control credit on STREAM_DATA_BLOCKED

Roman Arutyunyan 144 November 22, 2021 06:52AM

[PATCH 2 of 2] QUIC: handle DATA_BLOCKED frame from client

Roman Arutyunyan 252 November 17, 2021 02:32AM

Re: [PATCH 2 of 2] QUIC: handle DATA_BLOCKED frame from client

Vladimir Homutov 123 November 22, 2021 03:28AM

Re: [PATCH 2 of 2] QUIC: handle DATA_BLOCKED frame from client

Roman Arutyunyan 112 November 22, 2021 06:56AM

Re: [PATCH 2 of 2] QUIC: handle DATA_BLOCKED frame from client

Vladimir Homutov 187 November 22, 2021 07:02AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 289
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready