Commit dbd9d1bb authored by Geoff Simmons's avatar Geoff Simmons

Implement input and output stats for decryption VFPs.

parent 5cdfb762
...@@ -12,4 +12,16 @@ ...@@ -12,4 +12,16 @@
Total number of en-/decryption operations Total number of en-/decryption operations
.. varnish_vsc:: out
:type: counter
:oneliner: Output bytes
Total number of bytes output by the en-/decrypter
.. varnish_vsc:: in
:type: counter
:oneliner: Input bytes
Total number of input bytes processed by the en-/decrypter
.. varnish_vsc_end:: ece .. varnish_vsc_end:: ece
...@@ -71,6 +71,8 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VfpAcct" { ...@@ -71,6 +71,8 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VfpAcct" {
} -run } -run
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 2 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 2
varnish v1 -expect ECE.vfp.ece_decrypt.in == 126
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
## Corner cases ## Corner cases
...@@ -130,6 +132,8 @@ client c1 { ...@@ -130,6 +132,8 @@ client c1 {
logexpect l1 -wait logexpect l1 -wait
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 3 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 3
varnish v1 -expect ECE.vfp.ece_decrypt.in == 147
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
## Errors ## Errors
...@@ -174,6 +178,8 @@ client c1 { ...@@ -174,6 +178,8 @@ client c1 {
logexpect l1 -wait logexpect l1 -wait
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 4 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 4
varnish v1 -expect ECE.vfp.ece_decrypt.in == 150
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
server s1 -wait server s1 -wait
server s1 { server s1 {
...@@ -191,6 +197,8 @@ client c1 { ...@@ -191,6 +197,8 @@ client c1 {
} -run } -run
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 5 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 5
varnish v1 -expect ECE.vfp.ece_decrypt.in == 150
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
server s1 -wait server s1 -wait
server s1 { server s1 {
...@@ -218,6 +226,8 @@ client c1 { ...@@ -218,6 +226,8 @@ client c1 {
logexpect l1 -wait logexpect l1 -wait
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 6 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 6
varnish v1 -expect ECE.vfp.ece_decrypt.in == 172
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
server s1 -wait server s1 -wait
server s1 { server s1 {
...@@ -237,6 +247,8 @@ client c1 { ...@@ -237,6 +247,8 @@ client c1 {
} -run } -run
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 7 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 7
varnish v1 -expect ECE.vfp.ece_decrypt.in == 193
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
server s1 -wait server s1 -wait
server s1 { server s1 {
...@@ -264,6 +276,8 @@ client c1 { ...@@ -264,6 +276,8 @@ client c1 {
logexpect l1 -wait logexpect l1 -wait
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 8 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 8
varnish v1 -expect ECE.vfp.ece_decrypt.in == 214
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
server s1 -wait server s1 -wait
server s1 { server s1 {
...@@ -291,6 +305,8 @@ client c1 { ...@@ -291,6 +305,8 @@ client c1 {
logexpect l1 -wait logexpect l1 -wait
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 9 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 9
varnish v1 -expect ECE.vfp.ece_decrypt.in == 235
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
server s1 -wait server s1 -wait
server s1 { server s1 {
...@@ -318,6 +334,8 @@ client c1 { ...@@ -318,6 +334,8 @@ client c1 {
logexpect l1 -wait logexpect l1 -wait
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 10 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 10
varnish v1 -expect ECE.vfp.ece_decrypt.in == 258
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
server s1 -wait server s1 -wait
server s1 { server s1 {
...@@ -347,6 +365,8 @@ client c1 { ...@@ -347,6 +365,8 @@ client c1 {
logexpect l1 -wait logexpect l1 -wait
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 11 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 11
varnish v1 -expect ECE.vfp.ece_decrypt.in == 279
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
server s1 -wait server s1 -wait
server s1 -start server s1 -start
...@@ -383,3 +403,5 @@ client c1 { ...@@ -383,3 +403,5 @@ client c1 {
logexpect l1 -wait logexpect l1 -wait
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 12 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 12
varnish v1 -expect ECE.vfp.ece_decrypt.in == 300
varnish v1 -expect ECE.vfp.ece_decrypt.out == 30
...@@ -151,6 +151,8 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VfpAcct" { ...@@ -151,6 +151,8 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VfpAcct" {
varnish v1 -expect ECE.vfp.ece_encrypt.ops == 6 varnish v1 -expect ECE.vfp.ece_encrypt.ops == 6
varnish v1 -expect ECE.vfp.ece_decrypt.ops == 6 varnish v1 -expect ECE.vfp.ece_decrypt.ops == 6
varnish v1 -expect ECE.vfp.ece_decrypt.in > 199975
varnish v1 -expect ECE.vfp.ece_decrypt.out == 199975
# Repeat the test with custom VFPs # Repeat the test with custom VFPs
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
......
...@@ -193,6 +193,27 @@ outputLen(struct ece_stream *stream, unsigned char *ptr) ...@@ -193,6 +193,27 @@ outputLen(struct ece_stream *stream, unsigned char *ptr)
return (stream->next_out - ptr); return (stream->next_out - ptr);
} }
static inline uint8_t *
hdrBufIn(struct ece_hdrbuf *hdr)
{
CHECK_OBJ_NOTNULL(hdr, ECE_HDRBUF_MAGIC);
return (hdr->next_in);
}
static inline uint8_t *
recBufIn(struct ece_stream *stream)
{
CHECK_OBJ_NOTNULL(stream, ECE_STREAM_MAGIC);
return (stream->rec_next);
}
static inline uint8_t *
streamIn(struct ece_stream *stream)
{
CHECK_OBJ_NOTNULL(stream, ECE_STREAM_MAGIC);
return (stream->next_in);
}
static inline void static inline void
seq_inc(struct ece_crypto *crypto) seq_inc(struct ece_crypto *crypto)
{ {
......
...@@ -287,20 +287,31 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr, ...@@ -287,20 +287,31 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
{ {
struct ece *ece; struct ece *ece;
struct ece_stream *stream; struct ece_stream *stream;
unsigned char *p = ptr; struct ece_hdrbuf *hdr;
const struct vfp_cfg *cfg;
struct VSC_ece *stats;
unsigned char *p = ptr, *inb4;
enum vfp_status vp = VFP_OK; enum vfp_status vp = VFP_OK;
CHECK_OBJ_NOTNULL(ctx, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VFP_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ent, VFP_ENTRY_MAGIC); CHECK_OBJ_NOTNULL(ent, VFP_ENTRY_MAGIC);
CAST_OBJ_NOTNULL(ece, ent->priv1, ECE_MAGIC); CAST_OBJ_NOTNULL(ece, ent->priv1, ECE_MAGIC);
CHECK_OBJ_NOTNULL(ece->stream, ECE_STREAM_MAGIC); CHECK_OBJ_NOTNULL(ece->stream, ECE_STREAM_MAGIC);
CHECK_OBJ_NOTNULL(ece->hdr, ECE_HDRBUF_MAGIC);
AN(ent->vfp);
CAST_OBJ_NOTNULL(cfg, ent->vfp->priv1, VFP_CFG_MAGIC);
AN(ptr); AN(ptr);
AN(lenp); AN(lenp);
assert(*lenp >= 0); assert(*lenp >= 0);
stream = ece->stream; stream = ece->stream;
hdr = ece->hdr;
stats = cfg->stats;
if (ece->rs == 0) { if (ece->rs == 0) {
inb4 = hdrBufIn(hdr);
vp = decrypt_init(ctx, ece, ent); vp = decrypt_init(ctx, ece, ent);
if (stats != NULL)
stats->in += hdrBufIn(hdr) - inb4;
if (vp == VFP_ERROR) if (vp == VFP_ERROR)
return (vp); return (vp);
if (vp == VFP_NULL) { if (vp == VFP_NULL) {
...@@ -320,9 +331,14 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr, ...@@ -320,9 +331,14 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
AN(ece->buf); AN(ece->buf);
setOutputBuf(stream, ptr, *lenp); setOutputBuf(stream, ptr, *lenp);
inb4 = recBufIn(stream);
flushRecBuf(stream); flushRecBuf(stream);
if (stats != NULL)
stats->in += recBufIn(stream) - inb4;
if (isOutputBufFull(stream)) { if (isOutputBufFull(stream)) {
*lenp = outputLen(stream, p); *lenp = outputLen(stream, p);
if (stats != NULL)
stats->out += *lenp;
return (VFP_OK); return (VFP_OK);
} }
...@@ -335,7 +351,10 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr, ...@@ -335,7 +351,10 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
setInputBuf(stream, ece->buf, len); setInputBuf(stream, ece->buf, len);
} }
if (!isInputBufEmpty(stream)) { if (!isInputBufEmpty(stream)) {
inb4 = streamIn(stream);
vp = decrypt(ctx, ece, vp); vp = decrypt(ctx, ece, vp);
if (stats != NULL)
stats->in += streamIn(stream) - inb4;
if (vp == VFP_ERROR) if (vp == VFP_ERROR)
return (vp); return (vp);
} }
...@@ -343,6 +362,8 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr, ...@@ -343,6 +362,8 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
ERR(ctx, "message truncated"); ERR(ctx, "message truncated");
*lenp = outputLen(stream, p); *lenp = outputLen(stream, p);
if (stats != NULL)
stats->out += *lenp;
return (vp); return (vp);
} }
......
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