Skip to content

Commit 05cca5f

Browse files
committed
Merge of /httpd/httpd/trunk:r1924267,1927235,1927647,1927792,1929517,1929527
All accpeted backport proposals for mod_http2 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1929885 13f79535-47bb-0310-9956-ffa450edef68
1 parent ab9dd8e commit 05cca5f

File tree

19 files changed

+153
-65
lines changed

19 files changed

+153
-65
lines changed

STATUS

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -160,38 +160,6 @@ RELEASE SHOWSTOPPERS:
160160
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
161161
[ start all new proposals below, under PATCHES PROPOSED. ]
162162

163-
*) mod_http2/mod_proxy_http2: Fix bug in log2() calculation
164-
trunk patch: http://svn.apache.org/r1927235
165-
2.4.x patch: svn merge -c 1927235 ^/httpd/httpd/trunk .
166-
+1: icing, rpluem, jorton
167-
168-
*) mod_proxy_http2: add support for ProxyErrorOverride. PR69771
169-
trunk patch: http://svn.apache.org/r1927647
170-
2.4.x patch: svn merge -c 1927647 ^/httpd/httpd/trunk .
171-
+1: icing, rpluem, jorton
172-
173-
*) mod_http2: new directive H2MaxStreamErrors.
174-
trunk patch: http://svn.apache.org/r1927792
175-
2.4.x patch: svn merge -c 1927792 ^/httpd/httpd/trunk .
176-
+1: icing, rpluem, jorton
177-
178-
*) mod_http2: Fix handling of 304 responses from mod_cache. PR 69580.
179-
Trunk version of patch:
180-
https://svn.apache.org/r1924267
181-
Backport version for 2.4.x of patch:
182-
Trunk version of patch works
183-
svn merge -c 1924267 ^/httpd/httpd/trunk .
184-
+1: rpluem, jorton, covener
185-
186-
*) mod_http2: use nghttp2 supplied lengths when checking trailers.
187-
Trunk version of patch:
188-
https://svn.apache.org/r1929517
189-
https://svn.apache.org/r1929527
190-
Backport version for 2.4.x of patch:
191-
Trunk version of patch works
192-
svn merge -c 1929517,1929527 ^/httpd/httpd/trunk .
193-
+1: icing, covener, rpluem
194-
195163
*) mod_ssl: fix strict mode handling in SSLVHostSNIPolicy
196164
Trunk version of patch:
197165
https://svn.apache.org/r1929631

changes-entries/h2_v2.0.35.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*) mod_http2: update to version 2.0.35
2+
New directive `H2MaxStreamErrors` to control how much bad behaviour
3+
by clients is tolerated before the connection is closed.
4+
[Stefan Eissing]

changes-entries/pr69580.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*) mod_http2: Fix handling of 304 responses from mod_cache. PR 69580.
2+
[Stefan Eissing]

changes-entries/pr69741.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* mod_http2/mod_proxy_http2: fix a bug in calculating the log2 value of
2+
integers, used in push diaries and proxy window size calculations.
3+
PR69741 [Benjamin P. Kallus]

changes-entries/pr69771.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* mod_proxy_http2: add support for ProxyErrorOverride directive. PR69771

docs/manual/mod/mod_http2.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,4 +1166,31 @@ H2EarlyHint Link "</my.css>;rel=preload;as=style"
11661166
</usage>
11671167
</directivesynopsis>
11681168

1169+
<directivesynopsis>
1170+
<name>H2MaxStreamErrors</name>
1171+
<description>Maximum amount of client caused errors to tolerate</description>
1172+
<syntax>H2MaxStreamErrors <em>n</em></syntax>
1173+
<default>H2MaxStreamErrors 8</default>
1174+
<contextlist>
1175+
<context>server config</context>
1176+
<context>virtual host</context>
1177+
</contextlist>
1178+
<compatibility>Available in version 2.5.1 and later.</compatibility>
1179+
1180+
<usage>
1181+
<p>
1182+
<directive>H2MaxStreamErrors</directive> sets the maxmimum amount
1183+
of tolerated HTTP/2 stream errors caused by the client.
1184+
When exceeding this limit, the connection will be closed.
1185+
Stream errors are protocol violations on an individual HTTP/2
1186+
stream that do not necessitate a connection close by the
1187+
protocol specification, but can be a sign of malicious
1188+
activity by a client.
1189+
</p>
1190+
<p>
1191+
Set to 0 to tolerate faulty clients.
1192+
</p>
1193+
</usage>
1194+
</directivesynopsis>
1195+
11691196
</modulesynopsis>

modules/http2/h2_config.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ typedef struct h2_config {
7878
apr_interval_time_t stream_timeout;/* beam timeout */
7979
int max_data_frame_len; /* max # bytes in a single h2 DATA frame */
8080
int max_hd_block_len; /* max # bytes in a response header block */
81+
int max_stream_errors; /* max # of tolerated stream errors */
8182
int proxy_requests; /* act as forward proxy */
8283
int h2_websockets; /* if mod_h2 negotiating WebSockets */
8384
} h2_config;
@@ -119,6 +120,7 @@ static h2_config defconf = {
119120
-1, /* beam timeout */
120121
0, /* max DATA frame len, 0 == no extra limit */
121122
0, /* max header block len, 0 == no extra limit */
123+
8, /* max stream errors tolerated */
122124
0, /* forward proxy */
123125
0, /* WebSockets negotiation, enabled */
124126
};
@@ -168,6 +170,7 @@ void *h2_config_create_svr(apr_pool_t *pool, server_rec *s)
168170
conf->stream_timeout = DEF_VAL;
169171
conf->max_data_frame_len = DEF_VAL;
170172
conf->max_hd_block_len = DEF_VAL;
173+
conf->max_stream_errors = DEF_VAL;
171174
conf->proxy_requests = DEF_VAL;
172175
conf->h2_websockets = DEF_VAL;
173176
return conf;
@@ -220,6 +223,7 @@ static void *h2_config_merge(apr_pool_t *pool, void *basev, void *addv)
220223
n->stream_timeout = H2_CONFIG_GET(add, base, stream_timeout);
221224
n->max_data_frame_len = H2_CONFIG_GET(add, base, max_data_frame_len);
222225
n->max_hd_block_len = H2_CONFIG_GET(add, base, max_hd_block_len);
226+
n->max_stream_errors = H2_CONFIG_GET(add, base, max_stream_errors);
223227
n->proxy_requests = H2_CONFIG_GET(add, base, proxy_requests);
224228
n->h2_websockets = H2_CONFIG_GET(add, base, h2_websockets);
225229
return n;
@@ -319,6 +323,9 @@ static apr_int64_t h2_srv_config_geti64(const h2_config *conf, h2_config_var_t v
319323
return H2_CONFIG_GET(conf, &defconf, h2_websockets);
320324
case H2_CONF_MAX_HEADER_BLOCK_LEN:
321325
return H2_CONFIG_GET(conf, &defconf, max_hd_block_len);
326+
case H2_CONF_MAX_STREAM_ERRORS:
327+
return H2_CONFIG_GET(conf, &defconf, max_stream_errors);
328+
322329
default:
323330
return DEF_VAL;
324331
}
@@ -389,6 +396,9 @@ static void h2_srv_config_seti(h2_config *conf, h2_config_var_t var, int val)
389396
break;
390397
case H2_CONF_MAX_HEADER_BLOCK_LEN:
391398
H2_CONFIG_SET(conf, max_hd_block_len, val);
399+
break;
400+
case H2_CONF_MAX_STREAM_ERRORS:
401+
H2_CONFIG_SET(conf, max_stream_errors, val);
392402
default:
393403
break;
394404
}
@@ -669,6 +679,17 @@ static const char *h2_conf_set_max_hd_block_len(cmd_parms *cmd,
669679
return NULL;
670680
}
671681

682+
static const char *h2_conf_set_max_stream_errors(cmd_parms *cmd,
683+
void *dirconf, const char *value)
684+
{
685+
int val = (int)apr_atoi64(value);
686+
if (val < 0) {
687+
return "value must be 0 or larger";
688+
}
689+
CONFIG_CMD_SET(cmd, dirconf, H2_CONF_MAX_STREAM_ERRORS, val);
690+
return NULL;
691+
}
692+
672693
static const char *h2_conf_set_session_extra_files(cmd_parms *cmd,
673694
void *dirconf, const char *value)
674695
{
@@ -1092,6 +1113,8 @@ const command_rec h2_cmds[] = {
10921113
RSRC_CONF, "maximum number of bytes in a single HTTP/2 DATA frame"),
10931114
AP_INIT_TAKE1("H2MaxHeaderBlockLen", h2_conf_set_max_hd_block_len, NULL,
10941115
RSRC_CONF, "maximum number of bytes in a response header block"),
1116+
AP_INIT_TAKE1("H2MaxStreamErrors", h2_conf_set_max_stream_errors, NULL,
1117+
RSRC_CONF, "maximum number of flow control errors tolerated"),
10951118
AP_INIT_TAKE2("H2EarlyHint", h2_conf_add_early_hint, NULL,
10961119
OR_FILEINFO|OR_AUTHCFG, "add a a 'Link:' header for a 103 Early Hints response."),
10971120
AP_INIT_TAKE1("H2ProxyRequests", h2_conf_set_proxy_requests, NULL,

modules/http2/h2_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ typedef enum {
4747
H2_CONF_PROXY_REQUESTS,
4848
H2_CONF_WEBSOCKETS,
4949
H2_CONF_MAX_HEADER_BLOCK_LEN,
50+
H2_CONF_MAX_STREAM_ERRORS,
5051
} h2_config_var_t;
5152

5253
struct apr_hash_t;

modules/http2/h2_mplx.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,8 +1084,9 @@ static void s_mplx_be_happy(h2_mplx *m, conn_rec *c, h2_conn_ctx_t *conn_ctx)
10841084
m->last_mood_change = now;
10851085
m->irritations_since = 0;
10861086
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c,
1087-
H2_MPLX_MSG(m, "mood update, increasing worker limit to %d"),
1088-
m->processing_limit);
1087+
H2_MPLX_MSG(m, "mood update, increasing worker limit"
1088+
"to %d, processing %d right now"),
1089+
m->processing_limit, m->processing_count);
10891090
}
10901091
}
10911092
}
@@ -1114,8 +1115,9 @@ static void m_be_annoyed(h2_mplx *m)
11141115
m->last_mood_change = now;
11151116
m->irritations_since = 0;
11161117
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, m->c1,
1117-
H2_MPLX_MSG(m, "mood update, decreasing worker limit to %d"),
1118-
m->processing_limit);
1118+
H2_MPLX_MSG(m, "mood update, decreasing worker limit "
1119+
"to %d, processing %d right now"),
1120+
m->processing_limit, m->processing_count);
11191121
}
11201122
}
11211123
}
@@ -1139,6 +1141,7 @@ static int reset_is_acceptable(h2_stream *stream)
11391141
* The responses to such requests continue forever otherwise.
11401142
*
11411143
*/
1144+
if (stream->rst_error) return 0; /* errored stream. bad. */
11421145
if (!stream_is_running(stream)) return 1;
11431146
if (!(stream->id & 0x01)) return 1; /* stream initiated by us. acceptable. */
11441147
if (!stream->response) return 0; /* no response headers produced yet. bad. */

modules/http2/h2_proxy_session.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef struct h2_proxy_stream {
4949
unsigned int waiting_on_ping : 1;
5050
unsigned int headers_ended : 1;
5151
uint32_t error_code;
52+
int proxy_status;
5253

5354
apr_bucket_brigade *input;
5455
apr_off_t data_sent;
@@ -310,6 +311,15 @@ static int on_frame_recv(nghttp2_session *ngh2, const nghttp2_frame *frame,
310311
ap_send_interim_response(r, 1);
311312
}
312313
}
314+
else if (r->status >= 400) {
315+
proxy_dir_conf *dconf;
316+
dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
317+
if (ap_proxy_should_override(dconf, r->status)) {
318+
apr_table_setn(r->notes, "proxy-error-override", "1");
319+
nghttp2_submit_rst_stream(ngh2, NGHTTP2_FLAG_NONE,
320+
frame->hd.stream_id, NGHTTP2_STREAM_CLOSED);
321+
}
322+
}
313323
stream_resume(stream);
314324
break;
315325
case NGHTTP2_PING:

0 commit comments

Comments
 (0)