Commit cd3e4c61 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

We no longer use "anon" ACL's to compare VCL_IP

parent 3514c817
...@@ -422,7 +422,7 @@ vcc_acl_entry(struct vcc *tl) ...@@ -422,7 +422,7 @@ vcc_acl_entry(struct vcc *tl)
*/ */
static void static void
vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon) vcc_acl_emit(struct vcc *tl, const char *name, const char *rname)
{ {
struct acl_e *ae; struct acl_e *ae;
int depth, l, m, i; int depth, l, m, i;
...@@ -433,7 +433,7 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon) ...@@ -433,7 +433,7 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon)
func = VSB_new_auto(); func = VSB_new_auto();
AN(func); AN(func);
VSB_printf(func, "match_acl_%s_", anon ? "anon" : "named"); VSB_printf(func, "match_acl_");
VCC_PrintCName(func, name, NULL); VCC_PrintCName(func, name, NULL);
AZ(VSB_finish(func)); AZ(VSB_finish(func));
...@@ -448,7 +448,7 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon) ...@@ -448,7 +448,7 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon)
Fh(tl, 0, "\t\tVPI_acl_log(ctx, \"NO_FAM %s\");\n", name); Fh(tl, 0, "\t\tVPI_acl_log(ctx, \"NO_FAM %s\");\n", name);
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");
if (!tl->err_unref && !anon) { if (!tl->err_unref) {
ifp = New_IniFin(tl); ifp = New_IniFin(tl);
VSB_printf(ifp->ini, VSB_printf(ifp->ini,
"\tif (0) %s(0, 0);\n", VSB_data(func)); "\tif (0) %s(0, 0);\n", VSB_data(func));
...@@ -498,27 +498,25 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon) ...@@ -498,27 +498,25 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon)
i = ((int)ae->mask + 7) / 8; i = ((int)ae->mask + 7) / 8;
if (!anon) { Fh(tl, 0, "\t%*sVPI_acl_log(ctx, \"%sMATCH %s \" ",
Fh(tl, 0, "\t%*sVPI_acl_log(ctx, \"%sMATCH %s \" ", -i, "", ae->not ? "NEG_" : "", name);
-i, "", ae->not ? "NEG_" : "", name); t = ae->t_addr;
t = ae->t_addr; do {
do { if (t->tok == CSTR) {
if (t->tok == CSTR) { Fh(tl, 0, " \"\\\"\" ");
Fh(tl, 0, " \"\\\"\" "); EncToken(tl->fh, t);
EncToken(tl->fh, t); Fh(tl, 0, " \"\\\"\" ");
Fh(tl, 0, " \"\\\"\" "); } else
} else Fh(tl, 0, " \"%.*s\"", PF(t));
Fh(tl, 0, " \"%.*s\"", PF(t)); if (t == ae->t_mask)
if (t == ae->t_mask) break;
break; t = VTAILQ_NEXT(t, list);
t = VTAILQ_NEXT(t, list); AN(t);
AN(t); } while (ae->t_mask != NULL);
} while (ae->t_mask != NULL); if (ae->fixed)
if (ae->fixed) Fh(tl, 0, "\" fixed: %s\"",
Fh(tl, 0, "\" fixed: %s\"", ae->fixed);
ae->fixed); Fh(tl, 0, ");\n");
Fh(tl, 0, ");\n");
}
Fh(tl, 0, "\t%*sreturn (%d);\n", -i, "", ae->not ? 0 : 1); Fh(tl, 0, "\t%*sreturn (%d);\n", -i, "", ae->not ? 0 : 1);
} }
...@@ -528,18 +526,15 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon) ...@@ -528,18 +526,15 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon)
Fh(tl, 0, "\t%*.*s}\n", depth, depth, ""); Fh(tl, 0, "\t%*.*s}\n", depth, depth, "");
/* Deny by default */ /* Deny by default */
if (!anon) Fh(tl, 0, "\tVPI_acl_log(ctx, \"NO_MATCH %s\");\n", name);
Fh(tl, 0, "\tVPI_acl_log(ctx, \"NO_MATCH %s\");\n", name);
Fh(tl, 0, "\treturn (0);\n}\n"); Fh(tl, 0, "\treturn (0);\n}\n");
if (!anon) { /* Emit the struct that will be referenced */
/* Emit the struct that will be referenced */ Fh(tl, 0, "\nconst struct vrt_acl %s[] = {{\n", rname);
Fh(tl, 0, "\nconst struct vrt_acl %s[] = {{\n", rname); Fh(tl, 0, "\t.magic = VRT_ACL_MAGIC,\n");
Fh(tl, 0, "\t.magic = VRT_ACL_MAGIC,\n"); Fh(tl, 0, "\t.match = &%s,\n", VSB_data(func));
Fh(tl, 0, "\t.match = &%s,\n", VSB_data(func)); Fh(tl, 0, "\t.name = \"%s\",\n", name);
Fh(tl, 0, "\t.name = \"%s\",\n", name); Fh(tl, 0, "}};\n\n");
Fh(tl, 0, "}};\n\n");
}
VSB_destroy(&func); VSB_destroy(&func);
} }
...@@ -566,5 +561,5 @@ vcc_ParseAcl(struct vcc *tl) ...@@ -566,5 +561,5 @@ vcc_ParseAcl(struct vcc *tl)
} }
SkipToken(tl, '}'); SkipToken(tl, '}');
vcc_acl_emit(tl, sym->name, sym->rname, 0); vcc_acl_emit(tl, sym->name, sym->rname);
} }
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