Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit e5c5abf

Browse files
committed
Add param h2_rapid_reset
Only RST frames received earlier than this duration will be considered rapid.
1 parent 7236bc0 commit e5c5abf

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

bin/varnishd/http2/cache_http2_proto.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ h2_rapid_reset(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)
335335
return (0);
336336

337337
now = VTIM_real();
338+
CHECK_OBJ_NOTNULL(r2->req, REQ_MAGIC);
339+
AN(r2->req->t_first);
340+
if (now - r2->req->t_first > cache_param->h2_rapid_reset)
341+
return (0);
342+
338343
d = now - h2->last_rst;
339344
h2->rst_budget += cache_param->h2_rapid_reset_limit * d /
340345
cache_param->h2_rapid_reset_period;

bin/varnishtest/tests/r03996.vtc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ server s1 {
1010
varnish v1 -cliok "param.set feature +http2"
1111
varnish v1 -cliok "param.set debug +syncvsl"
1212
varnish v1 -cliok "param.set h2_rapid_reset_limit 3"
13+
varnish v1 -cliok "param.set h2_rapid_reset 5"
1314

1415
varnish v1 -vcl+backend {
1516
import vtc;

include/tbl/params.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,20 @@ PARAM_SIMPLE(
12571257
"HTTP2 maximum size of an uncompressed header list."
12581258
)
12591259

1260+
PARAM_SIMPLE(
1261+
/* name */ h2_rapid_reset,
1262+
/* typ */ timeout,
1263+
/* min */ "0.000",
1264+
/* max */ NULL,
1265+
/* def */ "1.000",
1266+
/* units */ "seconds",
1267+
/* descr */
1268+
"The upper threshold for how rapid an http/2 RST has to come for "
1269+
"it to be treated as suspect and subjected to the rate limits "
1270+
"specified by h2_rapid_reset_limit and h2_rapid_reset_period.",
1271+
/* flags */ EXPERIMENTAL,
1272+
)
1273+
12601274
PARAM_SIMPLE(
12611275
/* name */ h2_rapid_reset_limit,
12621276
/* typ */ uint,
@@ -1284,7 +1298,6 @@ PARAM_SIMPLE(
12841298
/* flags */ EXPERIMENTAL|WIZARD,
12851299
)
12861300

1287-
12881301
/*--------------------------------------------------------------------
12891302
* Memory pool parameters
12901303
*/

0 commit comments

Comments
 (0)