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

Commit bdf0c89

Browse files
daghfdridi
authored andcommitted
Copy rapid reset parameters to the h2 session
backport of f820f80 Conflicts: include/tbl/params.h
1 parent ca96164 commit bdf0c89

4 files changed

Lines changed: 28 additions & 13 deletions

File tree

bin/varnishd/http2/cache_http2.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,14 @@ struct h2_sess {
192192
VTAILQ_HEAD(,h2_req) txqueue;
193193

194194
h2_error error;
195-
196195
int open_streams;
196+
197+
// rst rate limit parameters, copied from h2_* parameters
198+
vtim_dur rapid_reset;
199+
int64_t rapid_reset_limit;
200+
vtim_dur rapid_reset_period;
201+
202+
// rst rate limit state
197203
double rst_budget;
198204
vtim_real last_rst;
199205
};

bin/varnishd/http2/cache_http2_proto.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,20 +325,20 @@ h2_rapid_reset(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)
325325
ASSERT_RXTHR(h2);
326326
CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC);
327327

328-
if (cache_param->h2_rapid_reset_limit == 0)
328+
if (h2->rapid_reset_limit == 0)
329329
return (0);
330330

331331
now = VTIM_real();
332332
CHECK_OBJ_NOTNULL(r2->req, REQ_MAGIC);
333333
AN(r2->req->t_first);
334-
if (now - r2->req->t_first > cache_param->h2_rapid_reset)
334+
if (now - r2->req->t_first > h2->rapid_reset)
335335
return (0);
336336

337337
d = now - h2->last_rst;
338-
h2->rst_budget += cache_param->h2_rapid_reset_limit * d /
339-
cache_param->h2_rapid_reset_period;
338+
h2->rst_budget += h2->rapid_reset_limit * d /
339+
h2->rapid_reset_period;
340340
h2->rst_budget = vmin_t(double, h2->rst_budget,
341-
cache_param->h2_rapid_reset_limit);
341+
h2->rapid_reset_limit);
342342
h2->last_rst = now;
343343

344344
if (h2->rst_budget < 1.0) {

bin/varnishd/http2/cache_http2_session.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@ h2_init_sess(const struct worker *wrk, struct sess *sp,
127127
h2_local_settings(&h2->local_settings);
128128
h2->remote_settings = H2_proto_settings;
129129
h2->decode = decode;
130-
h2->rst_budget = cache_param->h2_rapid_reset_limit;
130+
131+
h2->rapid_reset = cache_param->h2_rapid_reset;
132+
h2->rapid_reset_limit = cache_param->h2_rapid_reset_limit;
133+
h2->rapid_reset_period = cache_param->h2_rapid_reset_period;
134+
135+
h2->rst_budget = h2->rapid_reset_limit;
131136
h2->last_rst = sp->t_open;
132137
AZ(isnan(h2->last_rst));
133138

include/tbl/params.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,19 +1896,23 @@ PARAM(
18961896
)
18971897
#endif
18981898

1899+
#define H2_RR_INFO \
1900+
"Changes to this parameter affect the default for new HTTP2 " \
1901+
"sessions."
1902+
18991903
PARAM(
19001904
/* name */ h2_rapid_reset,
19011905
/* typ */ timeout,
19021906
/* min */ "0",
19031907
/* max */ NULL,
19041908
/* default */ "1.0",
19051909
/* units */ "seconds",
1906-
/* flags */ EXPERIMENTAL,
1910+
/* flags */ EXPERIMENTAL | DELAYED_EFFECT,
19071911
/* s-text */
19081912
"The upper threshold for how soon an http/2 RST_STREAM frame has "
19091913
"to be parsed after a HEADERS frame for it to be treated as "
19101914
"suspect and subjected to the rate limits specified by "
1911-
"h2_rapid_reset_limit and h2_rapid_reset_period.",
1915+
"h2_rapid_reset_limit and h2_rapid_reset_period." H2_RR_INFO,
19121916
/* l-text */ "",
19131917
/* func */ NULL
19141918
)
@@ -1921,12 +1925,12 @@ PARAM(
19211925
/* max */ NULL,
19221926
/* default */ "100",
19231927
/* units */ NULL,
1924-
/* flags */ EXPERIMENTAL,
1928+
/* flags */ EXPERIMENTAL | DELAYED_EFFECT,
19251929
/* s-text */
19261930
"HTTP2 RST Allowance.\n\n"
19271931
"Specifies the maximum number of allowed stream resets issued by "
19281932
"a client over a time period before the connection is closed. Setting "
1929-
"this parameter to 0 disables the limit.",
1933+
"this parameter to 0 disables the limit." H2_RR_INFO,
19301934
/* l-text */ "",
19311935
/* func */ NULL
19321936
)
@@ -1939,9 +1943,9 @@ PARAM(
19391943
/* max */ NULL,
19401944
/* default */ "60.000",
19411945
/* units */ "seconds",
1942-
/* flags */ EXPERIMENTAL|WIZARD,
1946+
/* flags */ EXPERIMENTAL | DELAYED_EFFECT | WIZARD,
19431947
/* s-text */
1944-
"HTTP2 sliding window duration for h2_rapid_reset_limit.",
1948+
"HTTP2 sliding window duration for h2_rapid_reset_limit." H2_RR_INFO,
19451949
/* l-text */ "",
19461950
/* func */ NULL
19471951
)

0 commit comments

Comments
 (0)