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
91cacbcc
Commit
91cacbcc
authored
Jan 05, 2021
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let VTP hash the vrt_endpoint, and dont truncate the hash.
parent
f44b0c31
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
64 deletions
+54
-64
cache_backend.c
bin/varnishd/cache/cache_backend.c
+1
-25
cache_tcp_pool.c
bin/varnishd/cache/cache_tcp_pool.c
+48
-33
cache_tcp_pool.h
bin/varnishd/cache/cache_tcp_pool.h
+5
-6
No files found.
bin/varnishd/cache/cache_backend.c
View file @
91cacbcc
...
...
@@ -38,9 +38,7 @@
#include "cache_varnishd.h"
#include "vend.h"
#include "vsa.h"
#include "vsha256.h"
#include "vtcp.h"
#include "vtim.h"
...
...
@@ -555,27 +553,6 @@ VRT_backend_vsm_need(VRT_CTX)
return
(
VRT_VSC_Overhead
(
VSC_vbe_size
));
}
static
uint64_t
vrt_hash_be
(
const
struct
vrt_endpoint
*
vep
)
{
struct
VSHA256Context
cx
[
1
];
unsigned
char
ident
[
VSHA256_DIGEST_LENGTH
];
CHECK_OBJ_NOTNULL
(
vep
,
VRT_ENDPOINT_MAGIC
);
VSHA256_Init
(
cx
);
VSHA256_Update
(
cx
,
vbe_proto_ident
,
strlen
(
vbe_proto_ident
));
if
(
vep
->
ipv4
!=
NULL
)
VSHA256_Update
(
cx
,
vep
->
ipv4
,
vsa_suckaddr_len
);
if
(
vep
->
ipv6
!=
NULL
)
VSHA256_Update
(
cx
,
vep
->
ipv6
,
vsa_suckaddr_len
);
if
(
vep
->
uds_path
!=
NULL
)
VSHA256_Update
(
cx
,
vep
->
uds_path
,
strlen
(
vep
->
uds_path
));
if
(
vep
->
ident
!=
NULL
)
VSHA256_Update
(
cx
,
vep
->
ident
,
vep
->
ident_len
);
VSHA256_Final
(
ident
,
cx
);
return
(
vbe64dec
(
ident
));
}
VCL_BACKEND
VRT_new_backend_clustered
(
VRT_CTX
,
struct
vsmw_cluster
*
vc
,
const
struct
vrt_backend
*
vrt
)
...
...
@@ -634,8 +611,7 @@ VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc,
if
(
!
vcl
->
temp
->
is_warm
)
VRT_VSC_Hide
(
be
->
vsc_seg
);
be
->
tcp_pool
=
VTP_Ref
(
vep
->
ipv4
,
vep
->
ipv6
,
vep
->
uds_path
,
vrt_hash_be
(
vrt
->
endpoint
));
be
->
tcp_pool
=
VTP_Ref
(
vep
,
vbe_proto_ident
);
AN
(
be
->
tcp_pool
);
vbp
=
vrt
->
probe
;
...
...
bin/varnishd/cache/cache_tcp_pool.c
View file @
91cacbcc
...
...
@@ -37,7 +37,9 @@
#include "cache_varnishd.h"
#include "vend.h"
#include "vsa.h"
#include "vsha256.h"
#include "vtcp.h"
#include "vus.h"
#include "vtim.h"
...
...
@@ -85,7 +87,7 @@ struct conn_pool {
const
struct
cp_methods
*
methods
;
uintmax_t
id
;
char
ident
[
VSHA256_DIGEST_LENGTH
]
;
void
*
priv
;
VTAILQ_ENTRY
(
conn_pool
)
list
;
...
...
@@ -201,14 +203,14 @@ vcp_handle(struct waited *w, enum wait_event ev, vtim_real now)
*/
static
struct
conn_pool
*
VCP_Ref
(
uintmax_t
id
)
VCP_Ref
(
const
uint8_t
*
ident
)
{
struct
conn_pool
*
cp
;
Lck_Lock
(
&
conn_pools_mtx
);
VTAILQ_FOREACH
(
cp
,
&
conn_pools
,
list
)
{
assert
(
cp
->
refcnt
>
0
);
if
(
cp
->
id
!=
id
)
if
(
memcmp
(
ident
,
cp
->
ident
,
sizeof
cp
->
ident
)
)
continue
;
cp
->
refcnt
++
;
Lck_Unlock
(
&
conn_pools_mtx
);
...
...
@@ -222,8 +224,8 @@ VCP_Ref(uintmax_t id)
*/
static
void
*
VCP_New
(
struct
conn_pool
*
cp
,
uint
max_t
id
,
void
*
priv
,
const
struct
cp_methods
*
cm
)
VCP_New
(
struct
conn_pool
*
cp
,
uint
8_t
ident
[
VSHA256_DIGEST_LENGTH
]
,
void
*
priv
,
const
struct
cp_methods
*
cm
)
{
AN
(
cp
);
...
...
@@ -232,7 +234,7 @@ VCP_New(struct conn_pool *cp, uintmax_t id, void *priv,
AN
(
cm
->
close
);
INIT_OBJ
(
cp
,
CONN_POOL_MAGIC
);
cp
->
id
=
id
;
memcpy
(
cp
->
ident
,
ident
,
sizeof
cp
->
ident
)
;
cp
->
priv
=
priv
;
cp
->
methods
=
cm
;
cp
->
refcnt
=
1
;
...
...
@@ -672,31 +674,41 @@ static const struct cp_methods vus_methods = {
*/
struct
tcp_pool
*
VTP_Ref
(
const
struct
suckaddr
*
ip4
,
const
struct
suckaddr
*
ip6
,
const
char
*
uds
,
uintmax_t
id
)
VTP_Ref
(
const
struct
vrt_endpoint
*
vep
,
const
char
*
ident
)
{
struct
tcp_pool
*
tp
;
struct
conn_pool
*
cp
;
const
struct
cp_methods
*
methods
;
assert
((
uds
!=
NULL
&&
ip4
==
NULL
&&
ip6
==
NULL
)
||
(
uds
==
NULL
&&
(
ip4
!=
NULL
||
ip6
!=
NULL
)));
cp
=
VCP_Ref
(
id
);
if
(
cp
!=
NULL
)
{
tp
=
cp
->
priv
;
CHECK_OBJ_NOTNULL
(
tp
,
TCP_POOL_MAGIC
);
if
(
uds
!=
NULL
)
{
AN
(
tp
->
uds
);
AZ
(
strcmp
(
tp
->
uds
,
uds
));
struct
VSHA256Context
cx
[
1
];
unsigned
char
digest
[
VSHA256_DIGEST_LENGTH
];
CHECK_OBJ_NOTNULL
(
vep
,
VRT_ENDPOINT_MAGIC
);
AN
(
ident
);
VSHA256_Init
(
cx
);
VSHA256_Update
(
cx
,
ident
,
strlen
(
ident
)
+
1
);
// include \0
if
(
vep
->
uds_path
!=
NULL
)
{
AZ
(
vep
->
ipv4
);
AZ
(
vep
->
ipv6
);
VSHA256_Update
(
cx
,
"UDS"
,
4
);
// include \0
VSHA256_Update
(
cx
,
vep
->
uds_path
,
strlen
(
vep
->
uds_path
));
}
else
{
assert
(
vep
->
ipv4
!=
NULL
||
vep
->
ipv6
!=
NULL
);
if
(
vep
->
ipv4
!=
NULL
)
{
assert
(
VSA_Sane
(
vep
->
ipv4
));
VSHA256_Update
(
cx
,
"IP4"
,
4
);
// include \0
VSHA256_Update
(
cx
,
vep
->
ipv4
,
vsa_suckaddr_len
);
}
if
(
vep
->
ipv6
!=
NULL
)
{
assert
(
VSA_Sane
(
vep
->
ipv6
));
VSHA256_Update
(
cx
,
"IP6"
,
4
);
// include \0
VSHA256_Update
(
cx
,
vep
->
ipv6
,
vsa_suckaddr_len
);
}
if
(
ip4
!=
NULL
)
AZ
(
VSA_Compare
(
tp
->
ip4
,
ip4
));
if
(
ip6
!=
NULL
)
AZ
(
VSA_Compare
(
tp
->
ip6
,
ip6
));
return
(
cp
->
priv
);
}
VSHA256_Final
(
digest
,
cx
);
cp
=
VCP_Ref
(
digest
);
if
(
cp
!=
NULL
)
return
(
cp
->
priv
);
/*
* this is racy - we could end up with additional pools on the same id
...
...
@@ -704,18 +716,19 @@ VTP_Ref(const struct suckaddr *ip4, const struct suckaddr *ip6, const char *uds,
*/
ALLOC_OBJ
(
tp
,
TCP_POOL_MAGIC
);
AN
(
tp
);
if
(
uds
!=
NULL
)
{
if
(
vep
->
uds_path
!=
NULL
)
{
methods
=
&
vus_methods
;
tp
->
uds
=
strdup
(
uds
);
tp
->
uds
=
strdup
(
vep
->
uds_path
);
AN
(
tp
->
uds
);
}
else
{
methods
=
&
vtp_methods
;
if
(
ip
4
!=
NULL
)
tp
->
ip4
=
VSA_Clone
(
ip
4
);
if
(
ip
6
!=
NULL
)
tp
->
ip6
=
VSA_Clone
(
ip
6
);
if
(
vep
->
ipv
4
!=
NULL
)
tp
->
ip4
=
VSA_Clone
(
vep
->
ipv
4
);
if
(
vep
->
ipv
6
!=
NULL
)
tp
->
ip6
=
VSA_Clone
(
vep
->
ipv
6
);
}
return
(
VCP_New
(
tp
->
cp
,
id
,
tp
,
methods
));
return
(
VCP_New
(
tp
->
cp
,
digest
,
tp
,
methods
));
}
/*--------------------------------------------------------------------
...
...
@@ -824,7 +837,9 @@ VTP_panic(struct vsb *vsb, struct tcp_pool *tp)
if
(
PAN_dump_struct
(
vsb
,
tp
,
TCP_POOL_MAGIC
,
"tcp_pool"
))
return
;
VSB_printf
(
vsb
,
"id = 0x%jx,
\n
"
,
tp
->
cp
->
id
);
VSB_printf
(
vsb
,
"ident = "
);
VSB_quote
(
vsb
,
tp
->
cp
->
ident
,
VSHA256_DIGEST_LENGTH
,
VSB_QUOTE_HEX
);
VSB_printf
(
vsb
,
",
\n
"
);
if
(
tp
->
uds
)
VSB_printf
(
vsb
,
"uds = %s,
\n
"
,
tp
->
uds
);
if
(
tp
->
ip4
&&
VSA_Sane
(
tp
->
ip4
))
{
...
...
bin/varnishd/cache/cache_tcp_pool.h
View file @
91cacbcc
...
...
@@ -54,13 +54,12 @@ void PFD_RemoteName(const struct pfd *, char *, unsigned, char *, unsigned);
struct
VSC_vbe
;
struct
tcp_pool
*
VTP_Ref
(
const
struct
suckaddr
*
ip4
,
const
struct
suckaddr
*
ip6
,
const
char
*
uds
,
uintmax_t
id
);
struct
tcp_pool
*
VTP_Ref
(
const
struct
vrt_endpoint
*
,
const
char
*
ident
);
/*
* Get a reference to a TCP pool. Either one or both of ip4 or
* ip6 arg must be non-NULL, or uds must be non-NULL. If recycling
* is to be used, the id
pointer distinguishes the pool per
*
protocol
.
* Get a reference to a TCP pool. Either one or both of ip
v
4 or
* ip
v
6 arg must be non-NULL, or uds must be non-NULL. If recycling
* is to be used, the id
ent pointer distinguishes the pool from
*
other pools with same {ipv4, ipv6, uds}
.
*/
void
VTP_AddRef
(
struct
tcp_pool
*
);
...
...
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