[master] c984e5d Look for VFP's also on the per-vcl list
Poul-Henning Kamp
phk at FreeBSD.org
Thu Apr 19 12:45:19 UTC 2018
commit c984e5d39f6a8f4ad34aa80c8a4519b35bedde5c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Apr 19 12:37:36 2018 +0000
Look for VFP's also on the per-vcl list
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 4e074c7..487807c 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -606,7 +606,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
}
if (bo->filter_list == NULL ||
- VCL_StackVFP(bo->vfc, bo->filter_list)) {
+ VCL_StackVFP(bo->vfc, bo->vcl, bo->filter_list)) {
(bo)->htc->doclose = SC_OVERLOAD;
VDI_Finish((bo)->wrk, bo);
return (F_STP_ERROR);
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index c859324..bec82c1 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -407,7 +407,7 @@ int VCL_IterDirector(struct cli *, const char *, vcl_be_func *, void *);
/* cache_vcl_vrt.c */
void VCL_VRT_Init(void);
-int VCL_StackVFP(struct vfp_ctx *, const char *);
+int VCL_StackVFP(struct vfp_ctx *, const struct vcl *, const char *);
/* cache_vrt.c */
void VRTPRIV_init(struct vrt_privs *privs);
diff --git a/bin/varnishd/cache/cache_vcl_vrt.c b/bin/varnishd/cache/cache_vcl_vrt.c
index c29e689..36bdf3f 100644
--- a/bin/varnishd/cache/cache_vcl_vrt.c
+++ b/bin/varnishd/cache/cache_vcl_vrt.c
@@ -470,7 +470,7 @@ VRT_RemoveVFP(VRT_CTX, const struct vfp *filter)
}
int
-VCL_StackVFP(struct vfp_ctx *vc, const char *fl)
+VCL_StackVFP(struct vfp_ctx *vc, const struct vcl *vcl, const char *fl)
{
const char *p, *q;
const struct vfp_filter *vp;
@@ -491,6 +491,14 @@ VCL_StackVFP(struct vfp_ctx *vc, const char *fl)
if (!memcmp(p, vp->filter->name, vp->nlen))
break;
}
+ if (vp == NULL) {
+ VTAILQ_FOREACH(vp, &vcl->vfps, list) {
+ if (vp->nlen != q - p)
+ continue;
+ if (!memcmp(p, vp->filter->name, vp->nlen))
+ break;
+ }
+ }
if (vp == NULL)
return (VFP_Error(vc,
"Filter '%.*s' not found", (int)(q-p), p));
diff --git a/bin/varnishtest/tests/m00048.vtc b/bin/varnishtest/tests/m00048.vtc
new file mode 100644
index 0000000..9f01bf5
--- /dev/null
+++ b/bin/varnishtest/tests/m00048.vtc
@@ -0,0 +1,21 @@
+varnishtest "VMOD vfp"
+
+server s1 {
+ rxreq
+ txresp -body "Ponto Facto, Caesar Transit!"
+} -start
+
+varnish v1 -vcl+backend {
+ import debug;
+
+ sub vcl_backend_response {
+ set beresp.filters = "rot13";
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.body == "Cbagb Snpgb, Pnrfne Genafvg!"
+} -run
+
More information about the varnish-commit
mailing list