gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated (565515da0 -> d9137653d)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (565515da0 -> d9137653d)
Date: Sun, 20 May 2018 19:06:48 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository gnunet.

    from 565515da0 fix partitioning
     new 6f32b2b8c remove dead shorten logic
     new 88da23e56 allow multiple GNS2DNS records to co-exist
     new f4d0fb91c add logic to count concurrently active GNS requests
     new 705459369 fix warning
     new bd4d98e35 add test for gns2dns records pointing to DNS name
     new d9137653d guard more carefully against integer overflows

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/gns/Makefile.am                                |  1 +
 src/gns/gnunet-gns-benchmark.c                     | 20 ++++++++--
 src/gns/gnunet-service-gns_resolver.c              | 36 ++++++------------
 ..._lookup.sh => test_gns_gns2dns_cname_lookup.sh} | 44 ++++++----------------
 src/gnsrecord/gnsrecord_serialization.c            | 12 ++++--
 src/namestore/gnunet-namestore.c                   | 28 +++++---------
 6 files changed, 59 insertions(+), 82 deletions(-)
 copy src/gns/{test_gns_gns2dns_lookup.sh => test_gns_gns2dns_cname_lookup.sh} 
(61%)

diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index ac11c834e..46642113f 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -264,6 +264,7 @@ check_SCRIPTS = \
   test_gns_txt_lookup.sh\
   test_gns_mx_lookup.sh \
   test_gns_gns2dns_lookup.sh \
+  test_gns_gns2dns_cname_lookup.sh \
   test_gns_dht_lookup.sh\
   test_gns_delegated_lookup.sh \
   test_gns_at_lookup.sh\
diff --git a/src/gns/gnunet-gns-benchmark.c b/src/gns/gnunet-gns-benchmark.c
index 3754eec09..00d1c6813 100644
--- a/src/gns/gnunet-gns-benchmark.c
+++ b/src/gns/gnunet-gns-benchmark.c
@@ -84,7 +84,7 @@ struct Request
    * this struct (optimizing memory consumption by reducing
    * total number of allocations).
    */
-  char *hostname;
+  const char *hostname;
 
   /**
    * While we are fetching the record, the value is set to the
@@ -176,6 +176,11 @@ static struct GNUNET_TIME_Relative request_delay;
  */
 static struct GNUNET_TIME_Relative timeout;
 
+/**
+ * Number of requests we have concurrently active.
+ */
+static unsigned int active_cnt;
+
 
 /**
  * Free @a req and data structures reachable from it.
@@ -210,6 +215,7 @@ process_result (void *cls,
   (void) gns_tld;
   (void) rd_count;
   (void) rd;
+  active_cnt--;
   req->lr = NULL;
   req->latency = GNUNET_TIME_absolute_get_duration (req->op_start_time);
   GNUNET_CONTAINER_DLL_remove (act_head,
@@ -244,11 +250,14 @@ process_queue (void *cls)
     duration = GNUNET_TIME_absolute_get_duration (req->op_start_time);
     if (duration.rel_value_us < timeout.rel_value_us)
       break;
-    GNUNET_GNS_lookup_with_tld_cancel (req->lr);
     GNUNET_CONTAINER_DLL_remove (act_head,
                                 act_tail,
                                 req);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Failing request `%s' due to timeout\n",
+                req->hostname);
     failures[req->cat]++;
+    active_cnt--;
     free_request (req);
   }
   if (NULL == (req = todo_head))
@@ -274,7 +283,12 @@ process_queue (void *cls)
                                    act_tail,
                                    req);
   lookups[req->cat]++;
+  active_cnt++;
   req->op_start_time = GNUNET_TIME_absolute_get ();
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Starting request `%s' (%u in parallel)\n",
+              req->hostname,
+              active_cnt);
   req->lr = GNUNET_GNS_lookup_with_tld (gns,
                                        req->hostname,
                                        GNUNET_GNSRECORD_TYPE_ANY,
@@ -440,7 +454,7 @@ queue (const char *hostname,
   req = GNUNET_malloc (sizeof (struct Request) + hlen);
   req->cat = cat;
   req->hostname = (char *) &req[1];
-  GNUNET_memcpy (req->hostname,
+  GNUNET_memcpy (&req[1],
                  hostname,
                  hlen);
   GNUNET_CONTAINER_DLL_insert (todo_head,
diff --git a/src/gns/gnunet-service-gns_resolver.c 
b/src/gns/gnunet-service-gns_resolver.c
index 369bd3d63..b66516363 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -151,16 +151,6 @@ struct AuthorityChain
   char *label;
 
   /**
-   * label/name suggested for shortening to the authority
-   */
-  char *suggested_shortening_label;
-
-  /**
-   * Do we already try to shorten this authority?
-   */
-  int shortening_started;
-
-  /**
    * #GNUNET_YES if the authority was a GNS authority,
    * #GNUNET_NO if the authority was a DNS authority.
    */
@@ -1243,8 +1233,6 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
     ac->gns_authority = GNUNET_YES;
     ac->authority_info.gns_authority = 
rh->ac_tail->authority_info.gns_authority;
     ac->label = resolver_lookup_get_next_label (rh);
-    ac->suggested_shortening_label = NULL;
-    ac->shortening_started = GNUNET_NO;
     /* add AC to tail */
     GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
                                      rh->ac_tail,
@@ -1620,8 +1608,6 @@ recursive_pkey_resolution (struct GNS_ResolverHandle *rh,
   ac = GNUNET_new (struct AuthorityChain);
   ac->rh = rh;
   ac->gns_authority = GNUNET_YES;
-  ac->suggested_shortening_label = NULL;
-  ac->shortening_started = GNUNET_NO;
   GNUNET_memcpy (&ac->authority_info.gns_authority,
                  rd->data,
                  sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
@@ -1668,6 +1654,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle 
*rh,
     size_t off;
     struct Gns2DnsPending *gp;
     struct GNUNET_CRYPTO_EcdsaPublicKey zone;
+    struct sockaddr_in v4;
+    struct sockaddr_in6 v6;
 
     if (GNUNET_GNSRECORD_TYPE_GNS2DNS != rd[i].record_type)
       continue;
@@ -1709,10 +1697,16 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle 
*rh,
     }
 
     /* check if 'ip' is already an IPv4/IPv6 address */
-    if (GNUNET_OK ==
-        GNUNET_DNSSTUB_add_dns_ip (ac->authority_info.dns_authority.dns_handle,
-                                   ip))
+    if ( (1 == inet_pton (AF_INET,
+                          ip,
+                          &v4)) ||
+         (1 == inet_pton (AF_INET6,
+                          ip,
+                          &v6)) )
     {
+      GNUNET_break (GNUNET_OK ==
+                    GNUNET_DNSSTUB_add_dns_ip 
(ac->authority_info.dns_authority.dns_handle,
+                                               ip));
       ac->authority_info.dns_authority.found = GNUNET_YES;
       GNUNET_free (ip);
       continue;
@@ -1817,7 +1811,6 @@ handle_gns_resolution_result (void *cls,
                              const struct GNUNET_GNSRECORD_Data *rd)
 {
   struct GNS_ResolverHandle *rh = cls;
-  struct AuthorityChain *shorten_ac;
   char *cname;
   struct VpnContext *vpn_ctx;
   const struct GNUNET_TUN_GnsVpnRecord *vpn;
@@ -1947,7 +1940,6 @@ handle_gns_resolution_result (void *cls,
        using 'scratch' array for memory allocations */
     scratch_off = 0;
     rd_off = 0;
-    shorten_ac = rh->ac_tail;
     for (unsigned int i=0;i<rd_count;i++)
     {
       GNUNET_assert (rd_off <= i);
@@ -2125,8 +2117,6 @@ handle_gns_resolution_result (void *cls,
             GNUNET_break_op (0);
             break;
           }
-          if (NULL == shorten_ac->suggested_shortening_label)
-            shorten_ac->suggested_shortening_label = GNUNET_strdup (nick);
           break;
         }
       case GNUNET_GNSRECORD_TYPE_PKEY:
@@ -2152,8 +2142,6 @@ handle_gns_resolution_result (void *cls,
             ac->gns_authority = GNUNET_YES;
             ac->authority_info.gns_authority = pub;
             ac->label = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT);
-            ac->suggested_shortening_label = NULL;
-            ac->shortening_started = GNUNET_NO;
             GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
                                               rh->ac_tail,
                                               ac);
@@ -2675,7 +2663,6 @@ start_resolver_lookup (void *cls)
   ac = GNUNET_new (struct AuthorityChain);
   ac->rh = rh;
   ac->label = resolver_lookup_get_next_label (rh);
-  ac->suggested_shortening_label = NULL;
   if (NULL == ac->label)
     /* name was just the "TLD", so we default to label
        #GNUNET_GNS_EMPTY_LABEL_AT */
@@ -2789,7 +2776,6 @@ GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh)
       GNUNET_DNSSTUB_stop (ac->authority_info.dns_authority.dns_handle);
     }
     GNUNET_free (ac->label);
-    GNUNET_free_non_null (ac->suggested_shortening_label);
     GNUNET_free (ac);
   }
   if (NULL != rh->task_id)
diff --git a/src/gns/test_gns_gns2dns_lookup.sh 
b/src/gns/test_gns_gns2dns_cname_lookup.sh
similarity index 61%
copy from src/gns/test_gns_gns2dns_lookup.sh
copy to src/gns/test_gns_gns2dns_cname_lookup.sh
index ad5d762eb..32e730d4c 100755
--- a/src/gns/test_gns_gns2dns_lookup.sh
+++ b/src/gns/test_gns_gns2dns_cname_lookup.sh
@@ -14,19 +14,17 @@ then
 fi
 
 rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
-# IP address of 'uk.gnunet.org'
-TEST_IP_ALT2="81.187.252.184"
 # IP address of 'www.gnunet.org'
 TEST_IP="131.159.74.67"
 # IPv6 address of 'gnunet.org'
 TEST_IP6="2001:4ca0:2001:42:225:90ff:fe6b:d60"
-# permissive DNS resolver we will use for the test
-TEST_IP_GNS2DNS="8.8.8.8"
 
 # main label used during resolution
 TEST_RECORD_NAME="homepage"
 
-if ! nslookup gnunet.org $TEST_IP_GNS2DNS &> /dev/null
+XNS=ns.joker.com
+
+if ! nslookup gnunet.org a.$XNS &> /dev/null
 then
   echo "Cannot reach DNS, skipping test"
   exit 77
@@ -36,22 +34,22 @@ fi
 TEST_RESOLVER_LABEL="resolver"
 # GNS2DNS record value: delegate to DNS domain 'gnunet.org'
 # using the TEST_RESOLVER_LABEL DNS server for resolution
-TEST_RECORD_GNS2DNS="address@hidden"
+TEST_RECORD_GNS2DNS1="address@hidden"
+TEST_RECORD_GNS2DNS2="address@hidden"
+TEST_RECORD_GNS2DNS3="address@hidden"
 
 MY_EGO="myego"
 # various names we will use for resolution
 TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO"
-TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.$MY_EGO"
-TEST_DOMAIN_ALT2="uk.${TEST_RECORD_NAME}.$MY_EGO"
-
 
 gnunet-arm -s -c test_gns_lookup.conf
 gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
 
 # set IP address for DNS resolver for resolving in gnunet.org domain
-gnunet-namestore -p -z $MY_EGO -a -n $TEST_RESOLVER_LABEL -t A -V 
$TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf
 # map '$TEST_RECORD_NAME.$MY_EGO' to 'gnunet.org' in DNS
-gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V 
$TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf
+gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V 
$TEST_RECORD_GNS2DNS1 -e never -c test_gns_lookup.conf
+gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V 
$TEST_RECORD_GNS2DNS2 -e never -c test_gns_lookup.conf
+gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V 
$TEST_RECORD_GNS2DNS3 -e never -c test_gns_lookup.conf
 
 which timeout &> /dev/null && DO_TIMEOUT="timeout 15"
 
@@ -62,14 +60,11 @@ gnunet-identity -d
 RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t A -c 
test_gns_lookup.conf`
 # lookup 'www.gnunet.org', IPv6
 RES_IP6=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t AAAA -c 
test_gns_lookup.conf`
-# lookup 'gnunet.org', IPv4
-RES_IP_ALT=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT -t A -c 
test_gns_lookup.conf`
-# lookup 'uk.gnunet.org', IPv4
-RES_IP_ALT2=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT2 -t A -c 
test_gns_lookup.conf`
 
 # clean up
-gnunet-namestore -z $MY_EGO -d -n $TEST_RESOLVER_LABEL -t A -V 
$TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf
-gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V 
$TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf
+gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V 
$TEST_RECORD_GNS2DNS1 -e never -c test_gns_lookup.conf
+gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V 
$TEST_RECORD_GNS2DNS2 -e never -c test_gns_lookup.conf
+gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V 
$TEST_RECORD_GNS2DNS3 -e never -c test_gns_lookup.conf
 gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
 gnunet-arm -e -c test_gns_lookup.conf
 rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
@@ -91,19 +86,4 @@ else
   ret=1
 fi
 
-if [ "$RES_IP_ALT" == "$TEST_IP" ]
-then
-  echo "PASS: Resolved $TEST_DOMAIN_ALT to $RES_IP_ALT."
-else
-  echo "Failed to resolve to proper IP for $TEST_DOMAIN_ALT, got $RES_IP_ALT, 
wanted $TEST_IP."
-  ret=1
-fi
-
-if [ "$RES_IP_ALT2" == "$TEST_IP_ALT2" ]
-then
-  echo "PASS: Resolved $TEST_DOMAIN_ALT2 to $RES_IP_ALT2."
-else
-  echo "Failed to resolve to proper IP for $TEST_DOMAIN_ALT2, got 
$RES_IP_ALT2, wanted $TEST_IP_ALT2."
-  ret=1
-fi
 exit $ret
diff --git a/src/gnsrecord/gnsrecord_serialization.c 
b/src/gnsrecord/gnsrecord_serialization.c
index 1db27464f..6164fa3db 100644
--- a/src/gnsrecord/gnsrecord_serialization.c
+++ b/src/gnsrecord/gnsrecord_serialization.c
@@ -126,7 +126,8 @@ GNUNET_GNSRECORD_records_serialize (unsigned int rd_count,
     rec.data_size = htonl ((uint32_t) rd[i].data_size);
     rec.record_type = htonl (rd[i].record_type);
     rec.flags = htonl (rd[i].flags);
-    if (off + sizeof (rec) > dest_size)
+    if ( (off + sizeof (rec) > dest_size) ||
+         (off + sizeof (rec) < off) )
     {
       GNUNET_break (0);
       return -1;
@@ -135,7 +136,8 @@ GNUNET_GNSRECORD_records_serialize (unsigned int rd_count,
                    &rec,
                    sizeof (rec));
     off += sizeof (rec);
-    if (off + rd[i].data_size > dest_size)
+    if ( (off + rd[i].data_size > dest_size) ||
+         (off + rd[i].data_size < off) )
     {
       GNUNET_break (0);
       return -1;
@@ -185,7 +187,8 @@ GNUNET_GNSRECORD_records_deserialize (size_t len,
   off = 0;
   for (unsigned int i=0;i<rd_count;i++)
   {
-    if (off + sizeof (rec) > len)
+    if ( (off + sizeof (rec) > len) ||
+         (off + sizeof (rec) < off) )
     {
       GNUNET_break_op (0);
       return GNUNET_SYSERR;
@@ -198,7 +201,8 @@ GNUNET_GNSRECORD_records_deserialize (size_t len,
     dest[i].record_type = ntohl (rec.record_type);
     dest[i].flags = ntohl (rec.flags);
     off += sizeof (rec);
-    if (off + dest[i].data_size > len)
+    if ( (off + dest[i].data_size > len) ||
+         (off + dest[i].data_size < off) )
     {
       GNUNET_break_op (0);
       return GNUNET_SYSERR;
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 753ee79d1..83a7ee349 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -641,14 +641,6 @@ get_existing_record (void *cls,
       ret = 1;
       test_finished ();
       return;
-    case GNUNET_GNSRECORD_TYPE_GNS2DNS:
-      fprintf (stderr,
-               _("A %s record exists already under `%s', no other records can 
be added.\n"),
-               "GNS2DNS",
-               rec_name);
-      ret = 1;
-      test_finished ();
-      return;
     }
   }
   switch (type)
@@ -678,16 +670,16 @@ get_existing_record (void *cls,
     }
     break;
   case GNUNET_GNSRECORD_TYPE_GNS2DNS:
-    if (0 != rd_count)
-    {
-      fprintf (stderr,
-               _("Records already exist under `%s', cannot add `%s' 
record.\n"),
-               rec_name,
-               "GNS2DNS");
-      ret = 1;
-      test_finished ();
-      return;
-    }
+    for (unsigned int i=0;i<rd_count;i++)
+      if (GNUNET_GNSRECORD_TYPE_GNS2DNS != rd[i].record_type)
+      {
+        fprintf (stderr,
+                 _("Non-GNS2DNS records already exist under `%s', cannot add 
GNS2DNS record.\n"),
+                 rec_name);
+        ret = 1;
+        test_finished ();
+        return;
+      }
     break;
   }
   memset (rdn,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]