comparison src/event/quic/ngx_event_quic_frames.c @ 8883:404de224517e quic

QUIC: limited the total number of frames. Exceeding 10000 allocated frames is considered a flood.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 13 Oct 2021 14:46:51 +0300
parents 4009f120cad4
children a6a328ebd362
comparison
equal deleted inserted replaced
8882:6204120cf37f 8883:404de224517e
36 #ifdef NGX_QUIC_DEBUG_ALLOC 36 #ifdef NGX_QUIC_DEBUG_ALLOC
37 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 37 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
38 "quic reuse frame n:%ui", qc->nframes); 38 "quic reuse frame n:%ui", qc->nframes);
39 #endif 39 #endif
40 40
41 } else { 41 } else if (qc->nframes < 10000) {
42 frame = ngx_palloc(c->pool, sizeof(ngx_quic_frame_t)); 42 frame = ngx_palloc(c->pool, sizeof(ngx_quic_frame_t));
43 if (frame == NULL) { 43 if (frame == NULL) {
44 return NULL; 44 return NULL;
45 } 45 }
46 46
47 ++qc->nframes;
48
47 #ifdef NGX_QUIC_DEBUG_ALLOC 49 #ifdef NGX_QUIC_DEBUG_ALLOC
48 ++qc->nframes;
49
50 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 50 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
51 "quic alloc frame n:%ui", qc->nframes); 51 "quic alloc frame n:%ui", qc->nframes);
52 #endif 52 #endif
53
54 } else {
55 ngx_log_error(NGX_LOG_INFO, c->log, 0, "quic flood detected");
56 return NULL;
53 } 57 }
54 58
55 ngx_memzero(frame, sizeof(ngx_quic_frame_t)); 59 ngx_memzero(frame, sizeof(ngx_quic_frame_t));
56 60
57 return frame; 61 return frame;