r5418 - in trunk/varnish-cache: bin/varnishtest/tests lib/libvcl

kristian at varnish-cache.org kristian at varnish-cache.org
Thu Oct 7 17:44:31 CEST 2010


Author: kristian
Date: 2010-10-07 17:44:31 +0200 (Thu, 07 Oct 2010)
New Revision: 5418

Modified:
   trunk/varnish-cache/bin/varnishtest/tests/v00030.vtc
   trunk/varnish-cache/lib/libvcl/vcc_dir_dns.c
Log:
DNS Director VCC improvements: Don't assert() as much on syntax errors in
VCL. Also adds a small test for incorrect headers.




Modified: trunk/varnish-cache/bin/varnishtest/tests/v00030.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00030.vtc	2010-10-06 21:50:42 UTC (rev 5417)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00030.vtc	2010-10-07 15:44:31 UTC (rev 5418)
@@ -20,6 +20,14 @@
        }
 }
 
+varnish v9 -badvcl {
+       director directorname dns {
+               .list = {
+                       .host_hdr = "192.168.1.1";
+		       "192.168.1.2";
+               }
+       }
+}
 varnish v1 -badvcl {
        director directorname dns {
                .list = {
@@ -45,10 +53,10 @@
        }
 }
 
-#varnish v1 -badvcl {
-#       director directorname dns {
-#               .list = {
-#                       "192.168.16.255"/24;
-#               }
-#       }
-#}
+varnish v1 -badvcl {
+       director directorname dns {
+               .list = {
+                       "192.168.16.255"/24;
+               }
+       }
+}

Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_dns.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_dir_dns.c	2010-10-06 21:50:42 UTC (rev 5417)
+++ trunk/varnish-cache/lib/libvcl/vcc_dir_dns.c	2010-10-07 15:44:31 UTC (rev 5418)
@@ -153,12 +153,14 @@
 	ip4 |= a[3] ;
 
 	ip4end = ip4 | ~mask;
-	assert (ip4 == (ip4 & mask));
+	if (ip4 != (ip4 & mask)) {
+		vsb_printf(tl->sb, "IP and network mask not compatible: ");
+		vcc_ErrToken(tl, tl->t);
+		vsb_printf(tl->sb, " at\n");
+		vcc_ErrWhere(tl, tl->t);
+		ERRCHK(tl);
+	}
 
-/*	printf("uip4: \t0x%.8X\na: \t0x", ip4,ip4);
-	for (int i=0;i<4;i++) printf("%.2X",a[i]);
-	printf("\nmask:\t0x%.8X\nend:\t0x%.8X\n", mask, ip4end);
-*/
 	while (ip4 <= ip4end) {
 		uint8_t *b;
 		b=(uint8_t *)&ip4;
@@ -256,13 +258,23 @@
 	int ret;
 	ERRCHK(tl);
 	SkipToken(tl, '{');
-	if (tl->t->tok != CSTR)
+	if (tl->t->tok != CSTR) {
 		vcc_dir_dns_parse_backend_options(tl);
+		ERRCHK(tl);
+	}
+
 	while (tl->t->tok == CSTR) {
 		mask = 32;
 		ret = sscanf(tl->t->dec, "%hhu.%hhu.%hhu.%hhu",
 		    &a[0], &a[1], &a[2], &a[3]);
-		assert(ret == 4);
+		if (ret != 4) {
+			vsb_printf(tl->sb, "Incomplete IP supplied: ");
+			vcc_ErrToken(tl, tl->t);
+			vsb_printf(tl->sb, " at\n");
+			vcc_ErrWhere(tl, tl->t);
+			ERRCHK(tl);
+		}
+
 		vcc_NextToken(tl);
 		if (tl->t->tok == '/') {
 			vcc_NextToken(tl);




More information about the varnish-commit mailing list