trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject [2/4] git commit: TS-2595 DNS lookup failed with multiple search domains
Date Mon, 03 Mar 2014 14:37:36 GMT
TS-2595 DNS lookup failed with multiple search domains

Expand multiple search domains by appending each to original host name rather
than keep appending one after the other.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/dfdc9854
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/dfdc9854
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/dfdc9854

Branch: refs/heads/master
Commit: dfdc98548bcbd92df1c998afd8239a4a4f7ccc75
Parents: af3e7aa
Author: Thach Tran <tranngocthachs@gmail.com>
Authored: Thu Feb 27 16:27:48 2014 +0700
Committer: Leif Hedstrom <zwoop@apache.org>
Committed: Mon Mar 3 14:36:28 2014 +0000

----------------------------------------------------------------------
 iocore/dns/DNS.cc           | 28 +++++++++++++++-------------
 iocore/dns/P_DNSProcessor.h |  6 ++++--
 2 files changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfdc9854/iocore/dns/DNS.cc
----------------------------------------------------------------------
diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc
index 74d972e..5f857be 100644
--- a/iocore/dns/DNS.cc
+++ b/iocore/dns/DNS.cc
@@ -385,10 +385,12 @@ DNSEntry::init(const char *x, int len, int qtype_arg, Continuation*
acont,
       len = len > (MAXDNAME - 1) ? (MAXDNAME - 1) : len;
       memcpy(qname, x, len);
       qname_len = len;
+      orig_qname_len = qname_len;
       qname[len] = 0;
     } else {
       ink_strlcpy(qname, x, MAXDNAME);
       qname_len = strlen(qname);
+      orig_qname_len = qname_len;
     }
   } else {                    //T_PTR
     IpAddr const* ip = reinterpret_cast<IpAddr const*>(x);
@@ -1045,8 +1047,8 @@ DNSEntry::mainEvent(int event, Event *e)
       if (dns_search)
         domains = dnsH->m_res->dnsrch;
       if (domains && !strnchr(qname, '.', MAXDNAME)) {
-        qname[qname_len] = '.';
-        ink_strlcpy(qname + qname_len + 1, *domains, MAXDNAME - (qname_len + 1));
+        qname[orig_qname_len] = '.';
+        ink_strlcpy(qname + orig_qname_len + 1, *domains, MAXDNAME - (orig_qname_len + 1));
         qname_len = strlen(qname);
         ++domains;
       }
@@ -1120,29 +1122,29 @@ dns_result(DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry) {
       return;
     } else if (e->domains && *e->domains) {
       do {
-        Debug("dns", "domain extending %s", e->qname);
+        Debug("dns", "domain extending, last tried '%s', original '%.*s'", e->qname, e->orig_qname_len,
e->qname);
         //int l = _strlen(e->qname);
         char *dot = strchr(e->qname, '.');
         if (dot) {
-          if (e->qname_len + strlen(*e->domains) + 2 > MAXDNAME) {
-            Debug("dns", "domain too large %s + %s", e->qname, *e->domains);
+          if (e->orig_qname_len + strlen(*e->domains) + 2 > MAXDNAME) {
+            Debug("dns", "domain too large %.*s + %s", e->orig_qname_len, e->qname,
*e->domains);
             goto LnextDomain;
           }
-          if (e->qname[e->qname_len - 1] != '.') {
-            e->qname[e->qname_len] = '.';
-            ink_strlcpy(e->qname + e->qname_len + 1, *e->domains, MAXDNAME - (e->qname_len
+ 1));
+          if (e->qname[e->orig_qname_len - 1] != '.') {
+            e->qname[e->orig_qname_len] = '.';
+            ink_strlcpy(e->qname + e->orig_qname_len + 1, *e->domains, MAXDNAME
- (e->orig_qname_len + 1));
             e->qname_len = strlen(e->qname);
           } else {
-            ink_strlcpy(e->qname + e->qname_len, *e->domains, MAXDNAME - e->qname_len);
+            ink_strlcpy(e->qname + e->orig_qname_len, *e->domains, MAXDNAME - e->orig_qname_len);
             e->qname_len = strlen(e->qname);
           }
         } else {
-          if (e->qname_len + strlen(*e->domains) + 2 > MAXDNAME) {
-            Debug("dns", "domain too large %s + %s", e->qname, *e->domains);
+          if (e->orig_qname_len + strlen(*e->domains) + 2 > MAXDNAME) {
+            Debug("dns", "domain too large %.*s + %s", e->orig_qname_len, e->qname,
*e->domains);
             goto LnextDomain;
           }
-          e->qname[e->qname_len] = '.';
-          ink_strlcpy(e->qname + e->qname_len + 1, *e->domains, MAXDNAME - (e->qname_len
+ 1));
+          e->qname[e->orig_qname_len] = '.';
+          ink_strlcpy(e->qname + e->orig_qname_len + 1, *e->domains, MAXDNAME -
(e->orig_qname_len + 1));
           e->qname_len = strlen(e->qname);
         }
         ++(e->domains);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfdc9854/iocore/dns/P_DNSProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/dns/P_DNSProcessor.h b/iocore/dns/P_DNSProcessor.h
index 7df7e10..9cb27ea 100644
--- a/iocore/dns/P_DNSProcessor.h
+++ b/iocore/dns/P_DNSProcessor.h
@@ -156,6 +156,7 @@ struct DNSEntry: public Continuation
   ink_hrtime send_time;
   char qname[MAXDNAME];
   int qname_len;
+  int orig_qname_len;
   char **domains;
   EThread *submit_thread;
   Action action;
@@ -179,8 +180,9 @@ struct DNSEntry: public Continuation
        qtype(0),
        host_res_style(HOST_RES_NONE),
        retries(DEFAULT_DNS_RETRIES),
-       which_ns(NO_NAMESERVER_SELECTED), submit_time(0), send_time(0), qname_len(0), domains(0),
-       timeout(0), result_ent(0), dnsH(0), written_flag(false), once_written_flag(false),
last(false)
+       which_ns(NO_NAMESERVER_SELECTED), submit_time(0), send_time(0), qname_len(0),
+       orig_qname_len(0), domains(0), timeout(0), result_ent(0), dnsH(0), written_flag(false),
+       once_written_flag(false), last(false)
   {
     for (int i = 0; i < MAX_DNS_RETRIES; i++)
       id[i] = -1;


Mime
View raw message