You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2020/11/26 22:58:14 UTC
[trafficserver] branch master updated: Fix lookup split dns rule
with fast path (#7320)
This is an automated email from the ASF dual-hosted git repository.
masaori pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 4e2ac3b Fix lookup split dns rule with fast path (#7320)
4e2ac3b is described below
commit 4e2ac3b2be8b535ab89d0f5762b3201647e5efba
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Fri Nov 27 07:57:57 2020 +0900
Fix lookup split dns rule with fast path (#7320)
---
iocore/dns/P_SplitDNSProcessor.h | 8 +++++---
iocore/dns/SplitDNS.cc | 22 ++++++++++------------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/iocore/dns/P_SplitDNSProcessor.h b/iocore/dns/P_SplitDNSProcessor.h
index ef20b0e..5fa119e 100644
--- a/iocore/dns/P_SplitDNSProcessor.h
+++ b/iocore/dns/P_SplitDNSProcessor.h
@@ -32,6 +32,8 @@
#include "ProxyConfig.h"
+#include "tscore/HostLookup.h"
+
/* ---------------------------
forward declarations ...
--------------------------- */
@@ -88,9 +90,9 @@ struct SplitDNS : public ConfigInfo {
required by the alleged fast
path
---------------------------- */
- bool m_bEnableFastPath = false;
- void *m_pxLeafArray = nullptr;
- int m_numEle = 0;
+ bool m_bEnableFastPath = false;
+ HostLookup::LeafArray *m_pxLeafArray = nullptr;
+ int m_numEle = 0;
};
/* --------------------------------------------------------------
diff --git a/iocore/dns/SplitDNS.cc b/iocore/dns/SplitDNS.cc
index cf6a9b9..6747c16 100644
--- a/iocore/dns/SplitDNS.cc
+++ b/iocore/dns/SplitDNS.cc
@@ -222,7 +222,7 @@ SplitDNS::findServer(RequestData *rdata, SplitDNSResult *result)
/* ---------------------------
the 'alleged' fast path ...
--------------------------- */
- if (m_bEnableFastPath) {
+ if (m_bEnableFastPath && m_pxLeafArray) {
SplitDNSRecord *data_ptr = nullptr;
char *pHost = const_cast<char *>(rdata->get_host());
if (nullptr == pHost) {
@@ -230,30 +230,28 @@ SplitDNS::findServer(RequestData *rdata, SplitDNSResult *result)
return;
}
- int len = strlen(pHost);
- HostLeaf *pxHL = static_cast<HostLeaf *>(m_pxLeafArray);
- for (int i = 0; i < m_numEle; i++) {
- if (nullptr == pxHL) {
- break;
- }
+ int len = strlen(pHost);
+ int n = std::min(static_cast<size_t>(m_numEle), m_pxLeafArray->size());
+ for (int i = 0; i < n; i++) {
+ const HostLeaf &pxHL = m_pxLeafArray->at(i);
- if (false == pxHL[i].isNot && static_cast<int>(pxHL[i].match.size()) > len) {
+ if (false == pxHL.isNot && static_cast<int>(pxHL.match.size()) > len) {
continue;
}
- int idx = len - pxHL[i].match.size();
+ int idx = len - pxHL.match.size();
char *pH = &pHost[idx];
- const char *pMatch = pxHL[i].match.data();
+ const char *pMatch = pxHL.match.data();
char cNot = *pMatch;
if ('!' == cNot) {
pMatch++;
}
- int res = memcmp(pH, pMatch, pxHL[i].match.size());
+ int res = memcmp(pH, pMatch, pxHL.match.size());
if ((0 != res && '!' == cNot) || (0 == res && '!' != cNot)) {
- data_ptr = static_cast<SplitDNSRecord *>(pxHL[i].opaque_data);
+ data_ptr = static_cast<SplitDNSRecord *>(pxHL.opaque_data);
data_ptr->UpdateMatch(result, rdata);
break;
}