[git] ADNS-g10 - branch, master, updated. adns-1.4-g10-6-21-g92b7fed

by Werner Koch cvs at cvs.gnupg.org
Wed Nov 9 09:09:05 CET 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "ADNS migrated to autotools/libtool".

The branch, master has been updated
       via  92b7fed7d65ba98c2d8736a692708b2f0597f6c5 (commit)
      from  9b21d214642b2a6ba43809369118722f2fa86415 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 92b7fed7d65ba98c2d8736a692708b2f0597f6c5
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Nov 9 09:06:29 2016 +0100

    Catch network failures from sendto earlier.
    
    * src/adns.h (adns_s_netunreach): New.
    (adns_s_netdown): New.
    * src/general.c (struct sinfo): Add corresponding strings.
    * src/transmit.c (adns__query_send): Bail out early on ENETUNREACH and
    ENETDOWN.
    --
    
    This patch will stop retrying sending UDP packets to an IP address for
    which the sever can't reach the network or the interface is down.  A
    common case for these errors are lost network connections (WLAN lost
    or cable unplugged).  It does not make sense to keep on trying once
    sendto returned one of these errors - it is unlikely that this will be
    solved within the next 30 seconds (15 retries * 2s)
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/adns.h b/src/adns.h
index 9fe9a9a..ac62b9a 100644
--- a/src/adns.h
+++ b/src/adns.h
@@ -254,6 +254,8 @@ typedef enum {
  adns_s_norecurse,
  adns_s_invalidresponse,
  adns_s_unknownformat,
+ adns_s_netunreach,
+ adns_s_netdown,
 
  adns_s_max_remotefail= 59,
 
diff --git a/src/general.c b/src/general.c
index a65fc8f..a6b7871 100644
--- a/src/general.c
+++ b/src/general.c
@@ -8,20 +8,20 @@
  *    Copyright (C) 1999-2000,2003,2006  Tony Finch
  *    Copyright (C) 1991 Massachusetts Institute of Technology
  *  (See the file INSTALL for full details.)
- *  
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2, or (at your option)
  *  any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
 #include <stdlib.h>
@@ -53,7 +53,7 @@ void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent,
 		 int serv, adns_query qu, const char *fmt, va_list al) {
   const char *bef, *aft;
   vbuf vb;
-  
+
   if (!ads->logfn ||
       (!(ads->iflags & adns_if_debug)
        && (!prevent || (ads->iflags & prevent))))
@@ -82,7 +82,7 @@ void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent,
     bef=", "; aft=")\n";
     adns__vbuf_free(&vb);
   }
-  
+
   if (serv>=0) {
     adns__lprintf(ads,"%sNS=%s",bef,inet_ntoa(ads->servers[serv].addr));
     bef=", "; aft=")\n";
@@ -164,7 +164,7 @@ adns_status adns_rr_info(adns_rrtype type,
   if (len_r) *len_r= typei->rrsz;
 
   if (!datap) return adns_s_ok;
-  
+
   adns__vbuf_init(&vb);
   st= typei->convstring(&vb,datap);
   if (st) goto x_freevb;
@@ -188,33 +188,35 @@ static const struct sinfo {
   const char *string;
 } sinfos[]= {
   SINFO( ok,                  "OK"                                           ),
-									      
+
   SINFO( nomemory,            "Out of memory"                                ),
   SINFO( unknownrrtype,       "Query not implemented in DNS library"         ),
   SINFO( systemfail,          "General resolver or system failure"           ),
-									      
+
   SINFO( timeout,             "DNS query timed out"                          ),
   SINFO( allservfail,         "All nameservers failed"                       ),
   SINFO( norecurse,           "Recursion denied by nameserver"               ),
   SINFO( invalidresponse,     "Nameserver sent bad response"                 ),
   SINFO( unknownformat,       "Nameserver used unknown format"               ),
-									      
+  SINFO( netunreach,          "Network is unreachable"                       ),
+  SINFO( netdown,             "Network is down"                              ),
+
   SINFO( rcodeservfail,       "Nameserver reports failure"                   ),
   SINFO( rcodeformaterror,    "Query not understood by nameserver"           ),
   SINFO( rcodenotimplemented, "Query not implemented by nameserver"          ),
   SINFO( rcoderefused,        "Query refused by nameserver"                  ),
   SINFO( rcodeunknown,        "Nameserver sent unknown response code"        ),
-  									      
+
   SINFO( inconsistent,        "Inconsistent resource records in DNS"         ),
   SINFO( prohibitedcname,     "DNS alias found where canonical name wanted"  ),
   SINFO( answerdomaininvalid, "Found syntactically invalid domain name"      ),
   SINFO( answerdomaintoolong, "Found overly-long domain name"                ),
   SINFO( invaliddata,         "Found invalid DNS data"                       ),
-									      
+
   SINFO( querydomainwrong,    "Domain invalid for particular DNS query type" ),
   SINFO( querydomaininvalid,  "Domain name is syntactically invalid"         ),
   SINFO( querydomaintoolong,  "Domain name or component is too long"         ),
-									      
+
   SINFO( nxdomain,            "No such domain"                               ),
   SINFO( nodata,              "No such data"                                 )
 };
@@ -275,7 +277,7 @@ static int sti_compar(const void *key, const void *elem) {
   here= *st;
   min= (sti==stinfos) ? 0 : sti[-1].stmax+1;
   max= sti->stmax;
-  
+
   return here < min  ? -1 : here > max ? 1 : 0;
 }
 
@@ -311,7 +313,7 @@ void adns__isort(void *array, int nobjs, int sz, void *tempbuf,
 void adns__sigpipe_protect(adns_state ads) {
 #ifdef HAVE_W32_SYSTEM
   /* No SIGPIPE under Windows.  */
-  (void)ads; 
+  (void)ads;
 #else
   sigset_t toblock;
   struct sigaction sa;
@@ -325,7 +327,7 @@ void adns__sigpipe_protect(adns_state ads) {
   sa.sa_handler= SIG_IGN;
   sigfillset(&sa.sa_mask);
   sa.sa_flags= 0;
-  
+
   r= sigprocmask(SIG_SETMASK,&toblock,&ads->stdsigmask); assert(!r);
   r= sigaction(SIGPIPE,&sa,&ads->stdsigpipe); assert(!r);
 #endif
@@ -334,7 +336,7 @@ void adns__sigpipe_protect(adns_state ads) {
 void adns__sigpipe_unprotect(adns_state ads) {
 #ifdef HAVE_W32_SYSTEM
   /* No SIGPIPE under Windows.  */
-  (void)ads; 
+  (void)ads;
 #else
   int r;
 
diff --git a/src/transmit.c b/src/transmit.c
index d070ecc..61ecb08 100644
--- a/src/transmit.c
+++ b/src/transmit.c
@@ -9,20 +9,20 @@
  *    Copyright (C) 1999-2000,2003,2006  Tony Finch
  *    Copyright (C) 1991 Massachusetts Institute of Technology
  *  (See the file INSTALL for full details.)
- *  
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2, or (at your option)
  *  any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
 #include <errno.h>
@@ -44,12 +44,12 @@ static adns_status mkquery_header(adns_state ads, vbuf *vb,
 				  int *id_r, int qdlen) {
   int id;
   byte *rqp;
-  
+
   if (!adns__vbuf_ensure(vb,DNS_HDRSIZE+qdlen+4)) return adns_s_nomemory;
 
   vb->used= 0;
   MKQUERY_START(vb);
-  
+
   *id_r= id= (ads->nextid++) & 0x0ffff;
   MKQUERY_ADDW(id);
   MKQUERY_ADDB(0x01); /* QR=Q(0), OPCODE=QUERY(0000), !AA, !TC, RD */
@@ -60,7 +60,7 @@ static adns_status mkquery_header(adns_state ads, vbuf *vb,
   MKQUERY_ADDW(0); /* ARCOUNT=0 */
 
   MKQUERY_STOP(vb);
-  
+
   return adns_s_ok;
 }
 
@@ -72,7 +72,7 @@ static adns_status mkquery_footer(vbuf *vb, adns_rrtype type) {
   MKQUERY_ADDW(DNS_CLASS_IN); /* QCLASS=IN */
   MKQUERY_STOP(vb);
   assert(vb->used <= vb->avail);
-  
+
   return adns_s_ok;
 }
 
@@ -86,7 +86,7 @@ adns_status adns__qdpl_normal(adns_state ads,
 
   ll= 0;
   p= *p_io;
-  
+
   while (p!=pe && (c= *p++)!='.') {
     if (c=='\\') {
       if (!(flags & adns_qf_quoteok_query)) return adns_s_querydomaininvalid;
@@ -114,7 +114,7 @@ adns_status adns__qdpl_normal(adns_state ads,
     if (ll == *ll_io) return adns_s_querydomaininvalid;
     label_r[ll++]= c;
   }
-  
+
   *p_io= p;
   *ll_io= ll;
   return adns_s_ok;
@@ -131,7 +131,7 @@ adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
   adns_status st;
 
   st= mkquery_header(ads,vb,id_r,ol+2); if (st) return st;
-  
+
   MKQUERY_START(vb);
 
   p= owner; pe= owner+ol;
@@ -151,9 +151,9 @@ adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
   MKQUERY_ADDB(0);
 
   MKQUERY_STOP(vb);
-  
+
   st= mkquery_footer(vb,type);
-  
+
   return adns_s_ok;
 }
 
@@ -182,9 +182,9 @@ adns_status adns__mkquery_frdgram(adns_state ads, vbuf *vb, int *id_r,
   MKQUERY_ADDB(0);
 
   MKQUERY_STOP(vb);
-  
+
   st= mkquery_footer(vb,type);
-  
+
   return adns_s_ok;
 }
 
@@ -274,17 +274,24 @@ void adns__query_send(adns_query qu, struct timeval now) {
   servaddr.sin_family= AF_INET;
   servaddr.sin_addr= ads->servers[serv].addr;
   servaddr.sin_port= htons(DNS_PORT);
-  
+
   r= adns__sock_sendto(ads->udpsocket,qu->query_dgram,qu->query_dglen,0,
                        (const struct sockaddr*)&servaddr,sizeof(servaddr));
-  if (r<0 && errno == EMSGSIZE) {
-    qu->retries= 0;
-    query_usetcp(qu,now);
-    return;
+  if (r<0) {
+    if (errno == EMSGSIZE) {
+      qu->retries= 0;
+      query_usetcp(qu,now);
+      return;
+    } else if (errno == ENETUNREACH) {
+      adns__query_fail(qu,adns_s_netunreach);
+      return;
+    } else if (errno == ENETDOWN) {
+      adns__query_fail(qu,adns_s_netdown);
+      return;
+    } else if (errno != EAGAIN)
+      adns__warn(ads,serv,0,"sendto failed: %s",strerror(errno));
   }
-  if (r<0 && errno != EAGAIN)
-    adns__warn(ads,serv,0,"sendto failed: %s",strerror(errno));
-  
+
   qu->timeout= now;
   timevaladd(&qu->timeout,UDPRETRYMS);
   qu->udpsent |= (1<<serv);

-----------------------------------------------------------------------

Summary of changes:
 src/adns.h     |  2 ++
 src/general.c  | 36 +++++++++++++++++++-----------------
 src/transmit.c | 53 ++++++++++++++++++++++++++++++-----------------------
 3 files changed, 51 insertions(+), 40 deletions(-)


hooks/post-receive
-- 
ADNS migrated to autotools/libtool
http://git.gnupg.org




More information about the Gnupg-commits mailing list