Repository: trafficserver Updated Branches: refs/heads/master add34803d -> 9212544ba
TS-3281: Add configuration option to not split local domains during name resolution domain expansion. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/9212544b Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/9212544b Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/9212544b Branch: refs/heads/master Commit: 9212544ba75508ad8fda579b81cb71e2f549b739 Parents: add3480 Author: Masaori Koshiba <[email protected]> Authored: Fri Jul 17 15:31:50 2015 -0500 Committer: Alan M. Carroll <[email protected]> Committed: Fri Jul 17 15:32:55 2015 -0500 ---------------------------------------------------------------------- .../configuration/records.config.en.rst | 4 +++- iocore/dns/DNS.cc | 4 ++-- iocore/dns/SplitDNS.cc | 3 ++- lib/ts/ink_res_init.cc | 25 +++++++++++--------- lib/ts/ink_resolver.h | 2 +- 5 files changed, 22 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9212544b/doc/reference/configuration/records.config.en.rst ---------------------------------------------------------------------- diff --git a/doc/reference/configuration/records.config.en.rst b/doc/reference/configuration/records.config.en.rst index 161676a..8ada5e1 100644 --- a/doc/reference/configuration/records.config.en.rst +++ b/doc/reference/configuration/records.config.en.rst @@ -1748,7 +1748,9 @@ DNS .. ts:cv:: CONFIG proxy.config.dns.search_default_domains INT 0 :Reloadable: - Enables (``1``) or disables (``0``) local domain expansion. + - ``0`` = disables local domain expansion + - ``1`` = enable local domain expansion + - ``2`` = enable local domain expansion, but restrain splitting local domain name Traffic Server can attempt to resolve unqualified hostnames by expanding to the local domain. For example if a client makes a http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9212544b/iocore/dns/DNS.cc ---------------------------------------------------------------------- diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc index 157e716..4601147 100644 --- a/iocore/dns/DNS.cc +++ b/iocore/dns/DNS.cc @@ -305,9 +305,9 @@ DNSProcessor::dns_init() } ats_free(ns_list); } - // The default domain (4th param) and search list (5th param) will + // The default domain (5th param) and search list (6th param) will // come from /etc/resolv.conf. - if (ink_res_init(&l_res, nameserver, nserv, NULL, NULL, dns_resolv_conf) < 0) + if (ink_res_init(&l_res, nameserver, nserv, dns_search, NULL, NULL, dns_resolv_conf) < 0) Warning("Failed to build DNS res records for the servers (%s). Using resolv.conf.", dns_ns_list); // Check for local forced bindings. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9212544b/iocore/dns/SplitDNS.cc ---------------------------------------------------------------------- diff --git a/iocore/dns/SplitDNS.cc b/iocore/dns/SplitDNS.cc index 346e4a9..6ca614f 100644 --- a/iocore/dns/SplitDNS.cc +++ b/iocore/dns/SplitDNS.cc @@ -499,7 +499,8 @@ SplitDNSRecord::Init(matcher_line *line_info) ink_res_state res = new ts_imp_res_state; memset(res, 0, sizeof(ts_imp_res_state)); - if ((-1 == ink_res_init(res, m_servers.x_server_ip, m_dnsSrvr_cnt, m_servers.x_def_domain, m_servers.x_domain_srch_list, NULL))) { + if ((-1 == ink_res_init(res, m_servers.x_server_ip, m_dnsSrvr_cnt, dns_search, m_servers.x_def_domain, + m_servers.x_domain_srch_list, NULL))) { char ab[INET6_ADDRPORTSTRLEN]; return config_parse_error("Failed to build res record for the servers %s ...", ats_ip_ntop(&m_servers.x_server_ip[0].sa, ab, sizeof ab)); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9212544b/lib/ts/ink_res_init.cc ---------------------------------------------------------------------- diff --git a/lib/ts/ink_res_init.cc b/lib/ts/ink_res_init.cc index b86b3cf..958f2dd 100644 --- a/lib/ts/ink_res_init.cc +++ b/lib/ts/ink_res_init.cc @@ -292,6 +292,7 @@ int ink_res_init(ink_res_state statp, ///< State object to update. IpEndpoint const *pHostList, ///< Additional servers. size_t pHostListSize, ///< # of entries in @a pHostList. + int dnsSearch, /// Option of search_default_domains. const char *pDefDomain, ///< Default domain (may be NULL). const char *pSearchList, ///< Unknown const char *pResolvConf ///< Path to configuration file. @@ -532,19 +533,21 @@ ink_res_init(ink_res_state statp, ///< State object to update. *pp++ = statp->defdname; *pp = NULL; - dots = 0; - for (cp = statp->defdname; *cp; cp++) - dots += (*cp == '.'); + if (dnsSearch == 1) { + dots = 0; + for (cp = statp->defdname; *cp; cp++) + dots += (*cp == '.'); - cp = statp->defdname; - while (pp < statp->dnsrch + INK_MAXDFLSRCH) { - if (dots < INK_LOCALDOMAINPARTS) - break; - cp = strchr(cp, '.') + 1; /*%< we know there is one */ - *pp++ = cp; - dots--; + cp = statp->defdname; + while (pp < statp->dnsrch + INK_MAXDFLSRCH) { + if (dots < INK_LOCALDOMAINPARTS) + break; + cp = strchr(cp, '.') + 1; /*%< we know there is one */ + *pp++ = cp; + dots--; + } + *pp = NULL; } - *pp = NULL; #ifdef DEBUG if (statp->options & INK_RES_DEBUG) { printf(";; res_init()... default dnsrch list:\n"); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9212544b/lib/ts/ink_resolver.h ---------------------------------------------------------------------- diff --git a/lib/ts/ink_resolver.h b/lib/ts/ink_resolver.h index 314676b..5d2546a 100644 --- a/lib/ts/ink_resolver.h +++ b/lib/ts/ink_resolver.h @@ -266,7 +266,7 @@ struct ts_imp_res_state { }; typedef ts_imp_res_state *ink_res_state; -int ink_res_init(ink_res_state, IpEndpoint const *pHostList, size_t pHostListSize, const char *pDefDomain = NULL, +int ink_res_init(ink_res_state, IpEndpoint const *pHostList, size_t pHostListSize, int dnsSearch, const char *pDefDomain = NULL, const char *pSearchList = NULL, const char *pResolvConf = NULL); int ink_res_mkquery(ink_res_state, int, const char *, int, int, const unsigned char *, int, const unsigned char *, unsigned char *,
