]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Test only if compiled with CLIENT_SUBNET. Fix assertion when running regular tests.
authorYuri Schaeffer <yuri@nlnetlabs.nl>
Thu, 24 Jan 2013 11:48:52 +0000 (11:48 +0000)
committerYuri Schaeffer <yuri@nlnetlabs.nl>
Thu, 24 Jan 2013 11:48:52 +0000 (11:48 +0000)
git-svn-id: file:///svn/unbound/branches/edns-subnet@2819 be551aaa-1e26-0410-a405-d3ace91eadb9

services/mesh.c
testcode/fake_event.c
testcode/testbound.c
testdata/subnet_format_ip4.crpl [moved from testdata/subnet_format_ip4.rpl with 100% similarity]
util/config_file.c

index 1c0b0a1ff79579f6d6f2243c9b72f2735439b390..f785e7a9b0a329b6d3b1f1b9d5d5b44b5476a619 100644 (file)
@@ -376,15 +376,28 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
                        edns->subnet_source_mask = MAX_CLIENT_SUBNET_IP4;
                        edns->subnet_addr_fam = IANA_ADDRFAM_IP4;
                        sinaddr = &((struct sockaddr_in*)ss)->sin_addr;
+#ifndef unbound_testbound
                        memcpy(edns->subnet_addr, (uint8_t *)sinaddr, INET_SIZE);
+#else
+                       /* sinaddr does not contain any valid data when running
+                        * testbound. Provide a constant so we can do our tests */
+                       memcpy(edns->subnet_addr, (uint8_t *)[5,0,15,10], INET_SIZE);
+#endif /* unbound_testbound */ 
                        edns->subnet_validdata = 1;
-               } 
+               }
 #ifdef INET6
                else {
                        edns->subnet_source_mask = MAX_CLIENT_SUBNET_IP6;
                        edns->subnet_addr_fam = IANA_ADDRFAM_IP6;
                        sinaddr = &((struct sockaddr_in6*)ss)->sin6_addr;
+#ifndef unbound_testbound
                        memcpy(edns->subnet_addr, (uint8_t *)sinaddr, INET6_SIZE);
+#else
+                       /* sinaddr does not contain any valid data when running
+                        * testbound. Provide a constant so we can do our tests */
+                       memcpy(edns->subnet_addr, (uint8_t *)[5,0,15,10, 5,0,15,10, 
+                               5,0,15,10, 5,0,15,10], INET6_SIZE);
+#endif /* unbound_testbound */ 
                        edns->subnet_validdata = 1;
                }
 #else
@@ -444,7 +457,7 @@ mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
 #ifdef UNBOUND_DEBUG
                n =
 #else
-                (void)
+               (void)
 #endif
                rbtree_insert(&mesh->all, &s->node);
                log_assert(n != NULL);
index cd42b7406b9628489bdcf417d42765cc37f95728..f1636dd522d481d2cc3305668fab1f64e2deba1f 100644 (file)
@@ -60,7 +60,9 @@
 #include "testcode/ldns-testpkts.h"
 #include "util/log.h"
 #include "util/fptr_wlist.h"
+#ifdef CLIENT_SUBNET
 #include "edns-subnet/edns-subnet.h"
+#endif
 #include <signal.h>
 struct worker;
 struct daemon_remote;
@@ -1106,6 +1108,8 @@ struct serviced_query* outnet_serviced_query(struct outside_network* outnet,
                        memcpy(&edns, edns_out, sizeof(edns));
                        /* This tells our module we've appened the option*/
                        edns.subnet_sent = 1;
+               } else {
+                       edns.subnet_validdata = 0;
                }
 #endif
                edns.edns_present = 1;
index 6e88edf22e625a9cd7c4d3dd32dabda02b3fafdb..3fa22391b3e764088cdd70914f00347fdd0372fc 100644 (file)
@@ -71,6 +71,7 @@ testbound_usage()
        printf("-2      detect SHA256 support (exit code 0 or 1)\n");
        printf("-g      detect GOST support (exit code 0 or 1)\n");
        printf("-e      detect ECDSA support (exit code 0 or 1)\n");
+       printf("-c      detect CLIENT_SUBNET support (exit code 0 or 1)\n");
        printf("-s      testbound self-test - unit test of testbound parts.\n");
        printf("-o str  unbound commandline options separated by spaces.\n");
        printf("Version %s\n", PACKAGE_VERSION);
@@ -273,7 +274,7 @@ main(int argc, char* argv[])
        pass_argc = 1;
        pass_argv[0] = "unbound";
        add_opts("-d", &pass_argc, pass_argv);
-       while( (c=getopt(argc, argv, "2egho:p:s")) != -1) {
+       while( (c=getopt(argc, argv, "2cegho:p:s")) != -1) {
                switch(c) {
                case 's':
                        free(pass_argv[1]);
@@ -310,6 +311,15 @@ main(int argc, char* argv[])
 #else
                        printf("GOST not supported\n");
                        exit(1);
+#endif
+                       break;
+               case 'c':
+#ifdef CLIENT_SUBNET
+                       printf("CLIENT_SUBNET supported\n");
+                       exit(0);
+#else
+                       printf("CLIENT_SUBNET not supported\n");
+                       exit(1);
 #endif
                        break;
                case 'p':
index cca2d8f594da29eced590b77edf383d8e19ae89f..c11070be4d750516464f35c88dd02c11a21a7ef2 100644 (file)
@@ -218,7 +218,11 @@ config_create(void)
        if(!(cfg->control_cert_file = strdup(RUN_DIR"/unbound_control.pem"))) 
                goto error_exit;
 
+#if CLIENT_SUBNET
+       if(!(cfg->module_conf = strdup("subnetcache validator iterator"))) goto error_exit;
+#else
        if(!(cfg->module_conf = strdup("validator iterator"))) goto error_exit;
+#endif
        if(!(cfg->val_nsec3_key_iterations = 
                strdup("1024 150 2048 500 4096 2500"))) goto error_exit;
        return cfg;