QUIC: added path limiting function ngx_quic_path_limit().
This commit is contained in:
parent
10fd8be86d
commit
3341a85076
@ -63,6 +63,8 @@ static ssize_t ngx_quic_send(ngx_connection_t *c, u_char *buf, size_t len,
|
||||
struct sockaddr *sockaddr, socklen_t socklen);
|
||||
static void ngx_quic_set_packet_number(ngx_quic_header_t *pkt,
|
||||
ngx_quic_send_ctx_t *ctx);
|
||||
static size_t ngx_quic_path_limit(ngx_connection_t *c, ngx_quic_path_t *path,
|
||||
size_t size);
|
||||
|
||||
|
||||
size_t
|
||||
@ -137,7 +139,6 @@ ngx_quic_socket_output(ngx_connection_t *c, ngx_quic_socket_t *qsock)
|
||||
static ngx_int_t
|
||||
ngx_quic_create_datagrams(ngx_connection_t *c, ngx_quic_socket_t *qsock)
|
||||
{
|
||||
off_t max;
|
||||
size_t len, min;
|
||||
ssize_t n;
|
||||
u_char *p;
|
||||
@ -160,12 +161,7 @@ ngx_quic_create_datagrams(ngx_connection_t *c, ngx_quic_socket_t *qsock)
|
||||
len = ngx_min(qc->ctp.max_udp_payload_size,
|
||||
NGX_QUIC_MAX_UDP_PAYLOAD_SIZE);
|
||||
|
||||
if (path->limited) {
|
||||
max = path->received * 3;
|
||||
max = (path->sent >= max) ? 0 : max - path->sent;
|
||||
|
||||
len = ngx_min(len, (size_t) max);
|
||||
}
|
||||
len = ngx_quic_path_limit(c, path, len);
|
||||
|
||||
pad = ngx_quic_get_padding_level(c);
|
||||
|
||||
@ -1212,7 +1208,6 @@ ngx_int_t
|
||||
ngx_quic_frame_sendto(ngx_connection_t *c, ngx_quic_frame_t *frame,
|
||||
size_t min, ngx_quic_path_t *path)
|
||||
{
|
||||
off_t max;
|
||||
size_t min_payload, pad;
|
||||
ssize_t len, sent;
|
||||
ngx_str_t res;
|
||||
@ -1228,14 +1223,7 @@ ngx_quic_frame_sendto(ngx_connection_t *c, ngx_quic_frame_t *frame,
|
||||
|
||||
ngx_quic_init_packet(c, ctx, qc->socket, &pkt);
|
||||
|
||||
/* account for anti-amplification limit: expand to allowed size */
|
||||
if (path->limited) {
|
||||
max = path->received * 3;
|
||||
max = (path->sent >= max) ? 0 : max - path->sent;
|
||||
if ((off_t) min > max) {
|
||||
min = max;
|
||||
}
|
||||
}
|
||||
min = ngx_quic_path_limit(c, path, min);
|
||||
|
||||
min_payload = min ? ngx_quic_payload_size(&pkt, min) : 0;
|
||||
|
||||
@ -1279,3 +1267,23 @@ ngx_quic_frame_sendto(ngx_connection_t *c, ngx_quic_frame_t *frame,
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static size_t
|
||||
ngx_quic_path_limit(ngx_connection_t *c, ngx_quic_path_t *path, size_t size)
|
||||
{
|
||||
off_t max;
|
||||
|
||||
if (path->limited) {
|
||||
max = path->received * 3;
|
||||
max = (path->sent >= max) ? 0 : max - path->sent;
|
||||
|
||||
if ((off_t) size > max) {
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||
"quic path limit %uz - %O", size, max);
|
||||
return max;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user