[master] c862d49ee Add two new feature-checks: `feature ipv4` and `feature ipv6`

Poul-Henning Kamp phk at FreeBSD.org
Mon Jan 11 09:39:07 UTC 2021


commit c862d49eedbc609b8bb4cb7b2fe15706ec92ffaf
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jan 11 09:37:59 2021 +0000

    Add two new feature-checks: `feature ipv4` and `feature ipv6`

diff --git a/bin/varnishtest/tests/b00000.vtc b/bin/varnishtest/tests/b00000.vtc
index 86d0aa6ed..59cb4c119 100644
--- a/bin/varnishtest/tests/b00000.vtc
+++ b/bin/varnishtest/tests/b00000.vtc
@@ -1,6 +1,9 @@
 varnishtest "Does anything get through at all ?"
 
-server s1 {
+feature ipv4
+feature ipv6
+
+server s1 -listen 127.0.0.1:0 {
 	rxreq
 	txresp -body "012345\n"
 } -start
diff --git a/bin/varnishtest/vtc_misc.c b/bin/varnishtest/vtc_misc.c
index ca85fabd2..180bafb8b 100644
--- a/bin/varnishtest/vtc_misc.c
+++ b/bin/varnishtest/vtc_misc.c
@@ -365,6 +365,28 @@ dns_works(void)
 	return (0);
 }
 
+/**********************************************************************
+ * Test if IPv4/IPv6 works
+ */
+
+static int
+ipvx_works(const char *target)
+{
+	struct suckaddr *sa;
+	int fd;
+
+	sa = VSS_ResolveOne(NULL, target, "0", 0, SOCK_STREAM, 0);
+	if (sa == NULL)
+		return (0);
+	fd = VTCP_bind(sa, NULL);
+	free(sa);
+	if (fd >= 0) {
+		VTCP_close(&fd);
+		return (1);
+	}
+        return(0);
+}
+
 /* SECTION: feature feature
  *
  * Test that the required feature(s) for a test are available, and skip
@@ -439,6 +461,8 @@ cmd_feature(CMD_ARGS)
 #endif
 		}
 
+		FEATURE("ipv4", ipvx_works("127.0.0.1"));
+		FEATURE("ipv6", ipvx_works("[::1]"));
 		FEATURE("pcre_jit", VRE_has_jit);
 		FEATURE("64bit", sizeof(void*) == 8);
 		FEATURE("dns", dns_works());


More information about the varnish-commit mailing list