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
2314365f
Commit
2314365f
authored
Aug 06, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the way VCC emit sockaddr's, explain why.
parent
b3a2823c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
22 deletions
+34
-22
cache_backend_cfg.c
bin/varnishd/cache/cache_backend_cfg.c
+5
-5
vrt.h
include/vrt.h
+2
-2
vcc_backend.c
lib/libvcl/vcc_backend.c
+27
-15
No files found.
bin/varnishd/cache/cache_backend_cfg.c
View file @
2314365f
...
...
@@ -150,13 +150,13 @@ VBE_DropRefConn(struct backend *b)
*/
static
void
copy_sockaddr
(
struct
sockaddr_storage
**
sa
,
const
unsigned
char
*
src
)
copy_sockaddr
(
struct
sockaddr_storage
**
sa
,
const
void
*
src
)
{
assert
(
*
src
>
0
);
assert
(
VSA_Sane
(
src
)
);
*
sa
=
calloc
(
sizeof
**
sa
,
1
);
XXXAN
(
*
sa
);
memcpy
(
*
sa
,
src
+
1
,
*
src
);
memcpy
(
*
sa
,
src
,
VSA_Len
(
src
)
);
assert
(
VSA_Sane
(
*
sa
));
}
...
...
@@ -183,10 +183,10 @@ VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb)
if
(
strcmp
(
b
->
vcl_name
,
vb
->
vcl_name
))
continue
;
if
(
vb
->
ipv4_sockaddr
!=
NULL
&&
VSA_Compare
(
b
->
ipv4
,
vb
->
ipv4_sockaddr
+
1
))
VSA_Compare
(
b
->
ipv4
,
vb
->
ipv4_sockaddr
))
continue
;
if
(
vb
->
ipv6_sockaddr
!=
NULL
&&
VSA_Compare
(
b
->
ipv6
,
vb
->
ipv6_sockaddr
+
1
))
VSA_Compare
(
b
->
ipv6
,
vb
->
ipv6_sockaddr
))
continue
;
b
->
refcount
++
;
b
->
vsc
->
vcls
++
;
...
...
include/vrt.h
View file @
2314365f
...
...
@@ -124,8 +124,8 @@ struct vrt_backend {
const
char
*
ipv6_addr
;
const
char
*
port
;
const
unsigned
char
*
ipv4_sockaddr
;
const
unsigned
char
*
ipv6_sockaddr
;
const
void
*
ipv4_sockaddr
;
const
void
*
ipv6_sockaddr
;
const
char
*
hosthdr
;
...
...
lib/libvcl/vcc_backend.c
View file @
2314365f
...
...
@@ -61,6 +61,7 @@
#include "vcc_compile.h"
#include "vss.h"
#include "vsa.h"
struct
host
{
VTAILQ_ENTRY
(
host
)
list
;
...
...
@@ -68,27 +69,38 @@ struct host {
char
*
vgcname
;
};
/*
* The IPv6 crew royally screwed up the entire idea behind
* struct sockaddr, and combined with various other incomptency
* in the OS business, that means that there is no sane or even
* remotely portable way to initialize a sockaddr at compile time.
*
* In our case it is slightly more tricky than that, because we don't
* even want to #include the struct sockaddr* definitions.
*
* Instead we make sure the sockaddr is sane (for our values of sane)
* and dump it in binary, using a 64 bit integertype, hoping that this
* will ensure good enough alignment.
*/
static
int
emit_sockaddr
(
struct
vcc
*
tl
,
void
*
sa
,
unsigned
sal
)
emit_sockaddr
(
struct
vcc
*
tl
,
const
void
*
sa
,
unsigned
sal
)
{
unsigned
len
;
uint
8_t
*
u
;
unsigned
n
=
(
sal
+
7
)
/
8
,
len
;
uint
64_t
b
[
n
]
;
assert
(
VSA_Sane
(
sa
));
AN
(
sa
);
AN
(
sal
);
assert
(
sal
<
256
);
Fh
(
tl
,
0
,
"
\n
static const unsigned char sockaddr_%u[%d] = {
\n
"
,
tl
->
unique
,
sal
+
1
);
Fh
(
tl
,
0
,
" %3u, /* Length */
\n
"
,
sal
);
u
=
sa
;
for
(
len
=
0
;
len
<
sal
;
len
++
)
{
if
((
len
%
8
)
==
0
)
Fh
(
tl
,
0
,
" "
);
Fh
(
tl
,
0
,
" %3u"
,
u
[
len
]);
if
(
len
+
1
<
sal
)
Fh
(
tl
,
0
,
","
);
if
((
len
%
8
)
==
7
)
Fh
(
tl
,
0
,
"
\n
"
);
assert
(
sizeof
(
unsigned
long
long
)
==
8
);
Fh
(
tl
,
0
,
"
\n
static const unsigned long long"
);
Fh
(
tl
,
0
,
" sockaddr_%u[%d] = {
\n
"
,
tl
->
unique
,
n
);
memcpy
(
b
,
sa
,
sal
);
for
(
len
=
0
;
len
<
n
;
len
++
)
{
Fh
(
tl
,
0
,
"%s 0x%016jx"
,
len
?
",
\n
"
:
""
,
(
uintmax_t
)
b
[
len
]);
}
Fh
(
tl
,
0
,
"
\n
};
\n
"
);
return
(
tl
->
unique
++
);
...
...
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