[master] d89674d12 Collapse vcc_acl_add_entry() and vcc_acl_insert_entry()
Poul-Henning Kamp
phk at FreeBSD.org
Mon Apr 12 12:09:05 UTC 2021
commit d89674d129ef0ed1c495e1169f83ec3203db1b42
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Apr 12 10:49:30 2021 +0000
Collapse vcc_acl_add_entry() and vcc_acl_insert_entry()
diff --git a/lib/libvcc/flint.lnt b/lib/libvcc/flint.lnt
index 22852628c..4e90fc671 100644
--- a/lib/libvcc/flint.lnt
+++ b/lib/libvcc/flint.lnt
@@ -4,6 +4,7 @@
-sem(vcc_new_source, custodial(1))
+-sem(acl_tree_VRBT_INSERT, custodial(2))
-emacro(835, EXPR_VAR) // Info 835: A zero has been given as right argument to operator '<<'
-esym(755, VCL_40) // Not used (right now)
diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c
index 08f8a135f..6f2c2c923 100644
--- a/lib/libvcc/vcc_acl.c
+++ b/lib/libvcc/vcc_acl.c
@@ -181,30 +181,11 @@ vcc_acl_chk(struct vcc *tl, const struct acl_e *ae, const int l,
return (strdup(t));
}
-static void
-vcc_acl_insert_entry(struct vcc *tl, struct acl_e **aenp)
-{
- struct acl_e *ae2;
-
- CHECK_OBJ_NOTNULL(*aenp, VCC_ACL_E_MAGIC);
- ae2 = VRBT_INSERT(acl_tree, &tl->acl->acl_tree, *aenp);
- if (ae2 != NULL) {
- if (ae2->not != (*aenp)->not) {
- VSB_cat(tl->sb, "Conflicting ACL entries:\n");
- vcc_ErrWhere(tl, ae2->t_addr);
- VSB_cat(tl->sb, "vs:\n");
- vcc_ErrWhere(tl, (*aenp)->t_addr);
- }
- return;
- }
- *aenp = NULL;
-}
-
static void
vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l,
unsigned char *u, int fam)
{
- struct acl_e *aen;
+ struct acl_e *aen, *ae2;
if (fam == PF_INET && ae->mask > 32) {
VSB_printf(tl->sb,
@@ -239,9 +220,14 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l,
assert(l + 1UL <= sizeof aen->data);
memcpy(aen->data + 1L, u, l);
- vcc_acl_insert_entry(tl, &aen);
- if (aen != NULL)
+ ae2 = VRBT_INSERT(acl_tree, &tl->acl->acl_tree, aen);
+ if (ae2 != NULL && ae2->not != aen->not) {
+ VSB_cat(tl->sb, "Conflicting ACL entries:\n");
+ vcc_ErrWhere(tl, ae2->t_addr);
+ VSB_cat(tl->sb, "vs:\n");
+ vcc_ErrWhere(tl, aen->t_addr);
vcl_acl_free(&aen);
+ }
}
static void
@@ -599,7 +585,7 @@ vcc_ParseAcl(struct vcc *tl)
ERRCHK(tl);
AN(sym);
- while (tl->t->tok == '-' || tl->t->tok == '+') {
+ while (tl->t->tok == '-' || tl->t->tok == '+') {
sign = tl->t;
vcc_NextToken(tl);
if (tl->t->b != sign->e) {
More information about the varnish-commit
mailing list