[master] bbb5db47e vcc_acl: split out insertion function

Nils Goroll nils.goroll at uplex.de
Thu Mar 25 17:21:04 UTC 2021


commit bbb5db47e02f431598e5a7ff7106a8ac316db8be
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Fri Dec 13 18:01:20 2019 +0100

    vcc_acl: split out insertion function
    
    Reduces conflicts with a held-back PR

diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c
index e03928ba0..ed0042a67 100644
--- a/lib/libvcc/vcc_acl.c
+++ b/lib/libvcc/vcc_acl.c
@@ -155,11 +155,30 @@ 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 *aen)
+{
+	struct acl_e *ae2;
+
+	ae2 = VRBT_FIND(acl_tree, &tl->acl_tree, aen);
+	if (ae2 != NULL) {
+		if (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);
+		}
+		free(aen);
+		return;
+	}
+	VRBT_INSERT(acl_tree, &tl->acl_tree, aen);
+}
+
 static void
 vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l,
     unsigned char *u, int fam)
 {
-	struct acl_e *ae2, *aen;
+	struct acl_e *aen;
 
 	if (fam == PF_INET && ae->mask > 32) {
 		VSB_printf(tl->sb,
@@ -178,7 +197,7 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l,
 	}
 
 	/* Make a copy from the template */
-	aen = TlAlloc(tl, sizeof *ae2);
+	aen = TlAlloc(tl, sizeof *aen);
 	AN(aen);
 	*aen = *ae;
 
@@ -192,18 +211,7 @@ 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);
 
-	ae2 = VRBT_FIND(acl_tree, &tl->acl_tree, aen);
-	if (ae2 != NULL) {
-		if (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);
-		}
-		free(aen);
-		return;
-	}
-	VRBT_INSERT(acl_tree, &tl->acl_tree, aen);
+	vcc_acl_insert_entry(tl, aen);
 }
 
 static void


More information about the varnish-commit mailing list