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
3f077667
Commit
3f077667
authored
Jan 29, 2021
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Teach Conn_pool to send preamble, vcc to configure it and test that it works.
parent
d87c71cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
1 deletion
+53
-1
cache_conn_pool.c
bin/varnishd/cache/cache_conn_pool.c
+16
-1
b00075.vtc
bin/varnishtest/tests/b00075.vtc
+27
-0
vcc_backend.c
lib/libvcc/vcc_backend.c
+10
-0
No files found.
bin/varnishd/cache/cache_conn_pool.c
View file @
3f077667
...
...
@@ -343,9 +343,20 @@ VCP_Open(struct conn_pool *cp, vtim_dur tmo, VCL_IP *ap, int *err)
return
(
-
1
);
}
*
err
=
errno
=
0
;
r
=
cp
->
methods
->
open
(
cp
,
tmo
,
ap
);
*
err
=
errno
;
if
(
r
>=
0
&&
errno
==
0
&&
cp
->
endpoint
->
preamble
!=
NULL
&&
cp
->
endpoint
->
preamble
->
len
>
0
)
{
if
(
write
(
r
,
cp
->
endpoint
->
preamble
->
blob
,
cp
->
endpoint
->
preamble
->
len
)
!=
cp
->
endpoint
->
preamble
->
len
)
{
*
err
=
errno
;
closefd
(
&
r
);
}
}
else
{
*
err
=
errno
;
}
if
(
r
>=
0
)
return
(
r
);
...
...
@@ -701,6 +712,10 @@ VCP_Ref(const struct vrt_endpoint *vep, const char *ident)
VSHA256_Update
(
cx
,
vep
->
ipv6
,
vsa_suckaddr_len
);
}
}
if
(
vep
->
preamble
!=
NULL
&&
vep
->
preamble
->
len
>
0
)
{
VSHA256_Update
(
cx
,
"PRE"
,
4
);
// include \0
VSHA256_Update
(
cx
,
vep
->
preamble
->
blob
,
vep
->
preamble
->
len
);
}
VSHA256_Final
(
digest
,
cx
);
/*
...
...
bin/varnishtest/tests/b00075.vtc
0 → 100644
View file @
3f077667
varnishtest "Test backend preamble"
server s1 {
rxreq
expect req.method == "POST"
expect req.url == "/preamble"
expect req.proto == "HTTP/7.3"
expect req.http.Header == "42"
rxreq
expect req.method == "GET"
expect req.url == "/"
expect req.proto == "HTTP/1.1"
txresp
} -start
varnish v1 -vcl {
backend s1 {
.host = "${s1_sock}";
.preamble = :UE9TVCAvcHJlYW1ibGUgSFRUUC83LjMKSGVhZGVyOiA0MgoKCg==: ;
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
} -run
lib/libvcc/vcc_backend.c
View file @
3f077667
...
...
@@ -339,6 +339,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
const
struct
token
*
t_path
=
NULL
;
const
struct
token
*
t_hosthdr
=
NULL
;
const
struct
token
*
t_did
=
NULL
;
const
struct
token
*
t_preamble
=
NULL
;
struct
symbol
*
pb
;
struct
fld_spec
*
fs
;
struct
inifin
*
ifp
;
...
...
@@ -382,6 +383,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
"?probe"
,
"?max_connections"
,
"?proxy_header"
,
"?preamble"
,
NULL
);
tl
->
fb
=
VSB_new_auto
();
...
...
@@ -497,6 +499,11 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
vcc_ErrWhere
(
tl
,
tl
->
t
);
VSB_destroy
(
&
tl
->
fb
);
return
;
}
else
if
(
vcc_IdIs
(
t_field
,
"preamble"
))
{
ExpectErr
(
tl
,
CBLOB
);
t_preamble
=
tl
->
t
;
vcc_NextToken
(
tl
);
SkipToken
(
tl
,
';'
);
}
else
{
ErrInternal
(
tl
);
VSB_destroy
(
&
tl
->
fb
);
...
...
@@ -534,6 +541,9 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
Emit_UDS_Path
(
tl
,
vsb1
,
t_path
,
"Backend path"
);
ERRCHK
(
tl
);
if
(
t_preamble
!=
NULL
)
VSB_printf
(
vsb1
,
"
\t
.preamble = %s,
\n
"
,
t_preamble
->
dec
);
VSB_printf
(
vsb1
,
"};
\n
"
);
AZ
(
VSB_finish
(
vsb1
));
Fh
(
tl
,
0
,
"%s"
,
VSB_data
(
vsb1
));
...
...
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