Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
29c0c571
Commit
29c0c571
authored
Mar 07, 2018
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement VCL var local.socket (VCL >= 4.1).
parent
b38c3d32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
18 deletions
+91
-18
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+24
-17
c00087.vtc
bin/varnishtest/tests/c00087.vtc
+5
-1
v00025.vtc
bin/varnishtest/tests/v00025.vtc
+62
-0
No files found.
bin/varnishd/cache/cache_vrt_var.c
View file @
29c0c571
...
...
@@ -745,26 +745,33 @@ GIP(client)
GIP
(
server
)
#undef GIP
/*--------------------------------------------------------------------*/
VCL_STRING
VRT_r_local_endpoint
(
VRT_CTX
)
{
struct
sess
*
sp
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
(
VALID_OBJ
(
ctx
->
req
,
REQ_MAGIC
))
sp
=
ctx
->
req
->
sp
;
else
{
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
sp
=
ctx
->
bo
->
sp
;
}
/*--------------------------------------------------------------------
* local.[endpoint|socket]
*/
CHECK_OBJ_NOTNULL
(
sp
->
listen_sock
,
LISTEN_SOCK_MAGIC
);
AN
(
sp
->
listen_sock
->
endpoint
);
return
(
sp
->
listen_sock
->
endpoint
);
#define LOC(var,fld) \
VCL_STRING \
VRT_r_local_##var(VRT_CTX) \
{ \
struct sess *sp; \
\
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
if (VALID_OBJ(ctx->req, REQ_MAGIC)) \
sp = ctx->req->sp; \
else { \
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \
sp = ctx->bo->sp; \
} \
\
CHECK_OBJ_NOTNULL(sp->listen_sock, LISTEN_SOCK_MAGIC); \
AN(sp->listen_sock->fld); \
return (sp->listen_sock->fld); \
}
LOC
(
endpoint
,
endpoint
)
LOC
(
socket
,
name
)
#undef LOC
/*--------------------------------------------------------------------*/
VCL_STRING
...
...
bin/varnishtest/tests/c00087.vtc
View file @
29c0c571
...
...
@@ -5,7 +5,7 @@ server s1 -listen "${tmpdir}/s1.sock" {
txresp
} -start
varnish v1 -syntax 4.1 -arg "-a ${tmpdir}/v1.sock" -vcl+backend {
varnish v1 -syntax 4.1 -arg "-a
foo=
${tmpdir}/v1.sock" -vcl+backend {
acl acl1 {
"${localhost}";
}
...
...
@@ -17,6 +17,7 @@ varnish v1 -syntax 4.1 -arg "-a ${tmpdir}/v1.sock" -vcl+backend {
set beresp.http.b-remote = remote.ip;
set beresp.http.b-compare = local.ip == remote.ip;
set beresp.http.b-endpoint = local.endpoint;
set beresp.http.b-socket = local.socket;
}
sub vcl_deliver {
...
...
@@ -30,6 +31,7 @@ varnish v1 -syntax 4.1 -arg "-a ${tmpdir}/v1.sock" -vcl+backend {
set resp.http.local_acl = local.ip ~ acl1;
set resp.http.remote_acl = remote.ip ~ acl1;
set resp.http.c-endpoint = local.endpoint;
set resp.http.c-socket = local.socket;
}
} -start
...
...
@@ -43,12 +45,14 @@ client c1 -connect "${tmpdir}/v1.sock" {
expect resp.http.c-remote == "0.0.0.0"
expect resp.http.c-compare == "true"
expect resp.http.c-endpoint == "${tmpdir}/v1.sock"
expect resp.http.c-socket == "foo"
expect resp.http.b-client == "0.0.0.0"
expect resp.http.b-server == "0.0.0.0"
expect resp.http.b-local == "0.0.0.0"
expect resp.http.b-remote == "0.0.0.0"
expect resp.http.b-compare == "true"
expect resp.http.b-endpoint == "${tmpdir}/v1.sock"
expect resp.http.b-socket == "foo"
expect resp.http.client_acl == "false"
expect resp.http.server_acl == "false"
expect resp.http.local_acl == "false"
...
...
bin/varnishtest/tests/v00025.vtc
View file @
29c0c571
...
...
@@ -118,15 +118,29 @@ varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'local.endpoint' (Only availab
}
}
varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'local.socket' (Only available when 4.1 <= VCL syntax)} {
sub vcl_recv {
set req.http.Socket = local.socket;
}
}
varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'local.socket' (Only available when 4.1 <= VCL syntax)} {
sub vcl_backend_fetch {
set bereq.http.Socket = local.socket;
}
}
varnish v1 -syntax 4.1 -vcl+backend {
sub vcl_backend_response {
set beresp.http.B-Sess-XID = sess.xid;
set beresp.http.B-Endpoint = local.endpoint;
set beresp.http.B-Socket = local.socket;
}
sub vcl_deliver {
set resp.http.C-Sess-XID = sess.xid;
set resp.http.C-Endpoint = local.endpoint;
set resp.http.C-Socket = local.socket;
}
}
...
...
@@ -139,4 +153,52 @@ client c1 {
expect resp.http.C-Sess-XID == resp.http.B-Sess-XID
expect resp.http.C-Endpoint == "${v1_addr}:${v1_port}"
expect resp.http.B-Endpoint == "${v1_addr}:${v1_port}"
expect resp.http.C-Socket == "a0"
expect resp.http.B-Socket == "a0"
} -run
varnish v1 -stop
server s1 {
rxreq
txresp
rxreq
txresp
} -start
varnish v2 -arg "-a foo=${tmpdir}/foo.sock -a bar=${tmpdir}/bar.sock" \
-syntax 4.1 -vcl+backend {
sub vcl_backend_response {
set beresp.http.B-Endpoint = local.endpoint;
set beresp.http.B-Socket = local.socket;
}
sub vcl_deliver {
set resp.http.C-Endpoint = local.endpoint;
set resp.http.C-Socket = local.socket;
}
} -start
client c2 -connect "${tmpdir}/foo.sock" {
txreq
rxresp
expect resp.status == 200
expect resp.http.C-Endpoint == "${tmpdir}/foo.sock"
expect resp.http.B-Endpoint == "${tmpdir}/foo.sock"
expect resp.http.C-Socket == "foo"
expect resp.http.B-Socket == "foo"
} -run
# The backend endpoint/socket may be either of the two possibilities,
# because the busyobj may point to the session started for the first
# fetch.
client c2 -connect "${tmpdir}/bar.sock" {
txreq
rxresp
expect resp.status == 200
expect resp.http.C-Endpoint == "${tmpdir}/bar.sock"
expect resp.http.B-Endpoint ~ "^${tmpdir}/(bar|foo).sock$"
expect resp.http.C-Socket == "bar"
expect resp.http.B-Socket ~ "^(bar|foo)$"
} -run
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment