Commit fcd46ae3 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Distinguish between headers we receive (VSL_BogoHeader) and headers

we generate (VSL_LostHeader).

Add counters for requests received with 400, 413 and 417 errors.

Inspired by:	patch from Lasse
parent 4a1b92bf
...@@ -518,8 +518,7 @@ http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) ...@@ -518,8 +518,7 @@ http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc)
} }
if (q - p > htc->maxhdr) { if (q - p > htc->maxhdr) {
VSC_C_main->losthdr++; VSLb(hp->vsl, SLT_BogoHeader, "%.*s",
VSLb(hp->vsl, SLT_LostHeader, "%.*s",
(int)(q - p > 20 ? 20 : q - p), p); (int)(q - p > 20 ? 20 : q - p), p);
return (413); return (413);
} }
...@@ -544,8 +543,7 @@ http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) ...@@ -544,8 +543,7 @@ http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc)
http_VSLH(hp, hp->nhd); http_VSLH(hp, hp->nhd);
hp->nhd++; hp->nhd++;
} else { } else {
VSC_C_main->losthdr++; VSLb(hp->vsl, SLT_BogoHeader, "%.*s",
VSLb(hp->vsl, SLT_LostHeader, "%.*s",
(int)(q - p > 20 ? 20 : q - p), p); (int)(q - p > 20 ? 20 : q - p), p);
return (413); return (413);
} }
...@@ -558,10 +556,20 @@ http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) ...@@ -558,10 +556,20 @@ http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc)
*/ */
static uint16_t static uint16_t
http_splitline(struct http *hp, http_splitline(struct http *hp, const struct http_conn *htc, int req)
const struct http_conn *htc, int h1, int h2, int h3)
{ {
char *p, *q; char *p, *q;
int h1, h2, h3;
if (req) {
h1 = HTTP_HDR_METHOD;
h2 = HTTP_HDR_URL;
h3 = HTTP_HDR_PROTO;
} else {
h1 = HTTP_HDR_PROTO;
h2 = HTTP_HDR_STATUS;
h3 = HTTP_HDR_RESPONSE;
}
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
...@@ -663,8 +671,7 @@ http_DissectRequest(struct req *req) ...@@ -663,8 +671,7 @@ http_DissectRequest(struct req *req)
hp = req->http; hp = req->http;
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
retval = http_splitline(hp, htc, retval = http_splitline(hp, htc, 1);
HTTP_HDR_METHOD, HTTP_HDR_URL, HTTP_HDR_PROTO);
if (retval != 0) { if (retval != 0) {
VSLbt(req->vsl, SLT_HttpGarbage, htc->rxbuf); VSLbt(req->vsl, SLT_HttpGarbage, htc->rxbuf);
return (retval); return (retval);
...@@ -686,8 +693,7 @@ http_DissectResponse(struct http *hp, const struct http_conn *htc) ...@@ -686,8 +693,7 @@ http_DissectResponse(struct http *hp, const struct http_conn *htc)
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
if (http_splitline(hp, htc, if (http_splitline(hp, htc, 0))
HTTP_HDR_PROTO, HTTP_HDR_STATUS, HTTP_HDR_RESPONSE))
retval = 503; retval = 503;
if (retval == 0 && memcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.", 7)) if (retval == 0 && memcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.", 7))
......
...@@ -262,11 +262,10 @@ http1_dissect(struct worker *wrk, struct req *req) ...@@ -262,11 +262,10 @@ http1_dissect(struct worker *wrk, struct req *req)
/* If we could not even parse the request, just close */ /* If we could not even parse the request, just close */
if (req->err_code == 400) { if (req->err_code == 400) {
wrk->stats.client_req_400++;
SES_Close(req->sp, SC_RX_JUNK); SES_Close(req->sp, SC_RX_JUNK);
return (1); return (1);
} }
wrk->stats.client_req++;
req->acct_req.req++; req->acct_req.req++;
req->ws_req = WS_Snapshot(req->ws); req->ws_req = WS_Snapshot(req->ws);
...@@ -275,12 +274,17 @@ http1_dissect(struct worker *wrk, struct req *req) ...@@ -275,12 +274,17 @@ http1_dissect(struct worker *wrk, struct req *req)
/* XXX: Expect headers are a mess */ /* XXX: Expect headers are a mess */
if (req->err_code == 0 && http_GetHdr(req->http, H_Expect, &p)) { if (req->err_code == 0 && http_GetHdr(req->http, H_Expect, &p)) {
if (strcasecmp(p, "100-continue")) { if (strcasecmp(p, "100-continue")) {
wrk->stats.client_req_417++;
req->err_code = 417; req->err_code = 417;
} else if (strlen(r) != write(req->sp->fd, r, strlen(r))) { } else if (strlen(r) != write(req->sp->fd, r, strlen(r))) {
SES_Close(req->sp, SC_REM_CLOSE); SES_Close(req->sp, SC_REM_CLOSE);
return (1); return (1);
} }
} } else if (req->err_code == 413)
wrk->stats.client_req_413++;
else
wrk->stats.client_req++;
http_Unset(req->http, H_Expect); http_Unset(req->http, H_Expect);
/* XXX: pull in req-body and make it available instead. */ /* XXX: pull in req-body and make it available instead. */
req->reqbodydone = 0; req->reqbodydone = 0;
......
...@@ -216,7 +216,7 @@ tweak_bool(struct cli *cli, const struct parspec *par, const char *arg) ...@@ -216,7 +216,7 @@ tweak_bool(struct cli *cli, const struct parspec *par, const char *arg)
*dest = 1; *dest = 1;
else { else {
VCLI_Out(cli, VCLI_Out(cli,
mode ? mode ?
"use \"on\" or \"off\"\n" : "use \"on\" or \"off\"\n" :
"use \"true\" or \"false\"\n"); "use \"true\" or \"false\"\n");
VCLI_SetResult(cli, CLIS_PARAM); VCLI_SetResult(cli, CLIS_PARAM);
......
...@@ -90,11 +90,29 @@ VSC_F(sess_fail, uint64_t, 1, 'c', ...@@ -90,11 +90,29 @@ VSC_F(sess_fail, uint64_t, 1, 'c',
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
VSC_F(client_req_400, uint64_t, 1, 'a',
"Client requests received, subject to 400 errors",
"400 means we couldn't make sense of the request, it was"
" malformed in some drastic way."
)
VSC_F(client_req_413, uint64_t, 1, 'a',
"Client requests received, subject to 413 errors",
"413 means that HTTP headers execeeded length or count limits."
)
VSC_F(client_req_417, uint64_t, 1, 'a',
"Client requests received, subject to 417 errors",
"417 means that something went wrong with an Expect: header."
)
VSC_F(client_req, uint64_t, 1, 'a', VSC_F(client_req, uint64_t, 1, 'a',
"Client requests received", "Good Client requests received",
"" ""
) )
/*---------------------------------------------------------------------*/
VSC_F(cache_hit, uint64_t, 1, 'a', VSC_F(cache_hit, uint64_t, 1, 'a',
"Cache hits", "Cache hits",
"Count of cache hits. " "Count of cache hits. "
...@@ -110,6 +128,7 @@ VSC_F(cache_hitpass, uint64_t, 1, 'a', ...@@ -110,6 +128,7 @@ VSC_F(cache_hitpass, uint64_t, 1, 'a',
" cached in it self. This counts how many times the cached " " cached in it self. This counts how many times the cached "
" decision is being used." " decision is being used."
) )
VSC_F(cache_miss, uint64_t, 1, 'a', VSC_F(cache_miss, uint64_t, 1, 'a',
"Cache misses", "Cache misses",
"Count of misses" "Count of misses"
...@@ -117,6 +136,8 @@ VSC_F(cache_miss, uint64_t, 1, 'a', ...@@ -117,6 +136,8 @@ VSC_F(cache_miss, uint64_t, 1, 'a',
" backend before delivering it to the backend." " backend before delivering it to the backend."
) )
/*---------------------------------------------------------------------*/
VSC_F(backend_conn, uint64_t, 0, 'a', VSC_F(backend_conn, uint64_t, 0, 'a',
"Backend conn. success", "Backend conn. success",
"" ""
......
...@@ -130,7 +130,11 @@ SLTM(FetchError, "Error while fetching object", "") ...@@ -130,7 +130,11 @@ SLTM(FetchError, "Error while fetching object", "")
#include "tbl/vsl_tags_http.h" #include "tbl/vsl_tags_http.h"
#undef SLTH #undef SLTH
SLTM(LostHeader, "", "") SLTM(BogoHeader, "Bogus HTTP received",
"Contains the first 20 characters of received HTTP headers we could"
" not make sense of. Applies to both req.http and beres.http."
)
SLTM(LostHeader, "Failed attempt to set HTTP header", "")
SLTM(TTL, "TTL set on object", "") SLTM(TTL, "TTL set on object", "")
SLTM(Fetch_Body, "Body fetched from backend", "") SLTM(Fetch_Body, "Body fetched from backend", "")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment