Skip to content

Commit

Permalink
Add param h2_rapid_reset
Browse files Browse the repository at this point in the history
Only RST frames received earlier than this duration will be considered
rapid.
  • Loading branch information
daghf committed Oct 17, 2023
1 parent 7236bc0 commit e5c5abf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions bin/varnishd/http2/cache_http2_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ h2_rapid_reset(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)
return (0);

now = VTIM_real();
CHECK_OBJ_NOTNULL(r2->req, REQ_MAGIC);
AN(r2->req->t_first);
if (now - r2->req->t_first > cache_param->h2_rapid_reset)
return (0);

d = now - h2->last_rst;
h2->rst_budget += cache_param->h2_rapid_reset_limit * d /
cache_param->h2_rapid_reset_period;
Expand Down
1 change: 1 addition & 0 deletions bin/varnishtest/tests/r03996.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ server s1 {
varnish v1 -cliok "param.set feature +http2"
varnish v1 -cliok "param.set debug +syncvsl"
varnish v1 -cliok "param.set h2_rapid_reset_limit 3"
varnish v1 -cliok "param.set h2_rapid_reset 5"

varnish v1 -vcl+backend {
import vtc;
Expand Down
15 changes: 14 additions & 1 deletion include/tbl/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,20 @@ PARAM_SIMPLE(
"HTTP2 maximum size of an uncompressed header list."
)

PARAM_SIMPLE(
/* name */ h2_rapid_reset,
/* typ */ timeout,
/* min */ "0.000",
/* max */ NULL,
/* def */ "1.000",
/* units */ "seconds",
/* descr */
"The upper threshold for how rapid an http/2 RST has to come for "
"it to be treated as suspect and subjected to the rate limits "
"specified by h2_rapid_reset_limit and h2_rapid_reset_period.",
/* flags */ EXPERIMENTAL,
)

PARAM_SIMPLE(
/* name */ h2_rapid_reset_limit,
/* typ */ uint,
Expand Down Expand Up @@ -1284,7 +1298,6 @@ PARAM_SIMPLE(
/* flags */ EXPERIMENTAL|WIZARD,
)


/*--------------------------------------------------------------------
* Memory pool parameters
*/
Expand Down

0 comments on commit e5c5abf

Please sign in to comment.