[master] 20de7660c Emit the "ipv4+ipv6 and mask" error first.
Poul-Henning Kamp
phk at FreeBSD.org
Sat Aug 15 12:02:08 UTC 2020
commit 20de7660cb88f251c39351fba3615dc4fee16cbb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sat Aug 15 12:01:12 2020 +0000
Emit the "ipv4+ipv6 and mask" error first.
diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c
index 689455926..795a7571d 100644
--- a/lib/libvcc/vcc_acl.c
+++ b/lib/libvcc/vcc_acl.c
@@ -138,17 +138,17 @@ vcc_acl_chk(struct vcc *tl, const struct acl_e *ae, const int l,
AN(sa);
VTCP_name(sa, h, sizeof h, NULL, 0);
bprintf(t, "%s/%d", h, ae->mask);
+ VSB_printf(tl->sb, "Address/Netmask mismatch, ");
if (tl->acl_pedantic != 0)
- VSB_printf(tl->sb, "Address/Netmask mismatch, need be %s\n", t);
+ VSB_printf(tl->sb, "need be %s\n", t);
else
- VSB_printf(tl->sb, "Address/Netmask mismatch, changed to %s\n", t);
+ VSB_printf(tl->sb, "changed to %s\n", t);
vcc_ErrWhere(tl, ae->t_addr);
if (tl->acl_pedantic == 0)
vcc_Warn(tl);
return (strdup(t));
}
-
static void
vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l,
unsigned char *u, int fam)
@@ -256,6 +256,30 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae)
}
i4 = i6 = 0;
+ for (res = res0; res != NULL; res = res->ai_next) {
+ switch (res->ai_family) {
+ case PF_INET:
+ i4++;
+ break;
+ case PF_INET6:
+ i6++;
+ break;
+ default:
+ VSB_printf(tl->sb,
+ "Ignoring unknown protocol family (%d) for %.*s\n",
+ res->ai_family, PF(ae->t_addr));
+ continue;
+ }
+ }
+
+ if (ae->t_mask != NULL && i4 > 0 && i6 > 0) {
+ VSB_printf(tl->sb,
+ "Mask (/%u) specified, but string resolves to"
+ " both IPv4 and IPv6 addresses.\n", ae->mask);
+ vcc_ErrWhere(tl, ae->t_mask);
+ return;
+ }
+
for (res = res0; res != NULL; res = res->ai_next) {
switch (res->ai_family) {
case PF_INET:
@@ -265,7 +289,6 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae)
u = (void*)&sin4->sin_addr;
if (ae->t_mask == NULL)
ae->mask = 32;
- i4++;
vcc_acl_add_entry(tl, ae, 4, u, res->ai_family);
break;
case PF_INET6:
@@ -275,13 +298,9 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae)
u = (void*)&sin6->sin6_addr;
if (ae->t_mask == NULL)
ae->mask = 128;
- i6++;
vcc_acl_add_entry(tl, ae, 16, u, res->ai_family);
break;
default:
- VSB_printf(tl->sb,
- "Ignoring unknown protocol family (%d) for %.*s\n",
- res->ai_family, PF(ae->t_addr));
continue;
}
if (tl->err)
@@ -290,13 +309,6 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae)
}
freeaddrinfo(res0);
- if (ae->t_mask != NULL && i4 > 0 && i6 > 0) {
- VSB_printf(tl->sb,
- "Mask (/%u) specified, but string resolves to"
- " both IPv4 and IPv6 addresses.\n", ae->mask);
- vcc_ErrWhere(tl, ae->t_mask);
- return;
- }
}
/*--------------------------------------------------------------------
More information about the varnish-commit
mailing list