Commit 1c759b87 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move acls to vrt_ctx

parent 2e3b542d
...@@ -98,10 +98,11 @@ VRT_count(const struct vrt_ctx *ctx, unsigned u) ...@@ -98,10 +98,11 @@ VRT_count(const struct vrt_ctx *ctx, unsigned u)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void void
VRT_acl_log(struct req *req, const char *msg) VRT_acl_log(const struct vrt_ctx *ctx, const char *msg)
{ {
VSLb(req->vsl, SLT_VCL_acl, "%s", msg); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
VSLb(ctx->vsl, SLT_VCL_acl, "%s", msg);
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
......
...@@ -182,7 +182,7 @@ struct vrt_ref { ...@@ -182,7 +182,7 @@ struct vrt_ref {
/* ACL related */ /* ACL related */
#define VRT_ACL_MAXADDR 16 /* max(IPv4, IPv6) */ #define VRT_ACL_MAXADDR 16 /* max(IPv4, IPv6) */
void VRT_acl_log(struct req *, const char *msg); void VRT_acl_log(const struct vrt_ctx *, const char *msg);
/* req related */ /* req related */
......
...@@ -357,7 +357,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon) ...@@ -357,7 +357,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon)
const char *oc; const char *oc;
Fh(tl, 0, "\nstatic int\n"); Fh(tl, 0, "\nstatic int\n");
Fh(tl, 0, "match_acl_%s_%s(struct req *req, const void *p)\n", Fh(tl, 0, "match_acl_%s_%s(const struct vrt_ctx *ctx, const void *p)\n",
anon ? "anon" : "named", acln); anon ? "anon" : "named", acln);
Fh(tl, 0, "{\n"); Fh(tl, 0, "{\n");
Fh(tl, 0, "\tconst unsigned char *a;\n"); Fh(tl, 0, "\tconst unsigned char *a;\n");
...@@ -372,7 +372,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon) ...@@ -372,7 +372,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon)
Fh(tl, 0, "\telse if (fam == %d)\n", PF_INET6); Fh(tl, 0, "\telse if (fam == %d)\n", PF_INET6);
Fh(tl, 0, "\t\ta += %zd;\n", offsetof(struct sockaddr_in6, sin6_addr)); Fh(tl, 0, "\t\ta += %zd;\n", offsetof(struct sockaddr_in6, sin6_addr));
Fh(tl, 0, "\telse {\n"); Fh(tl, 0, "\telse {\n");
Fh(tl, 0, "\t\tVRT_acl_log(req, \"NO_FAM %s\");\n", acln); Fh(tl, 0, "\t\tVRT_acl_log(ctx, \"NO_FAM %s\");\n", acln);
Fh(tl, 0, "\t\treturn(0);\n"); Fh(tl, 0, "\t\treturn(0);\n");
Fh(tl, 0, "\t}\n\n"); Fh(tl, 0, "\t}\n\n");
depth = -1; depth = -1;
...@@ -424,7 +424,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon) ...@@ -424,7 +424,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon)
i = (ae->mask + 7) / 8; i = (ae->mask + 7) / 8;
if (!anon) { if (!anon) {
Fh(tl, 0, "\t%*sVRT_acl_log(req, \"%sMATCH %s \" ", Fh(tl, 0, "\t%*sVRT_acl_log(ctx, \"%sMATCH %s \" ",
-i, "", ae->not ? "NEG_" : "", acln); -i, "", ae->not ? "NEG_" : "", acln);
EncToken(tl->fh, ae->t_addr); EncToken(tl->fh, ae->t_addr);
if (ae->t_mask != NULL) if (ae->t_mask != NULL)
...@@ -441,7 +441,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon) ...@@ -441,7 +441,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon)
/* Deny by default */ /* Deny by default */
if (!anon) if (!anon)
Fh(tl, 0, "\tVRT_acl_log(req, \"NO_MATCH %s\");\n", acln); Fh(tl, 0, "\tVRT_acl_log(ctx, \"NO_MATCH %s\");\n", acln);
Fh(tl, 0, "\treturn (0);\n}\n"); Fh(tl, 0, "\treturn (0);\n}\n");
} }
...@@ -457,7 +457,7 @@ vcc_Acl_Hack(struct vcc *tl, char *b) ...@@ -457,7 +457,7 @@ vcc_Acl_Hack(struct vcc *tl, char *b)
bprintf(acln, "%u", tl->unique++); bprintf(acln, "%u", tl->unique++);
vcc_acl_entry(tl); vcc_acl_entry(tl);
vcc_acl_emit(tl, acln, 1); vcc_acl_emit(tl, acln, 1);
sprintf(b, "%smatch_acl_anon_%s(req, \v1)", sprintf(b, "%smatch_acl_anon_%s(ctx, \v1)",
(tcond == T_NEQ ? "!" : ""), acln); (tcond == T_NEQ ? "!" : ""), acln);
} }
......
...@@ -1012,7 +1012,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt) ...@@ -1012,7 +1012,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt)
vcc_NextToken(tl); vcc_NextToken(tl);
ExpectErr(tl, ID); ExpectErr(tl, ID);
vcc_AddRef(tl, tl->t, SYM_ACL); vcc_AddRef(tl, tl->t, SYM_ACL);
bprintf(buf, "%smatch_acl_named_%.*s(req, \v1)", bprintf(buf, "%smatch_acl_named_%.*s(ctx, \v1)",
not, PF(tl->t)); not, PF(tl->t));
vcc_NextToken(tl); vcc_NextToken(tl);
*e = vcc_expr_edit(BOOL, buf, *e, NULL); *e = vcc_expr_edit(BOOL, buf, *e, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment