Commit 71a18061 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a "vsl_mask" parameter, that allows individual SLT tags to be

suppressed so the never take up space/bandwidth in the VSL.

Reimplement vcl_trace using this:

	param.set vsl_mask +VCL_trace
	param.set vsl_mask -VCL_trace

XXX: doc-update needed
parent 1ecffcdc
...@@ -61,6 +61,7 @@ varnishd_SOURCES = \ ...@@ -61,6 +61,7 @@ varnishd_SOURCES = \
mgt/mgt_cli.c \ mgt/mgt_cli.c \
mgt/mgt_main.c \ mgt/mgt_main.c \
mgt/mgt_param.c \ mgt/mgt_param.c \
mgt/mgt_param_vsl.c \
mgt/mgt_pool.c \ mgt/mgt_pool.c \
mgt/mgt_sandbox.c \ mgt/mgt_sandbox.c \
mgt/mgt_sandbox_solaris.c \ mgt/mgt_sandbox_solaris.c \
......
...@@ -50,6 +50,18 @@ static uint32_t *vsl_ptr; ...@@ -50,6 +50,18 @@ static uint32_t *vsl_ptr;
struct VSC_C_main *VSC_C_main; struct VSC_C_main *VSC_C_main;
static inline int
vsl_tag_is_masked(enum VSL_tag_e tag)
{
volatile uint8_t *bm = &cache_param->vsl_mask[0];
uint8_t b;
assert(tag < SLT_Reserved);
bm += ((unsigned)tag >> 3);
b = (0x80 >> ((unsigned)tag & 7));
return (*bm & b);
}
static inline uint32_t static inline uint32_t
vsl_w0(uint32_t type, uint32_t length) vsl_w0(uint32_t type, uint32_t length)
{ {
...@@ -159,6 +171,8 @@ VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...) ...@@ -159,6 +171,8 @@ VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...)
unsigned n, mlen = cache_param->shm_reclen; unsigned n, mlen = cache_param->shm_reclen;
char buf[mlen]; char buf[mlen];
if (vsl_tag_is_masked(tag))
return;
AN(fmt); AN(fmt);
va_start(ap, fmt); va_start(ap, fmt);
...@@ -281,6 +295,8 @@ VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) ...@@ -281,6 +295,8 @@ VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...)
va_list ap; va_list ap;
AN(fmt); AN(fmt);
if (vsl_tag_is_masked(tag))
return;
va_start(ap, fmt); va_start(ap, fmt);
wsl(vsl, tag, vsl->wid, fmt, ap); wsl(vsl, tag, vsl->wid, fmt, ap);
va_end(ap); va_end(ap);
...@@ -293,6 +309,9 @@ VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) ...@@ -293,6 +309,9 @@ VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...)
void void
VSLbt(struct vsl_log *vsl, enum VSL_tag_e tag, txt t) VSLbt(struct vsl_log *vsl, enum VSL_tag_e tag, txt t)
{ {
if (vsl_tag_is_masked(tag))
return;
wslr(vsl, tag, -1, t); wslr(vsl, tag, -1, t);
} }
......
...@@ -75,7 +75,6 @@ VRT_count(struct req *req, unsigned u) ...@@ -75,7 +75,6 @@ VRT_count(struct req *req, unsigned u)
if (req == NULL) if (req == NULL)
return; return;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
if (cache_param->vcl_trace)
VSLb(req->vsl, SLT_VCL_trace, "%u %u.%u", u, VSLb(req->vsl, SLT_VCL_trace, "%u %u.%u", u,
req->vcl->ref[u].line, req->vcl->ref[u].pos); req->vcl->ref[u].line, req->vcl->ref[u].pos);
} }
......
...@@ -103,10 +103,6 @@ struct params { ...@@ -103,10 +103,6 @@ struct params {
ssize_t fetch_maxchunksize; ssize_t fetch_maxchunksize;
unsigned nuke_limit; unsigned nuke_limit;
/* VCL traces */
unsigned vcl_trace;
unsigned accept_filter; unsigned accept_filter;
/* Listen address */ /* Listen address */
...@@ -204,4 +200,6 @@ struct params { ...@@ -204,4 +200,6 @@ struct params {
struct poolparam req_pool; struct poolparam req_pool;
struct poolparam sess_pool; struct poolparam sess_pool;
struct poolparam vbo_pool; struct poolparam vbo_pool;
uint8_t vsl_mask[256/8];
}; };
...@@ -872,14 +872,6 @@ static const struct parspec input_parspec[] = { ...@@ -872,14 +872,6 @@ static const struct parspec input_parspec[] = {
"fragmentation.\n", "fragmentation.\n",
EXPERIMENTAL, EXPERIMENTAL,
"256m", "bytes" }, "256m", "bytes" },
{ "vcl_trace", tweak_bool, &mgt_param.vcl_trace, 0, 0,
"Trace VCL execution in the shmlog.\n"
"Enabling this will allow you to see the path each "
"request has taken through the VCL program.\n"
"This generates a lot of logrecords so it is off by "
"default.",
0,
"off", "bool" },
{ "accept_filter", tweak_bool, &mgt_param.accept_filter, 0, 0, { "accept_filter", tweak_bool, &mgt_param.accept_filter, 0, 0,
"Enable kernel accept-filters, if supported by the kernel.", "Enable kernel accept-filters, if supported by the kernel.",
MUST_RESTART, MUST_RESTART,
...@@ -1318,7 +1310,7 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) ...@@ -1318,7 +1310,7 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv)
continue; continue;
} }
pp->func(cli, pp, NULL); pp->func(cli, pp, NULL);
if (pp->units != NULL) if (pp->units != NULL && *pp->units != '\0')
VCLI_Out(cli, " [%s]\n", pp->units); VCLI_Out(cli, " [%s]\n", pp->units);
else else
VCLI_Out(cli, "\n"); VCLI_Out(cli, "\n");
...@@ -1496,6 +1488,7 @@ MCF_ParamInit(struct cli *cli) ...@@ -1496,6 +1488,7 @@ MCF_ParamInit(struct cli *cli)
MCF_AddParams(input_parspec); MCF_AddParams(input_parspec);
MCF_AddParams(WRK_parspec); MCF_AddParams(WRK_parspec);
MCF_AddParams(VSL_parspec);
/* XXX: We do this twice, to get past any interdependencies */ /* XXX: We do this twice, to get past any interdependencies */
MCF_SetDefaults(NULL); MCF_SetDefaults(NULL);
......
...@@ -57,5 +57,8 @@ void tweak_timeout_double(struct cli *cli, ...@@ -57,5 +57,8 @@ void tweak_timeout_double(struct cli *cli,
const struct parspec *par, const char *arg); const struct parspec *par, const char *arg);
void tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg); void tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg);
/* mgt_param_vsl.c */
extern const struct parspec VSL_parspec[];
/* mgt_pool.c */ /* mgt_pool.c */
extern const struct parspec WRK_parspec[]; extern const struct parspec WRK_parspec[];
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2011 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include "common/params.h"
#include "mgt/mgt.h"
#include "mgt/mgt_param.h"
#include "vav.h"
#include "vcli.h"
#include "vcli_common.h"
#include "vcli_priv.h"
#include "vapi/vsl_int.h"
static const char * const VSL_tags[256] = {
# define SLTM(foo,sdesc,ldesc) [SLT_##foo] = #foo,
# include "tbl/vsl_tags.h"
# undef SLTM
};
enum bit_do {BSET, BCLR, BTST};
static int
vsl_bit(unsigned no, enum bit_do act)
{
volatile uint8_t *bm = &mgt_param.vsl_mask[0];
uint8_t b;
assert(no < (unsigned)SLT_Reserved);
bm += (no >> 3);
b = (0x80 >> (no & 7));
if (act == BSET)
*bm |= b;
else if (act == BCLR)
*bm &= ~b;
return (*bm & b);
}
static void
tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg)
{
int i, n;
unsigned j;
const char *s;
char **av;
(void)par;
if (arg != NULL) {
if (!strcmp(arg, "default")) {
(void)vsl_bit(SLT_VCL_trace, BSET);
(void)vsl_bit(SLT_WorkThread, BSET);
} else if (*arg != 0) {
av = VAV_Parse(arg, &n, ARGV_COMMA);
if (av[0] != NULL) {
VCLI_Out(cli, "Cannot parse: %s\n", av[0]);
VCLI_SetResult(cli, CLIS_PARAM);
return;
}
for (i = 1; av[i] != NULL; i++) {
s = av[i];
if (*s != '-' && *s != '+') {
VCLI_Out(cli,
"Missing '+' or '-' (%s)\n", s);
VCLI_SetResult(cli, CLIS_PARAM);
VAV_Free(av);
return;
}
for (j = 0; j < 256; j++)
if (VSL_tags[j] != NULL &&
!strcasecmp(s + 1, VSL_tags[j]))
break;
if (j == 256) {
VCLI_Out(cli,
"Unknown VSL tag (%s)\n", s);
VCLI_SetResult(cli, CLIS_PARAM);
VAV_Free(av);
return;
}
if (s[0] == '+')
(void)vsl_bit(j, BCLR);
else
(void)vsl_bit(j, BSET);
}
VAV_Free(av);
}
} else {
s = "";
for (j = 0; j < 256; j++) {
if (vsl_bit(j, BTST)) {
VCLI_Out(cli, "%s-%s", s, VSL_tags[j]);
s = ",";
}
}
if (*s == '\0')
VCLI_Out(cli, "(all enabled)");
}
}
const struct parspec VSL_parspec[] = {
{ "vsl_mask", tweak_vsl_mask, NULL, 0, 0,
"Mask individual VSL messages from being logged",
0, "default", "" },
{ NULL, NULL, NULL }
};
...@@ -9,7 +9,7 @@ server s1 { ...@@ -9,7 +9,7 @@ server s1 {
txresp -body "2222\n" txresp -body "2222\n"
} -start } -start
varnish v1 -arg "-p vcl_trace=on" -vcl+backend { varnish v1 -arg "-p vsl_mask=+VCL_trace" -vcl+backend {
acl acl1 { acl acl1 {
"localhost"; "localhost";
} }
......
varnishtest "SLT masking"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {} -start
varnish v1 -cliok "param.show vsl_mask"
varnish v1 -cliok "param.set vsl_mask +VCL_trace"
varnish v1 -cliok "param.show vsl_mask"
varnish v1 -cliok "param.set vsl_mask -WorkThread,-TTL"
varnish v1 -cliok "param.show vsl_mask"
varnish v1 -cliok "param.set vsl_mask +WorkThread"
varnish v1 -clierr 106 "param.set vsl_mask FooBar"
varnish v1 -clierr 106 "param.set vsl_mask -FooBar"
client c1 {
txreq
rxresp
} -run
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