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
3c11cfd2
Commit
3c11cfd2
authored
Feb 23, 2016
by
Dridi Boukelmoune
Committed by
Lasse Karstensen
Feb 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make named ACLs available to VMODs
parent
c4c50274
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
9 deletions
+46
-9
vmod.rst
doc/sphinx/reference/vmod.rst
+4
-1
vcc_acl.c
lib/libvcc/vcc_acl.c
+11
-4
vcc_compile.h
lib/libvcc/vcc_compile.h
+1
-0
vcc_expr.c
lib/libvcc/vcc_expr.c
+29
-4
vmodtool.py
lib/libvcc/vmodtool.py
+1
-0
No files found.
doc/sphinx/reference/vmod.rst
View file @
3c11cfd2
...
@@ -115,7 +115,10 @@ language representation. Here is a description of them.
...
@@ -115,7 +115,10 @@ language representation. Here is a description of them.
All but the PRIV and STRING_LIST types have typedefs: VCL_INT, VCL_REAL,
All but the PRIV and STRING_LIST types have typedefs: VCL_INT, VCL_REAL,
etc.
etc.
.. TODO document ACL if patchwork #314 is merged
ACL
C-type: ``const struct vrt_acl *``
A type for named ACLs declared in VCL.
BACKEND
BACKEND
C-type: ``const struct director *``
C-type: ``const struct director *``
...
...
lib/libvcc/vcc_acl.c
View file @
3c11cfd2
...
@@ -474,7 +474,7 @@ void
...
@@ -474,7 +474,7 @@ void
vcc_ParseAcl
(
struct
vcc
*
tl
)
vcc_ParseAcl
(
struct
vcc
*
tl
)
{
{
struct
token
*
an
;
struct
token
*
an
;
int
i
;
struct
symbol
*
sym
;
char
acln
[
1024
];
char
acln
[
1024
];
vcc_NextToken
(
tl
);
vcc_NextToken
(
tl
);
...
@@ -490,13 +490,20 @@ vcc_ParseAcl(struct vcc *tl)
...
@@ -490,13 +490,20 @@ vcc_ParseAcl(struct vcc *tl)
an
=
tl
->
t
;
an
=
tl
->
t
;
vcc_NextToken
(
tl
);
vcc_NextToken
(
tl
);
i
=
vcc_AddDef
(
tl
,
an
,
SYM_ACL
);
bprintf
(
acln
,
"%.*s"
,
PF
(
an
));
if
(
i
>
1
)
{
sym
=
VCC_GetSymbolTok
(
tl
,
an
,
SYM_ACL
);
AN
(
sym
);
if
(
sym
->
ndef
>
0
)
{
VSB_printf
(
tl
->
sb
,
"ACL %.*s redefined
\n
"
,
PF
(
an
));
VSB_printf
(
tl
->
sb
,
"ACL %.*s redefined
\n
"
,
PF
(
an
));
vcc_ErrWhere
(
tl
,
an
);
vcc_ErrWhere
(
tl
,
an
);
return
;
return
;
}
}
bprintf
(
acln
,
"%.*s"
,
PF
(
an
));
sym
->
fmt
=
ACL
;
sym
->
eval
=
vcc_Eval_Acl
;
sym
->
eval_priv
=
TlDup
(
tl
,
acln
);
sym
->
ndef
++
;
ERRCHK
(
tl
);
SkipToken
(
tl
,
'{'
);
SkipToken
(
tl
,
'{'
);
...
...
lib/libvcc/vcc_compile.h
View file @
3c11cfd2
...
@@ -288,6 +288,7 @@ sym_expr_t vcc_Eval_Var;
...
@@ -288,6 +288,7 @@ sym_expr_t vcc_Eval_Var;
sym_expr_t
vcc_Eval_SymFunc
;
sym_expr_t
vcc_Eval_SymFunc
;
void
vcc_Eval_Func
(
struct
vcc
*
tl
,
const
char
*
cfunc
,
const
char
*
extra
,
void
vcc_Eval_Func
(
struct
vcc
*
tl
,
const
char
*
cfunc
,
const
char
*
extra
,
const
char
*
name
,
const
char
*
args
);
const
char
*
name
,
const
char
*
args
);
sym_expr_t
vcc_Eval_Acl
;
sym_expr_t
vcc_Eval_Backend
;
sym_expr_t
vcc_Eval_Backend
;
sym_expr_t
vcc_Eval_Probe
;
sym_expr_t
vcc_Eval_Probe
;
...
...
lib/libvcc/vcc_expr.c
View file @
3c11cfd2
...
@@ -490,6 +490,24 @@ vcc_Eval_BoolConst(struct vcc *tl, struct expr **e, const struct symbol *sym)
...
@@ -490,6 +490,24 @@ vcc_Eval_BoolConst(struct vcc *tl, struct expr **e, const struct symbol *sym)
(
*
e
)
->
constant
=
EXPR_CONST
;
(
*
e
)
->
constant
=
EXPR_CONST
;
}
}
/*--------------------------------------------------------------------
*/
void
vcc_Eval_Acl
(
struct
vcc
*
tl
,
struct
expr
**
e
,
const
struct
symbol
*
sym
)
{
assert
(
sym
->
kind
==
SYM_ACL
);
AN
(
sym
->
eval_priv
);
vcc_ExpectCid
(
tl
);
vcc_AddRef
(
tl
,
tl
->
t
,
SYM_ACL
);
*
e
=
vcc_mk_expr
(
ACL
,
"&vrt_acl_named_%s"
,
(
const
char
*
)
sym
->
eval_priv
);
(
*
e
)
->
constant
=
EXPR_VAR
;
/* XXX ? */
vcc_NextToken
(
tl
);
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
*/
*/
...
@@ -498,6 +516,7 @@ vcc_Eval_Backend(struct vcc *tl, struct expr **e, const struct symbol *sym)
...
@@ -498,6 +516,7 @@ vcc_Eval_Backend(struct vcc *tl, struct expr **e, const struct symbol *sym)
{
{
assert
(
sym
->
kind
==
SYM_BACKEND
);
assert
(
sym
->
kind
==
SYM_BACKEND
);
AN
(
sym
->
eval_priv
);
vcc_ExpectCid
(
tl
);
vcc_ExpectCid
(
tl
);
vcc_AddRef
(
tl
,
tl
->
t
,
SYM_BACKEND
);
vcc_AddRef
(
tl
,
tl
->
t
,
SYM_BACKEND
);
...
@@ -800,6 +819,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
...
@@ -800,6 +819,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
struct
expr
*
e1
,
*
e2
;
struct
expr
*
e1
,
*
e2
;
const
char
*
ip
;
const
char
*
ip
;
const
struct
symbol
*
sym
;
const
struct
symbol
*
sym
;
enum
symkind
kind
;
double
d
;
double
d
;
int
i
;
int
i
;
...
@@ -819,10 +839,14 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
...
@@ -819,10 +839,14 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
* XXX: look for SYM_VAR first for consistency ?
* XXX: look for SYM_VAR first for consistency ?
*/
*/
sym
=
NULL
;
sym
=
NULL
;
if
(
fmt
==
BACKEND
)
switch
(
fmt
)
{
sym
=
VCC_FindSymbol
(
tl
,
tl
->
t
,
SYM_BACKEND
);
case
ACL
:
kind
=
SYM_ACL
;
break
;
if
(
fmt
==
PROBE
)
case
BACKEND
:
kind
=
SYM_BACKEND
;
break
;
sym
=
VCC_FindSymbol
(
tl
,
tl
->
t
,
SYM_PROBE
);
case
PROBE
:
kind
=
SYM_PROBE
;
break
;
default:
kind
=
SYM_NONE
;
break
;
}
if
(
kind
!=
SYM_NONE
)
sym
=
VCC_FindSymbol
(
tl
,
tl
->
t
,
kind
);
if
(
sym
==
NULL
)
if
(
sym
==
NULL
)
sym
=
VCC_FindSymbol
(
tl
,
tl
->
t
,
SYM_VAR
);
sym
=
VCC_FindSymbol
(
tl
,
tl
->
t
,
SYM_VAR
);
if
(
sym
==
NULL
)
if
(
sym
==
NULL
)
...
@@ -841,6 +865,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
...
@@ -841,6 +865,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
switch
(
sym
->
kind
)
{
switch
(
sym
->
kind
)
{
case
SYM_VAR
:
case
SYM_VAR
:
case
SYM_FUNC
:
case
SYM_FUNC
:
case
SYM_ACL
:
case
SYM_BACKEND
:
case
SYM_BACKEND
:
case
SYM_PROBE
:
case
SYM_PROBE
:
AN
(
sym
->
eval
);
AN
(
sym
->
eval
);
...
...
lib/libvcc/vmodtool.py
View file @
3c11cfd2
...
@@ -46,6 +46,7 @@ from os.path import dirname, realpath, exists
...
@@ -46,6 +46,7 @@ from os.path import dirname, realpath, exists
from
pprint
import
pprint
,
pformat
from
pprint
import
pprint
,
pformat
ctypes
=
{
ctypes
=
{
'ACL'
:
"VCL_ACL"
,
'BACKEND'
:
"VCL_BACKEND"
,
'BACKEND'
:
"VCL_BACKEND"
,
'BLOB'
:
"VCL_BLOB"
,
'BLOB'
:
"VCL_BLOB"
,
'BOOL'
:
"VCL_BOOL"
,
'BOOL'
:
"VCL_BOOL"
,
...
...
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