diff --git a/cmd/traffic_manager/AddConfigFilesHere.cc b/cmd/traffic_manager/AddConfigFilesHere.cc index 0bc2bd0256d..f6202041492 100644 --- a/cmd/traffic_manager/AddConfigFilesHere.cc +++ b/cmd/traffic_manager/AddConfigFilesHere.cc @@ -67,7 +67,6 @@ initializeRegistry() configFiles->addFile("socks.config", false); configFiles->addFile("records.config", false); configFiles->addFile("cache.config", false); - configFiles->addFile("icp.config", false); configFiles->addFile("ip_allow.config", false); configFiles->addFile("parent.config", false); configFiles->addFile("remap.config", false); diff --git a/cmd/traffic_via/tests/[u c s f p eS;tNc i p s ] b/cmd/traffic_via/tests/[u c s f p eS;tNc p s ] similarity index 87% rename from cmd/traffic_via/tests/[u c s f p eS;tNc i p s ] rename to cmd/traffic_via/tests/[u c s f p eS;tNc p s ] index bc130d948b7..f574eb27b06 100644 --- a/cmd/traffic_via/tests/[u c s f p eS;tNc i p s ] +++ b/cmd/traffic_via/tests/[u c s f p eS;tNc p s ] @@ -1,4 +1,4 @@ -Via header is [u c s f p eS;tNc i p s ], Length is 26 +Via header is [u c s f p eS;tNc p s ], Length is 25 Via Header Details: Request headers received from client :unknown Result of Traffic Server cache lookup for URL :no cache lookup @@ -9,6 +9,5 @@ Error codes (if any) :server related error Tunnel info :tunneling due to no forward Cache Type :unknown Cache Lookup Result :cache miss or no cache lookup -ICP status :no icp Parent proxy connection status :no parent proxy or unknown Origin server connection status :no server connection needed diff --git a/cmd/traffic_via/tests/[uIcRs f p eN;t cCHi p s ] b/cmd/traffic_via/tests/[uIcRs f p eN;t cCH p s ] similarity index 87% rename from cmd/traffic_via/tests/[uIcRs f p eN;t cCHi p s ] rename to cmd/traffic_via/tests/[uIcRs f p eN;t cCH p s ] index ad67e0d6f78..e7b47996b23 100644 --- a/cmd/traffic_via/tests/[uIcRs f p eN;t cCHi p s ] +++ b/cmd/traffic_via/tests/[uIcRs f p eN;t cCH p s ] @@ -1,4 +1,4 @@ -Via header is [uIcRs f p eN;t cCHi p s ], Length is 26 +Via header is [uIcRs f p eN;t cCH p s ], Length is 25 Via Header Details: Request headers received from client :IMS Result of Traffic Server cache lookup for URL :in cache, fresh Ram hit (a cache "HIT") @@ -9,6 +9,5 @@ Error codes (if any) :no error Tunnel info :no tunneling Cache Type :cache Cache Lookup Result :cache hit -ICP status :no icp Parent proxy connection status :no parent proxy or unknown Origin server connection status :no server connection needed diff --git a/cmd/traffic_via/tests/[uIcRs f p eN;t cCNi p s ] b/cmd/traffic_via/tests/[uIcRs f p eN;t cCN p s ] similarity index 88% rename from cmd/traffic_via/tests/[uIcRs f p eN;t cCNi p s ] rename to cmd/traffic_via/tests/[uIcRs f p eN;t cCN p s ] index c7140d3f289..d3d3860b2b9 100644 --- a/cmd/traffic_via/tests/[uIcRs f p eN;t cCNi p s ] +++ b/cmd/traffic_via/tests/[uIcRs f p eN;t cCN p s ] @@ -1,4 +1,4 @@ -Via header is [uIcRs f p eN;t cCNi p s ], Length is 26 +Via header is [uIcRs f p eN;t cCN p s ], Length is 25 Via Header Details: Request headers received from client :IMS Result of Traffic Server cache lookup for URL :in cache, fresh Ram hit (a cache "HIT") @@ -9,6 +9,5 @@ Error codes (if any) :no error Tunnel info :no tunneling Cache Type :cache Cache Lookup Result :conditional hit (client sent conditional, doc fresh in cache, returned 304) -ICP status :no icp Parent proxy connection status :no parent proxy or unknown Origin server connection status :no server connection needed diff --git a/cmd/traffic_via/tests/[uScMsSf pSeN;t cCMi p sS] b/cmd/traffic_via/tests/[uScMsSf pSeN;t cCM p sS] similarity index 88% rename from cmd/traffic_via/tests/[uScMsSf pSeN;t cCMi p sS] rename to cmd/traffic_via/tests/[uScMsSf pSeN;t cCM p sS] index 0940e12b003..e4bee740156 100644 --- a/cmd/traffic_via/tests/[uScMsSf pSeN;t cCMi p sS] +++ b/cmd/traffic_via/tests/[uScMsSf pSeN;t cCM p sS] @@ -1,4 +1,4 @@ -Via header is [uScMsSf pSeN;t cCMi p sS], Length is 26 +Via header is [uScMsSf pSeN;t cCM p sS], Length is 25 Via Header Details: Request headers received from client :simple request (not conditional) Result of Traffic Server cache lookup for URL :miss (a cache "MISS") @@ -9,6 +9,5 @@ Error codes (if any) :no error Tunnel info :no tunneling Cache Type :cache Cache Lookup Result :cache miss (url not in cache) -ICP status :no icp Parent proxy connection status :no parent proxy or unknown Origin server connection status :connection opened successfully diff --git a/cmd/traffic_via/tests/[uScRs f p eN;t cCHi p s ] b/cmd/traffic_via/tests/[uScRs f p eN;t cCH p s ] similarity index 87% rename from cmd/traffic_via/tests/[uScRs f p eN;t cCHi p s ] rename to cmd/traffic_via/tests/[uScRs f p eN;t cCH p s ] index 0ee3ff981ed..e587c1a2e71 100644 --- a/cmd/traffic_via/tests/[uScRs f p eN;t cCHi p s ] +++ b/cmd/traffic_via/tests/[uScRs f p eN;t cCH p s ] @@ -1,4 +1,4 @@ -Via header is [uScRs f p eN;t cCHi p s ], Length is 26 +Via header is [uScRs f p eN;t cCH p s ], Length is 25 Via Header Details: Request headers received from client :simple request (not conditional) Result of Traffic Server cache lookup for URL :in cache, fresh Ram hit (a cache "HIT") @@ -9,6 +9,5 @@ Error codes (if any) :no error Tunnel info :no tunneling Cache Type :cache Cache Lookup Result :cache hit -ICP status :no icp Parent proxy connection status :no parent proxy or unknown Origin server connection status :no server connection needed diff --git a/cmd/traffic_via/tests/long rubbish via code 24 b/cmd/traffic_via/tests/long rubbish via code 2 similarity index 93% rename from cmd/traffic_via/tests/long rubbish via code 24 rename to cmd/traffic_via/tests/long rubbish via code 2 index 536f4ad161c..b8f47efa30a 100644 --- a/cmd/traffic_via/tests/long rubbish via code 24 +++ b/cmd/traffic_via/tests/long rubbish via code 2 @@ -12,6 +12,6 @@ traffic_via: Invalid VIA header character: i traffic_via: Invalid VIA header character: a traffic_via: Invalid VIA header character: o traffic_via: Invalid VIA header character: d -Via header is long rubbish via code 24, Length is 24 +Via header is long rubbish via code 2, Length is 23 Via Header Details: Error codes (if any) :unknown diff --git a/cmd/traffic_via/tests/rubbish b/cmd/traffic_via/tests/rubbish index f3de8e9a791..51066c11576 100644 --- a/cmd/traffic_via/tests/rubbish +++ b/cmd/traffic_via/tests/rubbish @@ -1,4 +1,4 @@ Via header is rubbish, Length is 7 -Invalid VIA header. VIA header length should be 6 or 24 characters -Valid via header format is [ucsfp]e:tcips] \ No newline at end of file +Invalid VIA header. VIA header length should be 6 or 23 characters +Valid via header format is [ucsfpe:tcps] diff --git a/cmd/traffic_via/traffic_via.cc b/cmd/traffic_via/traffic_via.cc index e5c65ffeb46..882c8788a08 100644 --- a/cmd/traffic_via/traffic_via.cc +++ b/cmd/traffic_via/traffic_via.cc @@ -72,7 +72,7 @@ detailViaLookup(char flag) // Cache type viaTable = new VIA("Cache Type"); viaTable->viaData[(unsigned char)'C'] = "cache"; - viaTable->viaData[(unsigned char)'I'] = "icp"; + viaTable->viaData[(unsigned char)'L'] = "cluster, (not used)"; viaTable->viaData[(unsigned char)'P'] = "parent"; viaTable->viaData[(unsigned char)'S'] = "server"; viaTable->viaData[(unsigned char)' '] = "unknown"; @@ -90,12 +90,6 @@ detailViaLookup(char flag) viaTable->next->viaData[(unsigned char)'S'] = "cache hit, but expired"; viaTable->next->viaData[(unsigned char)'K'] = "cookie miss"; break; - case 'i': - viaTable = new VIA("ICP status"); - viaTable->viaData[(unsigned char)' '] = "no icp"; - viaTable->viaData[(unsigned char)'S'] = "connection opened successfully"; - viaTable->viaData[(unsigned char)'F'] = "connection open failed"; - break; case 'p': viaTable = new VIA("Parent proxy connection status"); viaTable->viaData[(unsigned char)' '] = "no parent proxy or unknown"; @@ -243,16 +237,16 @@ decodeViaHeader(const char *str) ++viaHdrLength; } - if (viaHdrLength == 24 || viaHdrLength == 6) { + if (viaHdrLength == 23 || viaHdrLength == 6) { // Decode via header printViaHeader(Via); return TS_ERR_OKAY; } // Invalid header size, come out. - printf("\nInvalid VIA header. VIA header length should be 6 or 24 characters\n"); + printf("\nInvalid VIA header. VIA header length should be 6 or 23 characters\n"); printf("Valid via header format is " - "[ucsfp]e:tc<" - "cache type>ips]"); + "[ucsfpe:tc<" + "cache type>ps]\n"); return TS_ERR_FAIL; } diff --git a/doc/.tx/config b/doc/.tx/config index 7a8686bf155..5fce4b57559 100644 --- a/doc/.tx/config +++ b/doc/.tx/config @@ -82,11 +82,6 @@ file_filter = locale//LC_MESSAGES/admin-guide/files/hosting.config.en.po source_file = _build/locale/pot/admin-guide/files/hosting.config.en.pot source_lang = en -[apache-traffic-server-6x.admin-guide--files--icp_config_en] -file_filter = locale//LC_MESSAGES/admin-guide/files/icp.config.en.po -source_file = _build/locale/pot/admin-guide/files/icp.config.en.pot -source_lang = en - [apache-traffic-server-6x.admin-guide--files--index_en] file_filter = locale//LC_MESSAGES/admin-guide/files/index.en.po source_file = _build/locale/pot/admin-guide/files/index.en.pot diff --git a/doc/appendices/faq.en.rst b/doc/appendices/faq.en.rst index b58ea552c45..09bcbb6f9cf 100644 --- a/doc/appendices/faq.en.rst +++ b/doc/appendices/faq.en.rst @@ -143,7 +143,7 @@ Via: HTTP/1.0 storm (Traffic-Server/4.0.0 [cMs f ]) The short status code shows the cache-lookup, server-info and cache-fill information as listed in the full status code description below. The long status code list provided in older, commercial versions of Traffic Server can be restored by setting the verbose_via_str config variable. The character strings in the via-code show [:] where represents status information about the results of the client request and represent some information about the proxy operations performed during request processing. The full via-code status format is -[u c s f p e : tc i p s] +[u c s f p e : tc p s] u client-info diff --git a/doc/locale/ja/LC_MESSAGES/appendices/faq.en.po b/doc/locale/ja/LC_MESSAGES/appendices/faq.en.po index 756ea6be487..1c2925dac31 100644 --- a/doc/locale/ja/LC_MESSAGES/appendices/faq.en.po +++ b/doc/locale/ja/LC_MESSAGES/appendices/faq.en.po @@ -383,12 +383,12 @@ msgstr "" #: ../../../appendices/faq.en.rst:146 msgid "" "[u c s f p " -"e : tc i p s]" +"e : tc " +"p s]" msgstr "" "[u c s f p " -"e : tc i p s]" +"e : tc " +"p s]" #: ../../../appendices/faq.en.rst:150 msgid "u client-info" diff --git a/iocore/cache/I_CacheDefs.h b/iocore/cache/I_CacheDefs.h index 06564d68417..667271fa273 100644 --- a/iocore/cache/I_CacheDefs.h +++ b/iocore/cache/I_CacheDefs.h @@ -34,7 +34,7 @@ #define CACHE_ALT_REMOVED -2 #define CACHE_DB_MAJOR_VERSION 24 -#define CACHE_DB_MINOR_VERSION 0 +#define CACHE_DB_MINOR_VERSION 1 #define CACHE_DIR_MAJOR_VERSION 18 #define CACHE_DIR_MINOR_VERSION 0 diff --git a/iocore/eventsystem/I_Event.h b/iocore/eventsystem/I_Event.h index 090c677062f..368e7e8d838 100644 --- a/iocore/eventsystem/I_Event.h +++ b/iocore/eventsystem/I_Event.h @@ -68,7 +68,6 @@ #define HTTP_NET_CONNECTION_EVENT_EVENTS_START 1400 #define HTTP_NET_VCONNECTION_EVENT_EVENTS_START 1500 #define GC_EVENT_EVENTS_START 1600 -#define ICP_EVENT_EVENTS_START 1800 #define TRANSFORM_EVENTS_START 2000 #define STAT_PAGES_EVENTS_START 2100 #define HTTP_SESSION_EVENTS_START 2200 diff --git a/lib/cppapi/HttpMethod.cc b/lib/cppapi/HttpMethod.cc index 8bde5004f7b..16a13c22d5d 100644 --- a/lib/cppapi/HttpMethod.cc +++ b/lib/cppapi/HttpMethod.cc @@ -22,7 +22,7 @@ #include "atscppapi/HttpMethod.h" -const std::string atscppapi::HTTP_METHOD_STRINGS[] = {std::string("UNKNOWN"), std::string("GET"), std::string("POST"), - std::string("HEAD"), std::string("CONNECT"), std::string("DELETE"), - std::string("ICP_QUERY"), std::string("OPTIONS"), std::string("PURGE"), - std::string("PUT"), std::string("TRACE"), std::string("PUSH")}; +const std::string atscppapi::HTTP_METHOD_STRINGS[] = {std::string("UNKNOWN"), std::string("GET"), std::string("POST"), + std::string("HEAD"), std::string("CONNECT"), std::string("DELETE"), + std::string("OPTIONS"), std::string("PURGE"), std::string("PUT"), + std::string("TRACE"), std::string("PUSH")}; diff --git a/lib/cppapi/include/atscppapi/HttpMethod.h b/lib/cppapi/include/atscppapi/HttpMethod.h index 7dc3b3ddde4..94d0a249b75 100644 --- a/lib/cppapi/include/atscppapi/HttpMethod.h +++ b/lib/cppapi/include/atscppapi/HttpMethod.h @@ -38,7 +38,6 @@ enum HttpMethod { HTTP_METHOD_HEAD, HTTP_METHOD_CONNECT, HTTP_METHOD_DELETE, - HTTP_METHOD_ICP_QUERY, HTTP_METHOD_OPTIONS, HTTP_METHOD_PURGE, HTTP_METHOD_PUT, diff --git a/lib/perl/lib/Apache/TS/AdminClient.pm b/lib/perl/lib/Apache/TS/AdminClient.pm index 9676f8d5223..42b31283f30 100644 --- a/lib/perl/lib/Apache/TS/AdminClient.pm +++ b/lib/perl/lib/Apache/TS/AdminClient.pm @@ -533,16 +533,6 @@ The Apache Traffic Server Administration Manual will explain what these strings proxy.config.http.transaction_no_activity_timeout_out proxy.config.http_ui_enabled proxy.config.http.uncacheable_requests_bypass_parent - proxy.config.icp.default_reply_port - proxy.config.icp.enabled - proxy.config.icp.icp_configuration - proxy.config.icp.icp_interface - proxy.config.icp.icp_port - proxy.config.icp.lookup_local - proxy.config.icp.multicast_enabled - proxy.config.icp.query_timeout - proxy.config.icp.reply_to_unknown_peer - proxy.config.icp.stale_icp_enabled proxy.config.io.max_buffer_size proxy.config.lm.pserver_timeout_msecs proxy.config.lm.pserver_timeout_secs diff --git a/mgmt/api/APITestCliRemote.cc b/mgmt/api/APITestCliRemote.cc index e3c96e4fc28..df0389fb00e 100644 --- a/mgmt/api/APITestCliRemote.cc +++ b/mgmt/api/APITestCliRemote.cc @@ -474,32 +474,6 @@ print_hosting_ele(TSHostingEle *ele) print_int_list(ele->volumes); } -void -print_icp_ele(TSIcpEle *ele) -{ - if (!ele) { - printf("can't print ele\n"); - return; - } - - int peer_type; - - switch (ele->peer_type) { - case TS_ICP_PARENT: - peer_type = 1; - break; - case TS_ICP_SIBLING: - peer_type = 2; - break; - - default: - peer_type = 10; - } - - printf("%s:%s:%d:%d:%d:%d:%s:%d:\n", ele->peer_hostname, ele->peer_host_ip_addr, peer_type, ele->peer_proxy_port, - ele->peer_icp_port, (ele->is_multicast ? 1 : 0), ele->mc_ip_addr, (ele->mc_ttl == TS_MC_TTL_SINGLE_SUBNET ? 1 : 2)); -} - void print_ip_allow_ele(TSIpAllowEle *ele) { @@ -789,9 +763,6 @@ print_ele_list(TSFileNameT file, TSCfgContext ctx) case TS_FNAME_HOSTING: print_hosting_ele((TSHostingEle *)ele); break; - case TS_FNAME_ICP_PEER: - print_icp_ele((TSIcpEle *)ele); - break; case TS_FNAME_IP_ALLOW: print_ip_allow_ele((TSIpAllowEle *)ele); break; @@ -1449,8 +1420,6 @@ test_cfg_context_get(char *args) file = TS_FNAME_CONGESTION; } else if (strcmp(name, "hosting.config") == 0) { file = TS_FNAME_HOSTING; - } else if (strcmp(name, "icp.config") == 0) { - file = TS_FNAME_ICP_PEER; } else if (strcmp(name, "ip_allow.config") == 0) { file = TS_FNAME_IP_ALLOW; } else if (strcmp(name, "parent.config") == 0) { @@ -1515,8 +1484,6 @@ test_cfg_context_move(char *args) file = TS_FNAME_CONGESTION; } else if (strcmp(name, "hosting.config") == 0) { file = TS_FNAME_HOSTING; - } else if (strcmp(name, "icp.config") == 0) { - file = TS_FNAME_ICP_PEER; } else if (strcmp(name, "ip_allow.config") == 0) { file = TS_FNAME_IP_ALLOW; } else if (strcmp(name, "parent.config") == 0) { diff --git a/mgmt/api/CfgContextImpl.cc b/mgmt/api/CfgContextImpl.cc index c8191c1bafc..bf88dad8711 100644 --- a/mgmt/api/CfgContextImpl.cc +++ b/mgmt/api/CfgContextImpl.cc @@ -615,248 +615,6 @@ HostingObj::getCfgEleCopy() return (TSCfgEle *)copy_hosting_ele(m_ele); } -//-------------------------------------------------------------------------- -// IcpObj -//-------------------------------------------------------------------------- -IcpObj::IcpObj(TSIcpEle *ele) -{ - m_ele = ele; - m_valid = true; - m_valid = isValid(); -} - -IcpObj::IcpObj(TokenList *tokens) -{ - Token *token; - int i; - - m_ele = TSIcpEleCreate(); - m_ele->cfg_ele.error = TS_ERR_OKAY; - m_valid = true; - - if (!tokens || tokens->length < 8) { - goto FORMAT_ERR; - } - - m_ele->cfg_ele.type = get_rule_type(tokens, TS_FNAME_ICP_PEER); - if (m_ele->cfg_ele.type == TS_TYPE_UNDEFINED) { - goto FORMAT_ERR; - } - - token = tokens->first(); - - for (i = 0; i < 8; i++) { - if (!token->name || token->value) { - goto FORMAT_ERR; - } - char *alias = token->name; - - unsigned short cache_type; - int mc_ttl; - int is_multicast; - - switch (i) { - case 0: - if (strlen(alias) > 0) { - m_ele->peer_hostname = ats_strdup(alias); - } - break; - case 1: - if (strlen(alias) > 0) { - m_ele->peer_host_ip_addr = string_to_ip_addr(alias); - if (!m_ele->peer_host_ip_addr) { - goto FORMAT_ERR; - } - } - break; - case 2: - cache_type = ink_atoi(alias); // what if failed? - switch (cache_type) { - case 1: - m_ele->peer_type = TS_ICP_PARENT; - break; - case 2: - m_ele->peer_type = TS_ICP_SIBLING; - break; - default: - m_ele->peer_type = TS_ICP_UNDEFINED; - } - break; - case 3: - m_ele->peer_proxy_port = ink_atoi(alias); - break; - case 4: - m_ele->peer_icp_port = ink_atoi(alias); - break; - case 5: - is_multicast = ink_atoi(alias); - switch (is_multicast) { - case 0: - m_ele->is_multicast = false; - break; - case 1: - m_ele->is_multicast = true; - break; - default: - // ERROR:MC_on can only be either 0 or 1 - goto FORMAT_ERR; - } - break; - case 6: - m_ele->mc_ip_addr = string_to_ip_addr(alias); - if (!m_ele->mc_ip_addr) { - goto FORMAT_ERR; - } - break; - case 7: - mc_ttl = ink_atoi(alias); - switch (mc_ttl) { - case 1: - m_ele->mc_ttl = TS_MC_TTL_SINGLE_SUBNET; - break; - case 2: - m_ele->mc_ttl = TS_MC_TTL_MULT_SUBNET; - break; - default: - m_ele->mc_ttl = TS_MC_TTL_UNDEFINED; - } - break; - default: - goto FORMAT_ERR; - } - token = tokens->next(token); - } - - return; - -FORMAT_ERR: - m_ele->cfg_ele.error = TS_ERR_INVALID_CONFIG_RULE; - m_valid = false; -} - -IcpObj::~IcpObj() -{ - TSIcpEleDestroy(m_ele); -} - -char * -IcpObj::formatEleToRule() -{ - char *ip_str1, *ip_str2; - char buf[MAX_RULE_SIZE]; - int peer_type = 0; - - if (!isValid()) { - m_ele->cfg_ele.error = TS_ERR_INVALID_CONFIG_RULE; - return nullptr; - } - - memset(buf, 0, MAX_RULE_SIZE); - - switch (m_ele->peer_type) { - case TS_ICP_PARENT: - peer_type = 1; - break; - case TS_ICP_SIBLING: - peer_type = 2; - break; - default: - // Handled here: - // TS_ICP_UNDEFINED - break; - } - - // optional field - if (m_ele->peer_host_ip_addr) { - ip_str1 = ip_addr_to_string(m_ele->peer_host_ip_addr); - } else { - ip_str1 = ats_strdup(""); - } - - // optional field - if (m_ele->mc_ip_addr) { - ip_str2 = ip_addr_to_string(m_ele->mc_ip_addr); - } else { - ip_str2 = ats_strdup("0.0.0.0"); - } - - if (m_ele->peer_hostname) { - snprintf(buf, sizeof(buf), "%s:%s:%d:%d:%d:%d:%s:", m_ele->peer_hostname, ip_str1, peer_type, m_ele->peer_proxy_port, - m_ele->peer_icp_port, (m_ele->is_multicast ? 1 : 0), ip_str2); - } else { - snprintf(buf, sizeof(buf), ":%s:%d:%d:%d:%d:%s:", ip_str1, peer_type, m_ele->peer_proxy_port, m_ele->peer_icp_port, - (m_ele->is_multicast ? 1 : 0), ip_str2); - } - - switch (m_ele->mc_ttl) { - case TS_MC_TTL_SINGLE_SUBNET: - ink_strlcat(buf, "1:", sizeof(buf)); - break; - case TS_MC_TTL_MULT_SUBNET: - ink_strlcat(buf, "2:", sizeof(buf)); - break; - case TS_MC_TTL_UNDEFINED: - ink_strlcat(buf, "0:", sizeof(buf)); - break; - } - - ats_free(ip_str1); - ats_free(ip_str2); - - return ats_strdup(buf); -} - -bool -IcpObj::isValid() -{ - if (m_ele->cfg_ele.error != TS_ERR_OKAY) { - m_valid = false; - } - // either hostname or IP must be specified - if (!m_ele->peer_hostname && !m_ele->peer_host_ip_addr) { - m_valid = false; - } - // check valid host IP - if (m_ele->peer_host_ip_addr && !ccu_checkIpAddr(m_ele->peer_host_ip_addr)) { - m_valid = false; - } - // check valid cache type - if (m_ele->peer_type == TS_ICP_UNDEFINED) { - m_valid = false; - } - // check valid ports - if (!ccu_checkPortNum(m_ele->peer_proxy_port)) { - m_valid = false; - } - - if (!ccu_checkPortNum(m_ele->peer_icp_port)) { - m_valid = false; - } - // check valid multicast values: mc_ttl, mc_ip, if enabled - if (m_ele->is_multicast) { - // a valid multicast address must be between 224.0.0.0-239.255.255.255 - if (!ccu_checkIpAddr(m_ele->mc_ip_addr, "224.0.0.0", "239.255.255.255") || m_ele->mc_ttl == TS_MC_TTL_UNDEFINED) { - m_valid = false; - } - } else { // multicast disabled; only valid mc ip is "0.0.0.0" - if (m_ele->mc_ip_addr && strcmp(m_ele->mc_ip_addr, "0.0.0.0") != 0) { - m_valid = false; - } - } - - if (!m_valid) { - m_ele->cfg_ele.error = TS_ERR_INVALID_CONFIG_RULE; - } - - return m_valid; -} - -TSCfgEle * -IcpObj::getCfgEleCopy() -{ - return (TSCfgEle *)copy_icp_ele(m_ele); -} - //-------------------------------------------------------------------------- // IpAllowObj //-------------------------------------------------------------------------- diff --git a/mgmt/api/CfgContextImpl.h b/mgmt/api/CfgContextImpl.h index 6a236b51050..93b1e09279a 100644 --- a/mgmt/api/CfgContextImpl.h +++ b/mgmt/api/CfgContextImpl.h @@ -177,32 +177,6 @@ class HostingObj : public CfgEleObj TSHostingEle *m_ele; }; -/* icp.config ************************************************/ -class IcpObj : public CfgEleObj -{ -public: - IcpObj(TSIcpEle *ele); - IcpObj(TokenList *tokens); // creates the ele - ~IcpObj(); - - virtual char *formatEleToRule(); - virtual bool isValid(); - virtual TSCfgEle *getCfgEleCopy(); - virtual TSCfgEle * - getCfgEle() - { - return (TSCfgEle *)m_ele; - } - virtual TSRuleTypeT - getRuleType() - { - return m_ele->cfg_ele.type; - } - -private: - TSIcpEle *m_ele; -}; - /* ip_allow.config *********************************************/ class IpAllowObj : public CfgEleObj { diff --git a/mgmt/api/CfgContextUtils.cc b/mgmt/api/CfgContextUtils.cc index a674c0bd900..54d3ca116a6 100644 --- a/mgmt/api/CfgContextUtils.cc +++ b/mgmt/api/CfgContextUtils.cc @@ -1463,8 +1463,6 @@ filename_to_string(TSFileNameT file) return "congestion.config"; case TS_FNAME_HOSTING: return "hosting.config"; - case TS_FNAME_ICP_PEER: - return "icp.config"; case TS_FNAME_IP_ALLOW: return "ip_allow.config"; case TS_FNAME_PARENT_PROXY: @@ -1962,9 +1960,6 @@ create_ele_obj_from_rule_node(Rule *rule) case TS_HOSTING: /* hosting.config */ ele = (CfgEleObj *)new HostingObj(token_list); break; - case TS_ICP: /* icp.config */ - ele = (CfgEleObj *)new IcpObj(token_list); - break; case TS_IP_ALLOW: /* ip_allow.config */ ele = (CfgEleObj *)new IpAllowObj(token_list); break; @@ -2042,10 +2037,6 @@ create_ele_obj_from_ele(TSCfgEle *ele) ele_obj = (CfgEleObj *)new HostingObj((TSHostingEle *)ele); break; - case TS_ICP: /* icp.config */ - ele_obj = (CfgEleObj *)new IcpObj((TSIcpEle *)ele); - break; - case TS_IP_ALLOW: /* ip_allow.config */ ele_obj = (CfgEleObj *)new IpAllowObj((TSIpAllowEle *)ele); break; @@ -2147,9 +2138,6 @@ get_rule_type(TokenList *token_list, TSFileNameT file) case TS_FNAME_HOSTING: /* hosting.config */ return TS_HOSTING; - case TS_FNAME_ICP_PEER: /* icp.config */ - return TS_ICP; - case TS_FNAME_IP_ALLOW: /* ip_allow.config */ return TS_IP_ALLOW; @@ -2535,37 +2523,6 @@ copy_hosting_ele(TSHostingEle *ele) return nele; } -TSIcpEle * -copy_icp_ele(TSIcpEle *ele) -{ - if (!ele) { - return nullptr; - } - - TSIcpEle *nele = TSIcpEleCreate(); - if (!nele) { - return nullptr; - } - - copy_cfg_ele(&(ele->cfg_ele), &(nele->cfg_ele)); - if (ele->peer_hostname) { - nele->peer_hostname = ats_strdup(ele->peer_hostname); - } - if (ele->peer_host_ip_addr) { - nele->peer_host_ip_addr = ats_strdup(ele->peer_host_ip_addr); - } - nele->peer_type = ele->peer_type; - nele->peer_proxy_port = ele->peer_proxy_port; - nele->peer_icp_port = ele->peer_icp_port; - nele->is_multicast = ele->is_multicast; - if (ele->mc_ip_addr) { - nele->mc_ip_addr = ats_strdup(ele->mc_ip_addr); - } - nele->mc_ttl = ele->mc_ttl; - - return nele; -} - TSIpAllowEle * copy_ip_allow_ele(TSIpAllowEle *ele) { diff --git a/mgmt/api/CfgContextUtils.h b/mgmt/api/CfgContextUtils.h index 1c1ab55ab4f..a19ca189d51 100644 --- a/mgmt/api/CfgContextUtils.h +++ b/mgmt/api/CfgContextUtils.h @@ -175,7 +175,6 @@ TSIntList copy_int_list(TSIntList list); TSCacheEle *copy_cache_ele(TSCacheEle *ele); TSCongestionEle *copy_congestion_ele(TSCongestionEle *ele); TSHostingEle *copy_hosting_ele(TSHostingEle *ele); -TSIcpEle *copy_icp_ele(TSIcpEle *ele); TSIpAllowEle *copy_ip_allow_ele(TSIpAllowEle *ele); TSParentProxyEle *copy_parent_proxy_ele(TSParentProxyEle *ele); TSVolumeEle *copy_volume_ele(TSVolumeEle *ele); diff --git a/mgmt/api/GenericParser.cc b/mgmt/api/GenericParser.cc index b49a048c08f..8ad94953172 100644 --- a/mgmt/api/GenericParser.cc +++ b/mgmt/api/GenericParser.cc @@ -202,8 +202,6 @@ Rule::parse(const char *const_rule, TSFileNameT filetype) return congestionParse(rule, 1, 15); case TS_FNAME_HOSTING: /* hosting.config */ return hostingParse(rule); - case TS_FNAME_ICP_PEER: /* icp.config */ - return icpParse(rule, 8, 8); case TS_FNAME_IP_ALLOW: /* ip_allow.config */ return ip_allowParse(rule); case TS_FNAME_PARENT_PROXY: /* parent.config */ @@ -388,41 +386,6 @@ Rule::hostingParse(char *rule) return cacheParse(rule, 2, 2); } -/** - * icpParse - * - mimic proxy/ICPConfig/icp_config_change_callback - **/ -TokenList * -Rule::icpParse(char *rule, unsigned short minNumToken, unsigned short maxNumToken) -{ - Tokenizer ruleTok(":"); - int numRuleTok = ruleTok.Initialize(rule, ALLOW_EMPTY_TOKS); - tok_iter_state ruleTok_state; - const char *tokenStr = ruleTok.iterFirst(&ruleTok_state); - Token *token; - TokenList *m_tokenList; - - // Sanity Check -- number of token - if (numRuleTok < minNumToken) { - setErrorHint("Expecting more ':' delimited tokens!"); - return nullptr; - } - if (numRuleTok > maxNumToken + 1 || - (numRuleTok == maxNumToken + 1 && strspn(ruleTok[maxNumToken], " ") != strlen(ruleTok[maxNumToken]))) { - setErrorHint("Expecting less ':' delimited tokens!"); - return nullptr; - } - - m_tokenList = new TokenList(); - for (; tokenStr; tokenStr = ruleTok.iterNext(&ruleTok_state)) { - token = new Token(); - token->setName(tokenStr); - m_tokenList->enqueue(token); - } - - return m_tokenList; -} - /** * ip_allowParse **/ @@ -880,8 +843,6 @@ RuleList::parse(char *fileBuf, const char *filename) m_filetype = TS_FNAME_CONGESTION; /* congestion.config */ } else if (strstr(filename, "hosting.config")) { m_filetype = TS_FNAME_HOSTING; /* hosting.config */ - } else if (strstr(filename, "icp.config")) { - m_filetype = TS_FNAME_ICP_PEER; /* icp.config */ } else if (strstr(filename, "ip_allow.config")) { m_filetype = TS_FNAME_IP_ALLOW; /* ip_allow.config */ } else if (strstr(filename, "parent.config")) { diff --git a/mgmt/api/GenericParser.h b/mgmt/api/GenericParser.h index 2737a9bb7d0..91ec10482bc 100644 --- a/mgmt/api/GenericParser.h +++ b/mgmt/api/GenericParser.h @@ -205,7 +205,6 @@ class Rule TokenList *cacheParse(char *rule, unsigned short minNumToken = MIN_CONFIG_TOKEN, unsigned short maxNumToken = MAX_CONFIG_TOKEN); TokenList *congestionParse(char *rule, unsigned short minNumToken = MIN_CONFIG_TOKEN, unsigned short maxNumToken = MAX_CONFIG_TOKEN); - TokenList *icpParse(char *rule, unsigned short minNumToken = MIN_CONFIG_TOKEN, unsigned short maxNumToken = MAX_CONFIG_TOKEN); TokenList *parentParse(char *rule); TokenList *remapParse(char *rule); TokenList *socksParse(char *rule); diff --git a/mgmt/api/INKMgmtAPI.cc b/mgmt/api/INKMgmtAPI.cc index 7eac29d4b48..f2be0bfea19 100644 --- a/mgmt/api/INKMgmtAPI.cc +++ b/mgmt/api/INKMgmtAPI.cc @@ -1009,41 +1009,6 @@ TSHostingEleDestroy(TSHostingEle *ele) return; } -/*------------------------------------------------------------- - * IcpObject - *-------------------------------------------------------------*/ -tsapi TSIcpEle * -TSIcpEleCreate() -{ - TSIcpEle *ele = (TSIcpEle *)ats_malloc(sizeof(TSIcpEle)); - - /* set defaults */ - ele->cfg_ele.type = TS_ICP; - ele->cfg_ele.error = TS_ERR_OKAY; - ele->peer_hostname = nullptr; - ele->peer_host_ip_addr = TS_INVALID_IP_ADDR; - ele->peer_type = TS_ICP_UNDEFINED; - ele->peer_proxy_port = TS_INVALID_PORT; - ele->peer_icp_port = TS_INVALID_PORT; - ele->is_multicast = false; - ele->mc_ip_addr = TS_INVALID_IP_ADDR; - ele->mc_ttl = TS_MC_TTL_SINGLE_SUBNET; // default value - - return ele; -} - -tsapi void -TSIcpEleDestroy(TSIcpEle *ele) -{ - if (ele) { - ats_free(ele->peer_hostname); - ats_free(ele->peer_host_ip_addr); - ats_free(ele->mc_ip_addr); - ats_free(ele); - } - return; -} - /*------------------------------------------------------------- * TSIpAllowEle *-------------------------------------------------------------*/ diff --git a/mgmt/api/include/mgmtapi.h b/mgmt/api/include/mgmtapi.h index a50ee77eed1..8d09b88debd 100644 --- a/mgmt/api/include/mgmtapi.h +++ b/mgmt/api/include/mgmtapi.h @@ -203,11 +203,6 @@ typedef enum /* header information types */ TS_HDR_CLIENT_IP, TS_HDR_UNDEFINED } TSHdrT; -typedef enum /* indicate if ICP parent cache or ICP sibling cache */ -{ TS_ICP_PARENT, - TS_ICP_SIBLING, - TS_ICP_UNDEFINED } TSIcpT; - /* TODO: This should be removed */ typedef enum /* access privileges to news articles cached by Traffic Server */ { TS_IP_ALLOW_ALLOW, @@ -274,7 +269,6 @@ typedef enum { TS_FNAME_CACHE_OBJ, /* cache.config */ TS_FNAME_CONGESTION, /* congestion.config */ TS_FNAME_HOSTING, /* hosting.config */ - TS_FNAME_ICP_PEER, /* icp.config */ TS_FNAME_IP_ALLOW, /* ip_allow.config */ TS_FNAME_PARENT_PROXY, /* parent.config */ TS_FNAME_VOLUME, /* volume.config */ @@ -304,7 +298,6 @@ typedef enum { TS_CACHE_AUTH_CONTENT, TS_CONGESTION, /* congestion.config */ TS_HOSTING, /* hosting.config */ - TS_ICP, /* icp.config */ TS_IP_ALLOW, /* ip_allow.config */ TS_PP_PARENT, /* parent.config */ TS_PP_GO_DIRECT, @@ -510,22 +503,6 @@ typedef struct { TSIntList volumes; /* must be a list of ints */ } TSHostingEle; -/* icp.config */ -typedef struct { - TSCfgEle cfg_ele; - char *peer_hostname; /* hostname of icp peer; ("localhost" name reserved for Traffic Server) */ - TSIpAddr peer_host_ip_addr; /* ip address of icp peer (not required if peer_hostname) */ - TSIcpT peer_type; /* 1: icp parent, 2: icp sibling */ - int peer_proxy_port; /* port number of the TCP port used by the ICP peer for proxy communication */ - int peer_icp_port; /* port number of the UDP port used by the ICP peer for ICP communication */ - bool is_multicast; /* false: multicast not enabled; true: multicast enabled */ - TSIpAddr mc_ip_addr; /* multicast ip (can be 0 if is_multicast == false */ - TSMcTtlT mc_ttl; /* multicast time to live; either IP multicast datagrams will not - be forwarded beyond a single subnetwork, or allow delivery - of IP multicast datagrams to more than one subnet - (can be UNDEFINED if is_multicast == false */ -} TSIcpEle; - /* ip_allow.config */ typedef struct { TSCfgEle cfg_ele; @@ -742,8 +719,6 @@ tsapi TSCongestionEle *TSCongestionEleCreate(); tsapi void TSCongestionEleDestroy(TSCongestionEle *ele); tsapi TSHostingEle *TSHostingEleCreate(); tsapi void TSHostingEleDestroy(TSHostingEle *ele); -tsapi TSIcpEle *TSIcpEleCreate(); -tsapi void TSIcpEleDestroy(TSIcpEle *ele); tsapi TSIpAllowEle *TSIpAllowEleCreate(); tsapi void TSIpAllowEleDestroy(TSIpAllowEle *ele); tsapi TSParentProxyEle *TSParentProxyEleCreate(TSRuleTypeT type); diff --git a/plugins/experimental/epic/epic.cc b/plugins/experimental/epic/epic.cc index 096c5f8da79..503baf21559 100644 --- a/plugins/experimental/epic/epic.cc +++ b/plugins/experimental/epic/epic.cc @@ -189,8 +189,6 @@ static const std::set epic_gauges = { "proxy.process.http.current_cache_connections", "proxy.process.http.current_client_connections", "proxy.process.http.current_client_transactions", - "proxy.process.http.current_icp_raw_transactions", - "proxy.process.http.current_icp_transactions", "proxy.process.http.current_parent_proxy_connections", "proxy.process.http.current_parent_proxy_raw_transactions", "proxy.process.http.current_parent_proxy_transactions", diff --git a/proxy/ICP.cc b/proxy/ICP.cc deleted file mode 100644 index b75d7e4edf4..00000000000 --- a/proxy/ICP.cc +++ /dev/null @@ -1,2388 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/**************************************************************************** - - ICP.cc - - -****************************************************************************/ - -#include "ts/ink_platform.h" -#include "Main.h" -#include "P_EventSystem.h" -#include "P_Cache.h" -#include "P_Net.h" -#include "MgmtUtils.h" -#include "P_RecProcess.h" -#include "ICP.h" -#include "ICPProcessor.h" -#include "ICPlog.h" -#include "logging/Log.h" -#include "logging/LogAccessICP.h" -#include "BaseManager.h" -#include "HdrUtils.h" - -HTTPHdr gclient_request; - -//**************************************************************************** -// File Overview: -// ============== -// ICP files -// ICP.h -- All ICP class definitions. -// ICPlog.h -- ICP log object for logging system -// ICP.cc -- Incoming/outgoing ICP request and ICP configuration -// data base management. -// ICPConfig.cc -- ICP interface to Traffic Server configuration -// management, member functions for ICPlog (object -// passed to logging system) along with -// miscellaneous support routines. -// ICPevents.h -- Event definitions specific to ICP. -// ICPProcessor.h -- ICP external interface for other subsystems. -// External subsystems only need to include this -// header to use ICP. -// ICPProcessor.cc -- ICP external interface implementation. -// ICPStats.cc -- ICP statistic callback registration. -// -// -// Class Overview: -// =============== -// ICPConfigData -- Manages global ICP data from the TS configuration -// manager. -// PeerConfigData -- Manages ICP peer data from the TS configuration -// manager. -// ICPConfigUpdateCont -- Used by -// ICPConfiguration::icp_config_change_callback() -// to retry callout after a delay in cases where -// we cannot acquire the configuration lock. -// ICPConfiguration -- Overall manager of ICP configuration from TS -// configuration. Acts as interface and uses -// ICPConfigData and PeerConfigData to implement -// actions. Also fields/processes TS configuration -// callouts for "icp.config" changes. ICP classes only -// see ICPConfiguration when dealing with TS -// configuration info. -// -// Peer (base class) -- abstract base class -// ParentSiblingPeer : Peer -- ICP object describing parent/sibling -// peer which is initialized from the -// TS configuration data. -// MultiCastPeer : Peer -- ICP object describing MultiCast peer. -// Object is initialized from the TS -// configuration data. -// -// BitMap -- Generic bit map management class -// -// ICPProcessor -- Central class which starts all periodic events -// and maintains ICP configuration database. Delegates -// incoming data processing to ICPHandlerCont and -// outgoing data processing to ICPRequestCont. Implements -// reconfiguration actions and query requests from the -// external interface. -// -// ICPRequestCont -- Implements the state machine which processes -// locally generated ICP queries. Generates message -// queries and processes query responses. Responses -// received via callout from ICPPeerReadCont. -// -// PeriodicCont (base class) -- abstract base class -// ICPPeriodicCont : PeriodicCont -- Periodic which looks for ICP -// configuration changes sent by the Traffic Server -// configuration manager, and initiates ICP reconfiguration -// in the event we have a valid configuration change via -// ICPProcessor::ReconfigureStateMachine(). -// -// ICPHandlerCont : PeriodicCont -- Periodic which monitors incoming -// ICP sockets and starts processing of the incoming ICP data. -// -// ICPPeerReadCont -- Implements the incoming data state machine. -// Processes remote ICP query requests and passes query -// responses to ICPRequestCont via a callout. -// ICPlog -- Logging object which encapsulates ICP query info required -// by the new logging subsystem to produce squid access log -// data for ICP queries. -// -//**************************************************************************** -// -// ICP is integrated into HTTP miss processing as follows. -// -// if (HTTP Traffic Server Miss) { -// if (proxy.config.icp.enabled) { -// Status = QueryICP(URL, &target_ip); -// if (Status == ICP_HIT) -// Issue Http Request to (target_ip, proxy_port); -// } -// if (proxy.config.http.parent_proxy_routing_enable) { -// Issue Http Request to (proxy.config.http.parent_proxy_hostname, -// proxy.config.http.parent_proxy_port) -// } -// else -// Issue Http Request to Origin Server -// } -// -//**************************************************************************** - -// VC++ 5.0 is rather picky -typedef int (ICPPeerReadCont::*ICPPeerReadContHandler)(int, void *); -typedef int (ICPPeriodicCont::*ICPPeriodicContHandler)(int, void *); -typedef int (ICPHandlerCont::*ICPHandlerContHandler)(int, void *); -typedef int (ICPRequestCont::*ICPRequestContHandler)(int, void *); - -// Plugin freshness function -PluginFreshnessCalcFunc pluginFreshnessCalcFunc = (PluginFreshnessCalcFunc) nullptr; - -//--------------------------------------- -// Class ICPHandlerCont member functions -// Deal with incoming ICP data -//--------------------------------------- - -// Static data declarations -// Allocator *ICPHandlerCont::IncomingICPDataBuf; -int64_t ICPHandlerCont::ICPDataBuf_IOBuffer_sizeindex; -static ClassAllocator PeerReadDataAllocator("PeerReadDataAllocator"); -static ClassAllocator ICPPeerReadContAllocator("ICPPeerReadContAllocator"); - -static Action *default_action = nullptr; - -ICPHandlerCont::ICPHandlerCont(ICPProcessor *icpP) : PeriodicCont(icpP) -{ -} - -// do nothing continuation handler -int -ICPHandlerCont::TossEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) -{ - return EVENT_DONE; -} - -int -ICPHandlerCont::PeriodicEvent(int event, Event * /* e ATS_UNUSED */) -{ - int n_peer, valid_peers; - Peer *P; - - // Periodic handler which initiates incoming message processing - // on the defined peers. - - valid_peers = _ICPpr->GetRecvPeers(); - - // get peer info from the completionEvent token. - switch (event) { - case EVENT_POLL: - case EVENT_INTERVAL: { - // start read I/Os on peers which don't have outstanding I/Os - for (n_peer = 0; n_peer < valid_peers; ++n_peer) { - P = _ICPpr->GetNthRecvPeer(n_peer, _ICPpr->GetLastRecvPeerBias()); - if (!P || (P && !P->IsOnline())) { - continue; - } - if (P->shouldStartRead()) { - P->startingRead(); - /////////////////////////////////////////// - // Setup state machine - /////////////////////////////////////////// - ICPPeerReadCont *s = ICPPeerReadContAllocator.alloc(); - int local_lookup = _ICPpr->GetConfig()->globalConfig()->ICPLocalCacheLookup(); - - s->init(_ICPpr, P, local_lookup); - RECORD_ICP_STATE_CHANGE(s, event, ICPPeerReadCont::READ_ACTIVE); - - /////////////////////////////////////////// - // Start processing - /////////////////////////////////////////// - s->handleEvent(EVENT_INTERVAL, (Event *)nullptr); - } - } - break; - } - default: { - ink_release_assert(!"unexpected event"); - break; - } - } // End of switch - return EVENT_CONT; -} - -//*************************************************************************** -// Nested Class PeerReadData member functions -// Used by ICPPeerReadCont to encapsulate the data required by -// PeerReadStateMachine -//*************************************************************************** -ICPPeerReadCont::PeerReadData::PeerReadData() -{ - init(); -} - -void -ICPPeerReadCont::PeerReadData::init() -{ - _start_time = 0; - _mycont = nullptr; - _peer = nullptr; - _next_state = READ_ACTIVE; - _cache_lookup_local = 0; - _buf = nullptr; - _rICPmsg = nullptr; - _rICPmsg_len = 0; - _cachelookupURL.clear(); - _queryResult = 0; - _ICPReqCont = nullptr; - _bytesReceived = 0; -#ifdef DEBUG_ICP - _nhistory = 0; -#endif - memset((void *)&_sender, 0, sizeof(_sender)); -} - -ICPPeerReadCont::PeerReadData::~PeerReadData() -{ - reset(1); -} - -void -ICPPeerReadCont::PeerReadData::reset(int full_reset) -{ - if (full_reset) { - _peer = nullptr; - _buf = nullptr; - } - if (_rICPmsg) { - _rICPmsg = nullptr; - _rICPmsg_len = 0; - } - - if (_cachelookupURL.valid()) { - _cachelookupURL.destroy(); - } -} - -//*************************************************************************** - -//------------------------------------------------------------------------ -// ICPPeerReadCont -- ICP incoming message processing state machine -//------------------------------------------------------------------------ -ICPPeerReadCont::ICPPeerReadCont() - : Continuation(nullptr), - _object_vc(nullptr), - _object_read(nullptr), - _cache_req_hdr_heap_handle(nullptr), - _cache_resp_hdr_heap_handle(nullptr), - _ICPpr(nullptr), - _state(nullptr), - _start_time(0), - _recursion_depth(0) -{ -} - -void -ICPPeerReadCont::init(ICPProcessor *ICPpr, Peer *p, int lookup_local) -{ - PeerReadData *s = PeerReadDataAllocator.alloc(); - s->init(); - s->_start_time = Thread::get_hrtime(); - s->_peer = p; - s->_next_state = READ_ACTIVE; - s->_cache_lookup_local = lookup_local; - SET_HANDLER((ICPPeerReadContHandler)&ICPPeerReadCont::ICPPeerReadEvent); - _ICPpr = ICPpr; - _state = s; - _recursion_depth = -1; - _object_vc = nullptr; - _object_read = nullptr; - _cache_req_hdr_heap_handle = nullptr; - _cache_resp_hdr_heap_handle = nullptr; - _http_config_params = HttpConfig::acquire(); - mutex = new_ProxyMutex(); -} - -ICPPeerReadCont::~ICPPeerReadCont() -{ - HttpConfig::release(_http_config_params); - reset(1); // Full reset -} - -void -ICPPeerReadCont::reset(int full_reset) -{ - mutex = nullptr; - if (this->_state) { - this->_state->reset(full_reset); - PeerReadDataAllocator.free(this->_state); - } - if (_cache_req_hdr_heap_handle) { - ats_free(_cache_req_hdr_heap_handle); - _cache_req_hdr_heap_handle = nullptr; - } - if (_cache_resp_hdr_heap_handle) { - ats_free(_cache_resp_hdr_heap_handle); - _cache_resp_hdr_heap_handle = nullptr; - } -} - -int -ICPPeerReadCont::ICPPeerReadEvent(int event, Event *e) -{ - switch (event) { - case EVENT_INTERVAL: - case EVENT_IMMEDIATE: { - break; - } - case NET_EVENT_DATAGRAM_WRITE_COMPLETE: - case NET_EVENT_DATAGRAM_READ_COMPLETE: - case NET_EVENT_DATAGRAM_READ_ERROR: - case NET_EVENT_DATAGRAM_WRITE_ERROR: { - ink_assert((event != NET_EVENT_DATAGRAM_READ_COMPLETE) || (_state->_next_state == READ_DATA_DONE)); - ink_assert((event != NET_EVENT_DATAGRAM_WRITE_COMPLETE) || (_state->_next_state == WRITE_DONE)); - - ink_release_assert(this == (ICPPeerReadCont *)completionUtil::getHandle(e)); - break; - } - case CACHE_EVENT_LOOKUP_FAILED: - case CACHE_EVENT_LOOKUP: { - ink_assert(_state->_next_state == AWAITING_CACHE_LOOKUP_RESPONSE); - break; - } - default: { - ink_release_assert(!"unexpected event"); - } - } // End of switch - - // Front end to PeerReadStateMachine(), invoked by Event subsystem. - if (PeerReadStateMachine(_state, e) == EVENT_CONT) { - eventProcessor.schedule_in(this, RETRY_INTERVAL, ET_ICP); - return EVENT_DONE; - - } else if (_state->_next_state == READ_PROCESSING_COMPLETE) { - _state->_peer->cancelRead(); - this->reset(1); // Full reset - ICPPeerReadContAllocator.free(this); - return EVENT_DONE; - - } else { - return EVENT_DONE; - } -} - -int -ICPPeerReadCont::StaleCheck(int event, Event * /* e ATS_UNUSED */) -{ - ip_port_text_buffer ipb; - - ink_release_assert(mutex->thread_holding == this_ethread()); - - Debug("icp-stale", "Stale check res=%d for id=%d, [%s] from [%s]", event, _state->_rICPmsg->h.requestno, - _state->_rICPmsg->un.query.URL, ats_ip_nptop(&_state->_sender, ipb, sizeof(ipb))); - - switch (event) { - case ICP_STALE_OBJECT: { - _state->_queryResult = CACHE_EVENT_LOOKUP_FAILED; - break; - } - case ICP_FRESH_OBJECT: { - _state->_queryResult = CACHE_EVENT_LOOKUP; - break; - } - default: { - Debug("icp-stale", "ICPPeerReadCont::StaleCheck: Invalid Event %d", event); - _state->_queryResult = CACHE_EVENT_LOOKUP_FAILED; - break; - } - } - _object_vc->do_io(VIO::CLOSE); - _object_vc = nullptr; - SET_HANDLER((ICPPeerReadContHandler)&ICPPeerReadCont::ICPPeerReadEvent); - return handleEvent(_state->_queryResult, nullptr); -} - -int -ICPPeerReadCont::ICPPeerQueryEvent(int event, Event *e) -{ - ip_port_text_buffer ipb; - - Debug("icp", "Remote Query lookup res=%d for id=%d, [%s] from [%s]", event, _state->_rICPmsg->h.requestno, - _state->_rICPmsg->un.query.URL, ats_ip_nptop(&_state->_sender, ipb, sizeof(ipb))); - if (pluginFreshnessCalcFunc) { - switch (event) { - case CACHE_EVENT_OPEN_READ: { - _object_vc = (CacheVConnection *)e; - SET_HANDLER((ICPPeerReadContHandler)&ICPPeerReadCont::StaleCheck); - _object_vc->get_http_info(&_object_read); - (*pluginFreshnessCalcFunc)((void *)this); - return EVENT_DONE; - } - case CACHE_EVENT_OPEN_READ_FAILED: { - event = CACHE_EVENT_LOOKUP_FAILED; - break; - } - default: - break; - } - } - // Process result - _state->_queryResult = event; - SET_HANDLER((ICPPeerReadContHandler)&ICPPeerReadCont::ICPPeerReadEvent); - return handleEvent(event, e); -} - -int -ICPPeerReadCont::ICPPeerQueryCont(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) -{ - ip_port_text_buffer ipb; - Action *a; - - // Perform lookup()/open_read() on behalf of PeerReadStateMachine() - - ((char *)_state->_rICPmsg)[MAX_ICP_MSGSIZE - 1] = 0; // null terminate - _state->_cachelookupURL.create(nullptr); - const char *qurl = (const char *)_state->_rICPmsg->un.query.URL; - _state->_cachelookupURL.parse(qurl, strlen(qurl)); - Debug("icp", "Remote Query for id=%d, [%s] from [%s]", _state->_rICPmsg->h.requestno, _state->_rICPmsg->un.query.URL, - ats_ip_nptop(&_state->_sender, ipb, sizeof(ipb))); - - SET_HANDLER((ICPPeerReadContHandler)&ICPPeerReadCont::ICPPeerQueryEvent); - if (_state->_rICPmsg->un.query.URL && *_state->_rICPmsg->un.query.URL) { - HttpCacheKey key; - ICPConfigData *cfg = _ICPpr->GetConfig()->globalConfig(); - - Cache::generate_key(&key, &_state->_cachelookupURL, cfg->ICPCacheGeneration()); - _state->_queryResult = ~CACHE_EVENT_LOOKUP_FAILED; - _start_time = Thread::get_hrtime(); - - if (pluginFreshnessCalcFunc && cfg->ICPStaleLookup()) { - ////////////////////////////////////////////////////////////// - // Note: _cache_lookup_local is ignored in this case, since - // cache clustering is not used with stale lookup. - ////////////////////////////////////////////////////////////// - - // ToDo: This is maybe not 100% correct, since this is not using the txnp (but the global overridable copy) - a = cacheProcessor.open_read(this, &key, &gclient_request, &_http_config_params->oride, (time_t)0); - } else { - a = cacheProcessor.lookup(this, &key); - } - if (!a) { - a = ACTION_IO_ERROR; - } - if (a == ACTION_RESULT_DONE) { - return EVENT_DONE; // callback complete - } else if (a == ACTION_IO_ERROR) { - handleEvent(CACHE_EVENT_LOOKUP_FAILED, nullptr); - return EVENT_DONE; // callback complete - } else { - return EVENT_CONT; // callback pending - } - } else { - // Null URL, return failed lookup - handleEvent(CACHE_EVENT_LOOKUP_FAILED, nullptr); - return EVENT_DONE; // callback done - } -} - -struct AutoReference { - AutoReference(int *cnt) - { - _cnt = cnt; - (*_cnt)++; - } - ~AutoReference() { (*_cnt)--; } - int *_cnt; -}; - -int -ICPPeerReadCont::PeerReadStateMachine(PeerReadData *s, Event *e) -{ - AutoReference l(&_recursion_depth); - ip_port_text_buffer ipb; // scratch buffer for diagnostic messages. - //----------------------------------------------------------- - // State machine to process ICP data received on UDP socket - //----------------------------------------------------------- - MUTEX_TRY_LOCK(lock, this->mutex, this_ethread()); - if (!lock.is_locked()) { - // we didn't get the lock, so we don't need to unlock it - // coverity[missing_unlock] - return EVENT_CONT; // try again later - } - - while (true) { // loop forever - - switch (s->_next_state) { - case READ_ACTIVE: { - ink_release_assert(_recursion_depth == 0); - if (!_ICPpr->Lock()) { - return EVENT_CONT; // unable to get lock, try again later - } - - bool valid_peer = (_ICPpr->IdToPeer(s->_peer->GetPeerID()) == s->_peer.get()); - - if (valid_peer && _ICPpr->AllowICPQueries() && _ICPpr->GetConfig()->globalConfig()->ICPconfigured()) { - // Note pending incoming ICP request or response - _ICPpr->IncPendingQuery(); - _ICPpr->Unlock(); - - s->_next_state = READ_DATA; - RECORD_ICP_STATE_CHANGE(s, 0, READ_DATA); - break; // move to next_state - - } else { - _ICPpr->Unlock(); - - // ICP NOT enabled, do nothing - s->_next_state = READ_PROCESSING_COMPLETE; - RECORD_ICP_STATE_CHANGE(s, 0, READ_PROCESSING_COMPLETE); - return EVENT_DONE; - } - } - ink_release_assert(0); // Should never happen - - case READ_DATA: { - ink_release_assert(_recursion_depth == 0); - - // Assumption of one outstanding read per peer... - // Setup read from FD - ink_assert(!s->_peer->buf); - Ptr buf = s->_peer->buf = new_IOBufferBlock(); - buf->alloc(ICPHandlerCont::ICPDataBuf_IOBuffer_sizeindex); - s->_peer->fromaddrlen = sizeof(s->_peer->fromaddr); - buf->fill(sizeof(ICPMsg_t)); // reserve space for decoding - char *be = buf->buf_end() - 1; - be[0] = 0; // null terminate buffer - s->_next_state = READ_DATA_DONE; - RECORD_ICP_STATE_CHANGE(s, 0, READ_DATA_DONE); - ink_assert(s->_peer->readAction == nullptr); - Action *a = - s->_peer->RecvFrom_re(this, this, buf.get(), buf->write_avail() - 1, &s->_peer->fromaddr.sa, &s->_peer->fromaddrlen); - if (!a) { - a = ACTION_IO_ERROR; - } - if (a == ACTION_RESULT_DONE) { - // we will have been called back already and our state updated - // appropriately. - // move to next state - ink_assert(s->_next_state == PROCESS_READ_DATA); - break; - } else if (a == ACTION_IO_ERROR) { - // actually, this *could* be taken care of by the main handler, but - // error processing makes more sense at this point. Therefore, - // the main handler ignores the errors. - // - // No data, terminate read loop. - // - ICP_INCREMENT_DYN_STAT(no_data_read_stat); - s->_peer->buf = nullptr; // release reference - s->_next_state = READ_NOT_ACTIVE_EXIT; - RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE_EXIT); - // move to next state - break; - } else { - s->_peer->readAction = a; - return EVENT_DONE; - } - } - ink_release_assert(0); // Should never happen - - case READ_DATA_DONE: { - // Convert ICP message from network to host format - if (s->_peer->readAction != nullptr) { - ink_assert(s->_peer->readAction == e); - s->_peer->readAction = nullptr; - } - s->_bytesReceived = completionUtil::getBytesTransferred(e); - - if (s->_bytesReceived >= 0) { - s->_next_state = PROCESS_READ_DATA; - RECORD_ICP_STATE_CHANGE(s, 0, PROCESS_READ_DATA); - } else { - ICP_INCREMENT_DYN_STAT(no_data_read_stat); - s->_peer->buf = nullptr; // release reference - s->_next_state = READ_NOT_ACTIVE_EXIT; - RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE_EXIT); - } - if (_recursion_depth > 0) { - return EVENT_DONE; - } else { - break; - } - } - ink_release_assert(0); // Should never happen - - case PROCESS_READ_DATA: - case ADD_PEER: { - ink_release_assert(_recursion_depth == 0); - - Ptr bufblock = s->_peer->buf; - char *buf = bufblock->start(); - - if (s->_next_state == PROCESS_READ_DATA) { - ICPRequestCont::NetToHostICPMsg((ICPMsg_t *)(buf + sizeof(ICPMsg_t)), (ICPMsg_t *)buf); - - // adjust buffer pointers to point to decoded message. - bufblock->reset(); - bufblock->fill(s->_bytesReceived); - - // Validate message length for sanity - if (s->_bytesReceived < ((ICPMsg_t *)buf)->h.msglen) { - // - // Short read, terminate - // - ICP_INCREMENT_DYN_STAT(short_read_stat); - s->_peer->buf = nullptr; - s->_next_state = READ_NOT_ACTIVE; - RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE); - break; // move to next_state - } - } - // Validate receiver and convert the received sockaddr - // to internal sockaddr format. - IpEndpoint from; - if (!s->_peer->ExtToIntRecvSockAddr(&s->_peer->fromaddr.sa, &from.sa)) { - int status; - ICPConfigData *cfg = _ICPpr->GetConfig()->globalConfig(); - ICPMsg_t *ICPmsg = (ICPMsg_t *)buf; - - if ((cfg->ICPconfigured() == ICP_MODE_RECEIVE_ONLY) && cfg->ICPReplyToUnknownPeer() && - ((ICPmsg->h.version == ICP_VERSION_2) || (ICPmsg->h.version == ICP_VERSION_3)) && (ICPmsg->h.opcode == ICP_OP_QUERY)) { - // - // Add the unknown Peer to our database to - // allow us to resolve the lookup request. - // - if (!_ICPpr->GetConfig()->Lock()) { - s->_next_state = ADD_PEER; - RECORD_ICP_STATE_CHANGE(s, 0, ADD_PEER); - return EVENT_CONT; - } - if (!_ICPpr->GetFreePeers() || !_ICPpr->GetFreeSendPeers()) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP Peer limit exceeded"); - _ICPpr->GetConfig()->Unlock(); - goto invalid_message; - } - - int icp_reply_port = cfg->ICPDefaultReplyPort(); - if (!icp_reply_port) { - icp_reply_port = ntohs(ats_ip_port_cast(&s->_peer->fromaddr)); - } - PeerConfigData *Pcfg = new PeerConfigData(PeerConfigData::CTYPE_SIBLING, IpAddr(s->_peer->fromaddr), 0, icp_reply_port); - ParentSiblingPeer *P = new ParentSiblingPeer(PEER_SIBLING, Pcfg, _ICPpr, true); - status = _ICPpr->AddPeer(P); - ink_release_assert(status); - status = _ICPpr->AddPeerToSendList(P); - ink_release_assert(status); - - P->GetChan()->setRemote(P->GetIP()); - - // coverity[uninit_use_in_call] - Note("ICP Peer added ip=%s", ats_ip_nptop(P->GetIP(), ipb, sizeof(ipb))); - from = s->_peer->fromaddr; - } else { - invalid_message: - // - // Sender does not exist in ICP configuration, terminate - // - ICP_INCREMENT_DYN_STAT(invalid_sender_stat); - Debug("icp", "Received msg from invalid sender [%s]", ats_ip_nptop(&s->_peer->fromaddr, ipb, sizeof(ipb))); - - s->_peer->buf = nullptr; - s->_next_state = READ_NOT_ACTIVE; - RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE); - break; // move to next_state - } - } - // we hand off the decoded buffer from the Peer to the PeerReadData - s->_sender = from; - s->_rICPmsg_len = s->_bytesReceived; - ink_assert(!s->_buf); - s->_buf = s->_peer->buf; - s->_rICPmsg = (ICPMsg_t *)s->_buf->start(); - s->_peer->buf = nullptr; - - // - // Handle only ICP_VERSION_2/3 messages. Reject all others. - // - if ((s->_rICPmsg->h.version != ICP_VERSION_2) && (s->_rICPmsg->h.version != ICP_VERSION_3)) { - ICP_INCREMENT_DYN_STAT(read_not_v2_icp_stat); - Debug("icp", "Received (v=%d) !v2 && !v3 msg from sender [%s]", (uint32_t)s->_rICPmsg->h.version, - ats_ip_nptop(&from, ipb, sizeof(ipb))); - - s->_rICPmsg = nullptr; - s->_buf = nullptr; - s->_next_state = READ_NOT_ACTIVE; - RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE); - break; // move to next_state - } - // - // If this is a query message, redirect to - // the query specific handlers. - // - if (s->_rICPmsg->h.opcode == ICP_OP_QUERY) { - ICP_INCREMENT_DYN_STAT(icp_remote_query_requests_stat); - ink_assert(!s->_mycont); - s->_next_state = AWAITING_CACHE_LOOKUP_RESPONSE; - RECORD_ICP_STATE_CHANGE(s, 0, AWAITING_CACHE_LOOKUP_RESPONSE); - - if (ICPPeerQueryCont(0, (Event *)nullptr) == EVENT_DONE) { - break; // Callback complete - } else { - return EVENT_DONE; // Callback pending - } - } else { - // We have a response message for an ICP query. - Debug("icp", "Response for Id=%d, from [%s]", s->_rICPmsg->h.requestno, ats_ip_nptop(&s->_sender, ipb, sizeof(ipb))); - ICP_INCREMENT_DYN_STAT(icp_remote_responses_stat); - s->_next_state = GET_ICP_REQUEST; - RECORD_ICP_STATE_CHANGE(s, 0, GET_ICP_REQUEST); - break; // move to next_state - } - } - ink_release_assert(0); // Should never happen - - case AWAITING_CACHE_LOOKUP_RESPONSE: { - int status = 0; - void *data = s->_rICPmsg->un.query.URL; - int datalen = strlen((const char *)data) + 1; - - if (s->_queryResult == CACHE_EVENT_LOOKUP) { - // Use the received ICP data buffer for the response message - Debug("icp", "Sending ICP_OP_HIT for id=%d, [%.*s] to [%s]", s->_rICPmsg->h.requestno, datalen, (const char *)data, - ats_ip_nptop(&s->_sender, ipb, sizeof(ipb))); - ICP_INCREMENT_DYN_STAT(icp_cache_lookup_success_stat); - status = ICPRequestCont::BuildICPMsg(ICP_OP_HIT, s->_rICPmsg->h.requestno, 0 /* optflags */, 0 /* optdata */, - 0 /* shostid */, data, datalen, &s->_mhdr, s->_iov, s->_rICPmsg); - } else if (s->_queryResult == CACHE_EVENT_LOOKUP_FAILED) { - // Use the received ICP data buffer for response message - Debug("icp", "Sending ICP_OP_MISS for id=%d, [%.*s] to [%s]", s->_rICPmsg->h.requestno, datalen, (const char *)data, - ats_ip_nptop(&s->_sender, ipb, sizeof(ipb))); - ICP_INCREMENT_DYN_STAT(icp_cache_lookup_fail_stat); - status = ICPRequestCont::BuildICPMsg(ICP_OP_MISS, s->_rICPmsg->h.requestno, 0 /* optflags */, 0 /* optdata */, - 0 /* shostid */, data, datalen, &s->_mhdr, s->_iov, s->_rICPmsg); - } else { - Warning("Bad cache lookup event: %d", s->_queryResult); - ink_release_assert(!"Invalid cache lookup event"); - } - ink_assert(status == 0); - - // Make system log entry for ICP query - ICPlog logentry(s); - LogAccessICP accessor(&logentry); - Log::access(&accessor); - - s->_next_state = SEND_REPLY; - RECORD_ICP_STATE_CHANGE(s, 0, SEND_REPLY); - - if (_recursion_depth > 0) { - return EVENT_DONE; - } else { - break; - } - } - ink_release_assert(0); // Should never happen - - case SEND_REPLY: { - ink_release_assert(_recursion_depth == 0); - // - // Send the query response back to the sender - // - s->_next_state = WRITE_DONE; - RECORD_ICP_STATE_CHANGE(s, 0, WRITE_DONE); - ink_assert(s->_peer->writeAction == nullptr); - Action *a = s->_peer->SendMsg_re(this, this, &s->_mhdr, &s->_sender.sa); - if (!a) { - a = ACTION_IO_ERROR; - } - if (a == ACTION_RESULT_DONE) { - // we have been called back already and our state updated - // appropriately - break; - - } else if (a == ACTION_IO_ERROR) { - // Partial write. - ICP_INCREMENT_DYN_STAT(query_response_partial_write_stat); - // coverity[uninit_use_in_call] - Debug("icp_warn", "ICP response send, sent=%d res=%d, ip=%s", ntohs(s->_rICPmsg->h.msglen), -1, - ats_ip_ntop(&s->_sender, ipb, sizeof(ipb))); - s->_next_state = READ_NOT_ACTIVE; - RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE); - break; - } else { - s->_peer->writeAction = a; - return EVENT_DONE; - } - } - ink_release_assert(0); // Should never happen - - case WRITE_DONE: { - s->_peer->writeAction = nullptr; - int len = completionUtil::getBytesTransferred(e); - - if (len == (int)ntohs(s->_rICPmsg->h.msglen)) { - ICP_INCREMENT_DYN_STAT(query_response_write_stat); - s->_peer->LogSendMsg(s->_rICPmsg, &s->_sender.sa); // log query reply - } else { - // Partial write. - ICP_INCREMENT_DYN_STAT(query_response_partial_write_stat); - // coverity[uninit_use_in_call] - Debug("icp_warn", "ICP response send, sent=%d res=%d, ip=%s", ntohs(s->_rICPmsg->h.msglen), len, - ats_ip_ntop(&s->_sender, ipb, sizeof(ipb))); - } - // Processing complete, perform completion actions - s->_next_state = READ_NOT_ACTIVE; - RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE); - Debug("icp", "state->READ_NOT_ACTIVE"); - - if (_recursion_depth > 0) { - return EVENT_DONE; - } else { - break; // move to next_state - } - } - ink_release_assert(0); // Should never happen - - case GET_ICP_REQUEST: { - ink_release_assert(_recursion_depth == 0); - ink_assert(s->_rICPmsg && s->_rICPmsg_len); // Sanity check - - // Get ICP request associated with response message - s->_ICPReqCont = ICPRequestCont::FindICPRequest(s->_rICPmsg->h.requestno); - if (s->_ICPReqCont) { - s->_next_state = GET_ICP_REQUEST_MUTEX; - RECORD_ICP_STATE_CHANGE(s, 0, GET_ICP_REQUEST_MUTEX); - break; // move to next_state - } - // - // No ICP request for response message, log as "response - // for non-existent ICP request" and terminate processing - // - Debug("icp", "No ICP Request for Id=%d", s->_rICPmsg->h.requestno); - ICP_INCREMENT_DYN_STAT(no_icp_request_for_response_stat); - Peer *p = _ICPpr->FindPeer(s->_sender); - p->LogRecvMsg(s->_rICPmsg, 0); - s->_next_state = READ_NOT_ACTIVE; - RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE); - break; // move to next_state - } - ink_release_assert(0); // Should never happen - - case GET_ICP_REQUEST_MUTEX: { - ink_release_assert(_recursion_depth == 0); - ink_assert(s->_ICPReqCont); - Ptr ICPReqContMutex(s->_ICPReqCont->mutex); - EThread *ethread = this_ethread(); - ink_hrtime request_start_time; - - if (!MUTEX_TAKE_TRY_LOCK(ICPReqContMutex, ethread)) { - ICP_INCREMENT_DYN_STAT(icp_response_request_nolock_stat); - // - // Unable to get ICP request mutex, delay and move back - // to the GET_ICP_REQUEST state. We need to do this - // since the ICP request may be deallocated by the active - // continuation. - // - s->_ICPReqCont = (ICPRequestCont *)nullptr; - s->_next_state = GET_ICP_REQUEST; - RECORD_ICP_STATE_CHANGE(s, 0, GET_ICP_REQUEST); - return EVENT_CONT; - } - // Log as "response for ICP request" - Peer *p = _ICPpr->FindPeer(s->_sender); - p->LogRecvMsg(s->_rICPmsg, 1); - - // Process the ICP response for the given ICP request - ICPRequestCont::ICPRequestEventArgs_t args; - args.rICPmsg = s->_rICPmsg; - args.rICPmsg_len = s->_rICPmsg_len; - args.peer = p; - if (!s->_ICPReqCont->GetActionPtr()->cancelled) { - request_start_time = s->_ICPReqCont->GetRequestStartTime(); - Debug("icp", "Passing Reply for ICP Id=%d", s->_rICPmsg->h.requestno); - s->_ICPReqCont->handleEvent((int)ICP_RESPONSE_MESSAGE, (void *)&args); - } else { - request_start_time = 0; - delete s->_ICPReqCont; - Debug("icp", "User cancelled ICP request Id=%d", s->_rICPmsg->h.requestno); - } - - // Note: s->_ICPReqCont is deallocated at this point. - s->_ICPReqCont = nullptr; - - MUTEX_UNTAKE_LOCK(ICPReqContMutex, ethread); - if (request_start_time) { - ICP_SUM_DYN_STAT(total_icp_response_time_stat, (Thread::get_hrtime() - request_start_time)); - } - RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE); - s->_next_state = READ_NOT_ACTIVE; - break; // move to next_state - } - ink_release_assert(0); // Should never happen - - case READ_NOT_ACTIVE: - case READ_NOT_ACTIVE_EXIT: { - ink_release_assert(_recursion_depth == 0); - if (!_ICPpr->Lock()) { - return EVENT_CONT; // unable to get lock, try again later - } - - // Note incoming ICP request or response completion - _ICPpr->DecPendingQuery(); - _ICPpr->Unlock(); - - s->_buf = nullptr; - if (s->_next_state == READ_NOT_ACTIVE_EXIT) { - s->_next_state = READ_PROCESSING_COMPLETE; - return EVENT_DONE; - } else { - // Last read was valid, see if any more read data before exiting - s->reset(); - s->_start_time = Thread::get_hrtime(); - s->_next_state = READ_ACTIVE; - RECORD_ICP_STATE_CHANGE(s, 0, READ_ACTIVE); - break; // restart - } - } - ink_release_assert(0); // Should never happen - - case READ_PROCESSING_COMPLETE: - default: - ink_release_assert(0); // Should never happen - - } // End of switch - - } // End of while(1) -} - -//------------------------------------------------------------------------ -// Class ICPRequestCont member functions -// Implements the state machine which processes locally generated -// ICP queries. -//------------------------------------------------------------------------ -ClassAllocator ICPRequestCont_allocator("ICPRequestCont_allocator"); - -ICPRequestCont::ICPRequestCont(ICPProcessor *pr, Continuation *c, URL *u) - : Continuation(nullptr), - _cont(c), - _url(u), - _start_time(0), - _ICPpr(pr), - _timeout(nullptr), - npending_actions(0), - pendingActions(nullptr), - _sequence_number(0), - _expected_replies(0), - _expected_replies_list(MAX_DEFINED_PEERS), - _received_replies(0), - _next_state(ICP_START) -{ - memset((void *)&_ret_sockaddr, 0, sizeof(_ret_sockaddr)); - _ret_status = ICP_LOOKUP_FAILED; - _act.cancelled = false; - _act = c; - memset((void *)&_ICPmsg, 0, sizeof(_ICPmsg)); - memset((void *)&_sendMsgHdr, 0, sizeof(_sendMsgHdr)); - memset((void *)&_sendMsgIOV, 0, sizeof(_sendMsgIOV[MSG_IOVECS])); - - if (c) { - this->mutex = c->mutex; - } -} - -ICPRequestCont::~ICPRequestCont() -{ - _act = nullptr; - this->mutex = nullptr; - - if (_timeout) { - _timeout->cancel(this); - _timeout = nullptr; - } - RemoveICPRequest(_sequence_number); - - if (_ICPmsg.h.opcode == ICP_OP_QUERY) { - if (_ICPmsg.un.query.URL) { - ats_free(_ICPmsg.un.query.URL); - } - } - if (pendingActions) { - delete pendingActions; - pendingActions = nullptr; - } -} - -void -ICPRequestCont::remove_from_pendingActions(Action *a) -{ - if (!pendingActions) { - npending_actions--; - return; - } - for (intptr_t i = 0; i < pendingActions->length(); i++) { - if ((*pendingActions)[i] == a) { - for (intptr_t j = i; j < pendingActions->length() - 1; j++) { - (*pendingActions)[j] = (*pendingActions)[j + 1]; - } - pendingActions->set_length(pendingActions->length() - 1); - npending_actions--; - return; - } - } - npending_actions--; // completed inline -} - -void -ICPRequestCont::remove_all_pendingActions() -{ - int active_pendingActions = 0; - - if (!pendingActions) { - return; - } - for (intptr_t i = 0; i < pendingActions->length(); i++) { - if ((*pendingActions)[i] && ((*pendingActions)[i] != ACTION_IO_ERROR)) { - ((*pendingActions)[i])->cancel(); - (*pendingActions)[i] = nullptr; - npending_actions--; - active_pendingActions++; - } else { - (*pendingActions)[i] = nullptr; - } - } - pendingActions->set_length(pendingActions->length() - active_pendingActions); -} - -int -ICPRequestCont::ICPRequestEvent(int event, Event *e) -{ - // Note: Passed parameter 'e' is not an Event * - // if event == ICP_RESPONSE_MESSAGE - - ink_assert(event == NET_EVENT_DATAGRAM_WRITE_COMPLETE || event == NET_EVENT_DATAGRAM_WRITE_ERROR || event == EVENT_IMMEDIATE || - event == EVENT_INTERVAL || event == ICP_RESPONSE_MESSAGE); - // handle reentrant callback - if ((event == NET_EVENT_DATAGRAM_WRITE_COMPLETE) || (event == NET_EVENT_DATAGRAM_WRITE_ERROR)) { - ink_assert(npending_actions > 0); - remove_from_pendingActions((Action *)e); - return EVENT_DONE; - } - // Start of user ICP query request processing. We start here after - // the reschedule in ICPProcessor::ICPQuery(). - switch (_next_state) { - case ICP_START: - case ICP_OFF_TERMINATE: - case ICP_QUEUE_REQUEST: - case ICP_AWAITING_RESPONSE: - case ICP_DEQUEUE_REQUEST: - case ICP_POST_COMPLETION: - case ICP_REQUEST_NOT_ACTIVE: { - if (ICPStateMachine(event, (void *)e) == EVENT_CONT) { - // - // Unable to acquire lock, reschedule continuation - // - eventProcessor.schedule_in(this, HRTIME_MSECONDS(RETRY_INTERVAL), ET_ICP); - return EVENT_CONT; - - } else if (_next_state == ICP_DONE) { - // - // ICP request processing complete. - // - delete this; - break; - } else { - break; - } - } - ink_release_assert(0); // should never happen - - case ICP_DONE: - default: - ink_release_assert(0); // should never happen - } // End of switch - - return EVENT_DONE; -} - -int -ICPRequestCont::NopICPRequestEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) -{ - delete this; - return EVENT_DONE; -} - -int -ICPRequestCont::ICPStateMachine(int event, void *d) -{ - //******************************************* - // ICP message processing state machine - //******************************************* - ICPConfiguration *ICPcf = _ICPpr->GetConfig(); - ip_port_text_buffer ipb; - - while (true) { // loop forever - - switch (_next_state) { - case ICP_START: { - // User may have cancelled request, if so abort request. - if (_act.cancelled) { - _next_state = ICP_DONE; - return EVENT_DONE; - } - - if (!_ICPpr->Lock()) { - return EVENT_CONT; // Unable to get lock, try again later - } - - if (_ICPpr->AllowICPQueries() && (ICPcf->globalConfig()->ICPconfigured() == ICP_MODE_SEND_RECEIVE)) { - // Reject NULL pointer or "localhost" URLs - if (_url->valid()) { - int host_len; - const char *host = _url->host_get(&host_len); - if (ptr_len_casecmp(host, host_len, "127.0.0.1") == 0 || ptr_len_casecmp(host, host_len, "localhost") == 0) { - _ICPpr->Unlock(); - - // NULL pointer or "localhost" URL, terminate request - _next_state = ICP_OFF_TERMINATE; - Debug("icp", "[ICP_START] NULL/localhost URL ignored Id=%d", _sequence_number); - break; // move to next_state - } - } - // Note pending ICP request - _ICPpr->IncPendingQuery(); - _ICPpr->Unlock(); - - // Build the ICP query message - char *urlstr = _url->string_get(nullptr); - int urlstr_len = strlen(urlstr) + 1; - - int status = BuildICPMsg(ICP_OP_QUERY, _sequence_number = ICPReqSeqNumber(), 0 /* optflags */, 0 /* optdata */, - 0 /* shostid */, (void *)urlstr, urlstr_len, &_sendMsgHdr, _sendMsgIOV, &_ICPmsg); - // urlstr memory freed in destructor - ink_assert(status == 0); - Debug("icp", "[ICP_START] ICP_OP_QUERY for [%s], Id=%d", urlstr, _sequence_number); - - _next_state = ICP_QUEUE_REQUEST; - break; // move to next_state - - } else { - ICP_INCREMENT_DYN_STAT(icp_start_icpoff_stat); - _ICPpr->Unlock(); - - // ICP NOT enabled, terminate request - _next_state = ICP_OFF_TERMINATE; - break; // move to next_state - } - } - ink_release_assert(0); // should never happen - - case ICP_OFF_TERMINATE: { - if (!MUTEX_TAKE_TRY_LOCK_FOR(mutex, this_ethread(), _cont)) { - return EVENT_CONT; // unable to get lock, delay and retry - } - Debug("icp", "[ICP_OFF_TERMINATE] Id=%d", _sequence_number); - - // ICP NOT enabled, post completion on request - if (!_act.cancelled) { - _cont->handleEvent(_ret_status, (void *)&_ret_sockaddr); - } - MUTEX_UNTAKE_LOCK(mutex, this_ethread()); - - _next_state = ICP_DONE; - return EVENT_DONE; - } - ink_release_assert(0); // should never happen - - case ICP_QUEUE_REQUEST: { - // Place ICP request on the pending request queue - int ret = AddICPRequest(_sequence_number, this); - ink_assert(ret == 0); - - // Generate ICP requests to peers - int bias = _ICPpr->GetStartingSendPeerBias(); - int SendPeers = _ICPpr->GetSendPeers(); - npending_actions = 0; - while (SendPeers > 0) { - Peer *P = _ICPpr->GetNthSendPeer(SendPeers, bias); - if (!P->IsOnline()) { - SendPeers--; - continue; - } - // - // Send query request to Peers - // - - // because of reentrancy, we have to do this first, just - // in case we get called back immediately. - int was_expected = P->ExpectedReplies(&_expected_replies_list); - _expected_replies += was_expected; - npending_actions++; - Action *a = P->SendMsg_re(this, P, &_sendMsgHdr, nullptr); - if (!a) { - a = ACTION_IO_ERROR; - } - if (a != ACTION_IO_ERROR) { - if (a != ACTION_RESULT_DONE) { - if (!pendingActions) { - pendingActions = new DynArray(&default_action); - } - (*pendingActions)(npending_actions) = a; - } - P->LogSendMsg(&_ICPmsg, nullptr); // log as send query - Debug("icp", "[ICP_QUEUE_REQUEST] Id=%d send query to [%s]", _sequence_number, - ats_ip_nptop(P->GetIP(), ipb, sizeof(ipb))); - } else { - _expected_replies_list.ClearBit(P->GetPeerID()); - _expected_replies -= was_expected; - // Partial or failed write. - ICP_INCREMENT_DYN_STAT(send_query_partial_write_stat); - // coverity[uninit_use_in_call] - Debug("icp_warn", "ICP query send, res=%d, ip=%s", ntohs(_ICPmsg.h.msglen), ats_ip_ntop(P->GetIP(), ipb, sizeof(ipb))); - } - SendPeers--; - } - - Debug("icp", "[ICP_QUEUE_REQUEST] Id=%d expected replies=%d", _sequence_number, _expected_replies); - if (!_expected_replies) { - // - // Nothing to wait for, terminate ICP processing - // - ICP_INCREMENT_DYN_STAT(icp_queries_no_expected_replies_stat); - _next_state = ICP_DEQUEUE_REQUEST; - break; // move to next_state - } - ICP_SUM_DYN_STAT(total_udp_send_queries_stat, _expected_replies); - - // - // Setup ICP request response timeout - // - int tval = _ICPpr->GetConfig()->globalConfig()->ICPqueryTimeout(); - _timeout = eventProcessor.schedule_in(this, HRTIME_SECONDS(tval), ET_ICP); - - _next_state = ICP_AWAITING_RESPONSE; - return EVENT_DONE; - } - ink_release_assert(0); // should never happen - - case ICP_AWAITING_RESPONSE: { - Debug("icp", "[ICP_AWAITING_RESPONSE] Id=%d", _sequence_number); - ink_assert(d); - ICPRequestEventArgs_t dummyArgs; - ICPRequestEventArgs_t *args = nullptr; - - if (event == ICP_RESPONSE_MESSAGE) { - args = (ICPRequestEventArgs_t *)d; - } else if (event == EVENT_INTERVAL) { - memset((void *)&dummyArgs, 0, sizeof(dummyArgs)); - args = &dummyArgs; - } else { - ink_release_assert(0); // should never happen - } - - // Process ICP response - if (ICPResponseMessage(event, args->rICPmsg, args->peer) == EVENT_DONE) { - // ICP Request processing is complete, do completion actions - _next_state = ICP_DEQUEUE_REQUEST; - break; // move to next_state - - } else { - // Continue to wait for additional replies - return EVENT_DONE; - } - } - ink_release_assert(0); // should never happen - - case ICP_DEQUEUE_REQUEST: { - // Remove ICP request from active queue - int ret = RemoveICPRequest(_sequence_number); - Debug("icp", "[ICP_DEQUEUE_REQUEST] Id=%d", _sequence_number); - ink_assert(ret == 0); - //_sequence_number = 0; // moved to REQUEST_NOT_ACTIVE - _next_state = ICP_POST_COMPLETION; - break; // move to next_state - } - ink_release_assert(0); // should never happen - - case ICP_POST_COMPLETION: { - if (!MUTEX_TAKE_TRY_LOCK_FOR(mutex, this_ethread(), _cont)) { - return EVENT_CONT; // unable to get lock, delay and retry - } - Debug("icp", "[ICP_POST_COMPLETION] Id=%d", _sequence_number); - - // Post completion on the ICP request. - if (!_act.cancelled) { - _cont->handleEvent(_ret_status, (void *)&_ret_sockaddr); - } - MUTEX_UNTAKE_LOCK(mutex, this_ethread()); - ICP_SUM_DYN_STAT(total_icp_request_time_stat, (Thread::get_hrtime() - _start_time)); - - _next_state = ICP_WAIT_SEND_COMPLETE; - break; // move to next_state - } - ink_release_assert(0); // should never happen - case ICP_WAIT_SEND_COMPLETE: { - // wait for all the sends to complete. - if (npending_actions > 0) { - Debug("icp", "[ICP_WAIT_SEND_COMPLETE] Id=%d active=%d", _sequence_number, npending_actions); - } else { - _next_state = ICP_REQUEST_NOT_ACTIVE; - // move to next state - break; - } - } break; - ink_release_assert(0); // should never happen - case ICP_REQUEST_NOT_ACTIVE: { - Debug("icp", "[ICP_REQUEST_NOT_ACTIVE] Id=%d", _sequence_number); - _sequence_number = 0; - if (!_ICPpr->Lock()) { - return EVENT_CONT; // Unable to get lock, try again later - } - - // Note pending ICP request completion - _ICPpr->DecPendingQuery(); - _ICPpr->Unlock(); - - _next_state = ICP_DONE; - return EVENT_DONE; - } - ink_release_assert(0); // should never happen - - case ICP_DONE: - default: - ink_release_assert(0); // should never happen - - } // End of switch - - } // End of while(1) -} - -int -ICPRequestCont::ICPResponseMessage(int event, ICPMsg_t *m, Peer *peer) -{ - ip_port_text_buffer ipb, ipb2; - - if (event == EVENT_INTERVAL) { - _timeout = nullptr; - remove_all_pendingActions(); - - // ICP request response timeout, if we received a response from - // any parent, return it to resolve the miss. - - if (_received_replies) { - int NumParentPeers = _ICPpr->GetParentPeers(); - if (NumParentPeers > 0) { - int n; - Peer *pp; - for (n = 0; n < NumParentPeers; n++) { - pp = _ICPpr->GetNthParentPeer(0, _ICPpr->GetStartingParentPeerBias()); - if (pp && !_expected_replies_list.IsBitSet(pp->GetPeerID()) && pp->isUp()) { - ats_ip_copy(&_ret_sockaddr.sa, pp->GetIP()); - _ret_sockaddr.port() = htons(static_cast(pp)->GetProxyPort()); - _ret_status = ICP_LOOKUP_FOUND; - - Debug("icp", "ICP timeout using parent Id=%d from [%s] return [%s]", _sequence_number, - ats_ip_nptop(pp->GetIP(), ipb, sizeof(ipb)), ats_ip_nptop(&_ret_sockaddr, ipb2, sizeof(ipb2))); - return EVENT_DONE; - } - } - } - } - // Timeout received on ICP request, return ICP_LOOKUP_FAILED - Debug("icp", "ICP Response timeout for Id=%d", _sequence_number); - return EVENT_DONE; - - } else { - // We have received a response to our ICP query request. - // See if this response resolves the ICP query. - // - ink_assert(m->h.requestno == _sequence_number); - - switch (m->h.opcode) { - case ICP_OP_HIT: - case ICP_OP_HIT_OBJ: { - // Kill timeout event - _timeout->cancel(this); - _timeout = nullptr; - - ICP_INCREMENT_DYN_STAT(icp_query_hits_stat); - ++_received_replies; - ats_ip_copy(&_ret_sockaddr, peer->GetIP()); - _ret_sockaddr.port() = htons(static_cast(peer)->GetProxyPort()); - _ret_status = ICP_LOOKUP_FOUND; - - Debug("icp", "ICP Response HIT for Id=%d from [%s] return [%s]", _sequence_number, - ats_ip_nptop(peer->GetIP(), ipb, sizeof(ipb)), ats_ip_nptop(&_ret_sockaddr, ipb2, sizeof(ipb2))); - return EVENT_DONE; - } - case ICP_OP_MISS: - case ICP_OP_ERR: - case ICP_OP_MISS_NOFETCH: - case ICP_OP_DENIED: { - Debug("icp", "ICP MISS response for Id=%d from [%s]", _sequence_number, ats_ip_nptop(peer->GetIP(), ipb, sizeof(ipb))); - // "received_replies" is only for Peers who we expect a reply - // from (Peers which are in the expected_replies_list). - int Id = peer->GetPeerID(); - if (_expected_replies_list.IsBitSet(Id)) { - // Clear bit to note receipt of reply - _expected_replies_list.ClearBit(Id); - ++_received_replies; - } - - if (_received_replies < _expected_replies) { - return EVENT_CONT; // wait for more responses - } - - // Kill timeout event - _timeout->cancel(this); - _timeout = nullptr; - - ICP_INCREMENT_DYN_STAT(icp_query_misses_stat); - // - // All responders have returned ICP_OP_MISS. - // If parents exists, select one to resolve the request. - // - if (_ICPpr->GetParentPeers() > 0) { - // In cases where multiple parents exist, we use - // a round robin scheme. - Peer *p = nullptr; - // try to find an UP parent, if none, return ICP_LOOKUP_FAILED - { - int i; - for (i = 0; i < _ICPpr->GetParentPeers(); i++) { - p = _ICPpr->GetNthParentPeer(0, _ICPpr->GetStartingParentPeerBias()); - // find an UP parent - if (p->isUp()) { - break; - } - } - // if no parent is selected, then return ICP_LOOKUP_FAILED - if (i >= _ICPpr->GetParentPeers()) { - Debug("icp", "None of the %d ICP parent(s) is up", _ICPpr->GetParentPeers()); - p = nullptr; - } - } - if (p) { - ats_ip_copy(&_ret_sockaddr, p->GetIP()); - _ret_sockaddr.port() = htons(static_cast(p)->GetProxyPort()); - _ret_status = ICP_LOOKUP_FOUND; - - Debug("icp", "ICP ALL MISS(1) for Id=%d return [%s]", _sequence_number, ats_ip_nptop(&_ret_sockaddr, ipb, sizeof(ipb))); - return EVENT_DONE; - } - } - Debug("icp", "ICP ALL MISS(2) for Id=%d return [%s]", _sequence_number, ats_ip_nptop(&_ret_sockaddr, ipb, sizeof(ipb))); - return EVENT_DONE; - } - default: { - ICP_INCREMENT_DYN_STAT(invalid_icp_query_response_stat); - // coverity[uninit_use_in_call] - Warning("Invalid ICP response, op=%d reqno=%d ip=%s", m->h.opcode, m->h.requestno, - ats_ip_ntop(peer->GetIP(), ipb, sizeof(ipb))); - return EVENT_CONT; // wait for more responses - } - - } // End of switch - } -} - -//------------------------------------------------ -// Class ICPRequestCont static member functions -//------------------------------------------------ - -// Static member function -void -ICPRequestCont::NetToHostICPMsg(ICPMsg_t *in, ICPMsg_t *out) -{ - out->h.opcode = in->h.opcode; - out->h.version = in->h.version; - out->h.msglen = ntohs(in->h.msglen); - out->h.requestno = ntohl(in->h.requestno); - out->h.optionflags = ntohl(in->h.optionflags); - out->h.optiondata = ntohl(in->h.optiondata); - out->h.shostid = ntohl(in->h.shostid); - - switch (in->h.opcode) { - case ICP_OP_QUERY: { - memcpy((char *)&out->un.query.rhostid, (char *)((char *)(&in->h.shostid) + sizeof(in->h.shostid)), - sizeof(out->un.query.rhostid)); - out->un.query.rhostid = ntohl(out->un.query.rhostid); - out->un.query.URL = (char *)((char *)(&in->h.shostid) + sizeof(in->h.shostid) + sizeof(out->un.query.rhostid)); - break; - } - case ICP_OP_HIT: { - out->un.hit.URL = (char *)((char *)(&in->h.shostid) + sizeof(in->h.shostid)); - break; - } - case ICP_OP_MISS: { - out->un.miss.URL = (char *)((char *)(&in->h.shostid) + sizeof(in->h.shostid)); - break; - } - case ICP_OP_HIT_OBJ: { - out->un.hitobj.URL = (char *)((char *)(&in->h.shostid) + sizeof(in->h.shostid)); - - // strlen() is bounded since buffer in null terminated. - out->un.hitobj.p_objsize = (char *)(out->un.hitobj.URL + strlen(out->un.hitobj.URL)); - memcpy((char *)&out->un.hitobj.objsize, out->un.hitobj.p_objsize, sizeof(out->un.hitobj.objsize)); - out->un.hitobj.objsize = ntohs(out->un.hitobj.objsize); - out->un.hitobj.data = (char *)(out->un.hitobj.p_objsize + sizeof(out->un.hitobj.objsize)); - break; - } - default: - break; - } -} - -int -ICPRequestCont::BuildICPMsg(ICPopcode_t op, unsigned int seqno, int optflags, int optdata, int shostid, void *data, int datalen, - struct msghdr *mhdr, struct iovec *iov, ICPMsg_t *icpmsg) -{ - // Build ICP message for transmission in network byte order. - if (op == ICP_OP_QUERY) { - icpmsg->un.query.rhostid = htonl(0); - icpmsg->un.query.URL = (char *)data; - - mhdr->msg_iov = iov; - mhdr->msg_iovlen = 3; - - iov[0].iov_base = (caddr_t)icpmsg; - iov[0].iov_len = sizeof(ICPMsgHdr_t); - - iov[1].iov_base = (caddr_t)&icpmsg->un.query.rhostid; - iov[1].iov_len = sizeof(icpmsg->un.query.rhostid); - - iov[2].iov_base = (caddr_t)data; - iov[2].iov_len = datalen; - icpmsg->h.msglen = htons(iov[0].iov_len + iov[1].iov_len + iov[2].iov_len); - - } else if (op == ICP_OP_HIT) { - icpmsg->un.hit.URL = (char *)data; - - mhdr->msg_iov = iov; - mhdr->msg_iovlen = 2; - - iov[0].iov_base = (caddr_t)icpmsg; - iov[0].iov_len = sizeof(ICPMsgHdr_t); - - iov[1].iov_base = (caddr_t)data; - iov[1].iov_len = datalen; - icpmsg->h.msglen = htons(iov[0].iov_len + iov[1].iov_len); - - } else if (op == ICP_OP_MISS) { - icpmsg->un.miss.URL = (char *)data; - - mhdr->msg_iov = iov; - mhdr->msg_iovlen = 2; - - iov[0].iov_base = (caddr_t)icpmsg; - iov[0].iov_len = sizeof(ICPMsgHdr_t); - - iov[1].iov_base = (caddr_t)data; - iov[1].iov_len = datalen; - icpmsg->h.msglen = htons(iov[0].iov_len + iov[1].iov_len); - - } else { - ink_release_assert(0); - return 1; // failed - } - - mhdr->msg_name = (caddr_t) nullptr; - mhdr->msg_namelen = 0; -// TODO: The following is just awkward -#if !defined(linux) && !defined(freebsd) && !defined(darwin) && !defined(solaris) && !defined(openbsd) - mhdr->msg_accrights = (caddr_t)0; - mhdr->msg_accrightslen = 0; -#elif !defined(solaris) - mhdr->msg_control = nullptr; - mhdr->msg_controllen = 0; - mhdr->msg_flags = 0; -#endif - - icpmsg->h.opcode = op; - icpmsg->h.version = ICP_VERSION_2; - icpmsg->h.requestno = htonl(seqno); - icpmsg->h.optionflags = htonl(optflags); - icpmsg->h.optiondata = htonl(optdata); - icpmsg->h.shostid = htonl(shostid); - - return 0; // Success -} - -// Static ICPRequestCont data declarations -unsigned int ICPRequestCont::ICPRequestSeqno = 1; -Queue ICPRequestQueue[ICPRequestCont::ICP_REQUEST_HASH_SIZE]; - -// Static member function -unsigned int -ICPRequestCont::ICPReqSeqNumber() -{ - // Generate ICP request sequence numbers. This must be unique. - unsigned int res = 0; - do { - res = (unsigned int)ink_atomic_increment((int *)&ICPRequestSeqno, 1); - } while (!res); - - return res; -} - -// Static member function -inline int -ICPRequestCont::ICPRequestHash(unsigned int seqno) -{ - // ICPRequestQueue hash - return seqno % ICP_REQUEST_HASH_SIZE; -} - -// Static member function -int -ICPRequestCont::AddICPRequest(unsigned int seqno, ICPRequestCont *r) -{ - // Add ICP request to ICP outstanding queue (ICPRequestQueue). - // return: 0 - success - - ICPRequestQueue[ICPRequestHash(seqno)].enqueue(r); - return 0; // Success -} - -// Static member function -ICPRequestCont * -ICPRequestCont::FindICPRequest(unsigned int seqno) -{ - // Find ICP request on outstanding queue with the given sequence number - int hash = ICPRequestHash(seqno); - ICPRequestCont *r; - - for (r = (ICPRequestCont *)ICPRequestQueue[hash].head; r; r = (ICPRequestCont *)r->link.next) { - if (r->_sequence_number == seqno) { - return r; - } - } - return (ICPRequestCont *)nullptr; // Not found -} - -// Static member function -int -ICPRequestCont::RemoveICPRequest(unsigned int seqno) -{ - // Remove ICP request from outstanding queue with the given - // sequence number - // Return: 0 - success; 1 - not found - - if (!seqno) { - return 1; // Not found - } - int hash = ICPRequestHash(seqno); - ICPRequestCont *r; - - for (r = (ICPRequestCont *)ICPRequestQueue[hash].head; r; r = (ICPRequestCont *)r->link.next) { - if (r->_sequence_number == seqno) { - ICPRequestQueue[hash].remove(r); - return 0; - } - } - return 1; // Not found -} - -//------------------------------------------------------------------------ -// Class ICPProcessor member functions -// Central class which initializes the ICP world. -// Delegates incoming message processing to ICPHandlerCont -// and outgoing message processing to ICPRequestCont. -// Manages the ICP configuration database derived from TS -// configuration info. -//------------------------------------------------------------------------ - -// Static data declarations for ICPProcessor -void -initialize_thread_for_icp(EThread *e) -{ - (void)e; -} - -ICPProcessor icpProcessorInternal; -ICPProcessorExt icpProcessor(&icpProcessorInternal); - -ICPProcessor::ICPProcessor() - : _l(nullptr), - _Initialized(0), - _AllowIcpQueries(0), - _PendingIcpQueries(0), - _ICPConfig(nullptr), - _ICPPeriodic(nullptr), - _ICPHandler(nullptr), - _mcastCB_handler(nullptr), - _PeriodicEvent(nullptr), - _ICPHandlerEvent(nullptr), - _nPeerList(-1), - _LocalPeer(nullptr), - _curSendPeer(0), - _nSendPeerList(-1), - _curRecvPeer(0), - _nRecvPeerList(-1), - _curParentPeer(0), - _nParentPeerList(-1), - _ValidPollData(0), - _last_recv_peer_bias(0) -{ - memset((void *)_PeerList, 0, sizeof(_PeerList[PEER_LIST_SIZE])); - memset((void *)_SendPeerList, 0, sizeof(_SendPeerList[SEND_PEER_LIST_SIZE])); - memset((void *)_RecvPeerList, 0, sizeof(_RecvPeerList[RECV_PEER_LIST_SIZE])); - memset((void *)_ParentPeerList, 0, sizeof(_ParentPeerList[PARENT_PEER_LIST_SIZE])); - memset((void *)_PeerIDtoPollIndex, 0, sizeof(_PeerIDtoPollIndex[PEER_ID_POLL_INDEX_SIZE])); -} - -ICPProcessor::~ICPProcessor() -{ - if (_ICPPeriodic) { - MUTEX_TAKE_LOCK(_ICPPeriodic->mutex, this_ethread()); - _PeriodicEvent->cancel(); - Mutex_unlock(_ICPPeriodic->mutex, this_ethread()); - } - - if (_ICPHandler) { - MUTEX_TAKE_LOCK(_ICPHandler->mutex, this_ethread()); - _ICPHandlerEvent->cancel(); - Mutex_unlock(_ICPHandler->mutex, this_ethread()); - } -} - -void -ICPProcessor::start() -{ - //***************************************************** - // Perform initialization actions for ICPProcessor - // (called at system startup) - //***************************************************** - if (_Initialized) { // Do only once - return; - } - - // - // Setup ICPProcessor lock, required since ICPProcessor is instantiated - // as static object. - // - _l = new AtomicLock(); - - // - // Setup custom allocators - // - // replaced with generic IOBufferBlock allocator - ICPHandlerCont::ICPDataBuf_IOBuffer_sizeindex = iobuffer_size_to_index(MAX_ICP_MSGSIZE, MAX_BUFFER_SIZE_INDEX); - - // - // Setup ICP stats callbacks - // - InitICPStatCallbacks(); - - // - // Create ICP configuration objects - // - _ICPConfig = new ICPConfiguration(); - - _mcastCB_handler = new ICPHandlerCont(this); - SET_CONTINUATION_HANDLER(_mcastCB_handler, (ICPHandlerContHandler)&ICPHandlerCont::TossEvent); - - // - // Build ICP peer list and setup listen sockets - // - if (_ICPConfig->globalConfig()->ICPconfigured()) { - if (BuildPeerList() == 0) { - if (SetupListenSockets() == 0) { - _AllowIcpQueries = 1; // allow receipt of queries - } - } - } - DumpICPConfig(); - - // - // Start ICP configuration monitor (periodic continuation) - // - _ICPPeriodic = new ICPPeriodicCont(this); - SET_CONTINUATION_HANDLER(_ICPPeriodic, (ICPPeriodicContHandler)&ICPPeriodicCont::PeriodicEvent); - _PeriodicEvent = eventProcessor.schedule_every(_ICPPeriodic, HRTIME_MSECONDS(ICPPeriodicCont::PERIODIC_INTERVAL), ET_ICP); - - // - // Start ICP receive handler continuation - // - _ICPHandler = new ICPHandlerCont(this); - SET_CONTINUATION_HANDLER(_ICPHandler, (ICPHandlerContHandler)&ICPHandlerCont::PeriodicEvent); - _ICPHandlerEvent = eventProcessor.schedule_every(_ICPHandler, HRTIME_MSECONDS(ICPHandlerCont::ICP_HANDLER_INTERVAL), ET_ICP); - // - // Stale lookup data initializations - // - if (!gclient_request.valid()) { - gclient_request.create(HTTP_TYPE_REQUEST); - } - _Initialized = 1; -} - -Action * -ICPProcessor::ICPQuery(Continuation *c, URL *url) -{ - //************************************** - // HTTP state machine interface to ICP - //************************************** - - // Build continuation to process ICP request - EThread *thread = this_ethread(); - ProxyMutex *mutex = thread->mutex.get(); - ICPRequestCont *rc = new (ICPRequestCont_allocator.alloc()) ICPRequestCont(this, c, url); - - ICP_INCREMENT_DYN_STAT(icp_query_requests_stat); - - rc->SetRequestStartTime(); - SET_CONTINUATION_HANDLER(rc, (ICPRequestContHandler)&ICPRequestCont::ICPRequestEvent); - eventProcessor.schedule_imm(rc, ET_ICP); - - return rc->GetActionPtr(); -} - -int -ICPProcessor::BuildPeerList() -{ - // Returns 0 on Success - - // - //--------------------------------------------------------------------- - // We always place all allocated Peer elements onto PeerList[], - // which is used to track allocated elements and validate (ip, port) - // uniqueness in the ICP configuration. - // - // All MultiCastPeer(s) link the underlying ParentSiblingPeer structures - // using a singly linked list off the MultiCastPeer. - // - // Peer elements placed onto SendPeerList[] are elements which are - // the target of ICP queries. - // In the case where MultiCasting is used, a pseudo peer element - // (MultiCastPeer) is placed onto the SendPeerList[] to act as a place - // holder for the underlying Peers. - // - // RecvPeerList[] is the list of Peer(s) we perform reads on for - // ICP messages. In the case of MultiCast, the pseudo MultiCast peer - // element (MultiCastPeer) is placed on this list. Since we currently - // funnel all unicast receives through the local peer UDP socket, - // only the local peer and any pseudo MultiCastPeer structures reside - // on this list. - // - // Parent (PEER_PARENT) Peer elements are also added to ParentPeerList - // which is used to select a parent in the case where all ICP queries - // have returned ICP_MISS. - //--------------------------------------------------------------------- - // - PeerConfigData *Pcfg; - Peer *P; - Peer *mcP; - int index; - int status; - PeerType_t type; - - // - // From the working copy of the ICP configuration data, build the - // internal Peer data structures for ICP processing. - // First, establish the Local Peer descriptor before processing - // parents and siblings. - // - Pcfg = _ICPConfig->indexToPeerConfigData(0); - ink_strlcpy(Pcfg->_hostname, "localhost", sizeof(Pcfg->_hostname)); - Pcfg->_ctype = PeerConfigData::CTYPE_LOCAL; - - // Get IP address for given interface - IpEndpoint tmp_ip; - if (!mgmt_getAddrForIntr(GetConfig()->globalConfig()->ICPinterface(), &tmp_ip.sa)) { - Pcfg->_ip_addr._family = AF_UNSPEC; - // No IP address for given interface - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP interface [%s] has no IP address", GetConfig()->globalConfig()->ICPinterface()); - } else { - Pcfg->_my_ip_addr = Pcfg->_ip_addr = tmp_ip; - } - Pcfg->_proxy_port = 0; - Pcfg->_icp_port = GetConfig()->globalConfig()->ICPport(); - Pcfg->_mc_member = 0; - Pcfg->_mc_ip_addr._family = AF_UNSPEC; - Pcfg->_mc_ttl = 0; - - //*************************************************** - // Descriptor for local host, add to PeerList and - // RecvPeerList - //*************************************************** - P = new ParentSiblingPeer(PEER_LOCAL, Pcfg, this); - status = AddPeer(P); - ink_release_assert(status); - status = AddPeerToRecvList(P); - ink_release_assert(status); - _LocalPeer = P; - - for (index = 1; index < MAX_DEFINED_PEERS; ++index) { - Pcfg = _ICPConfig->indexToPeerConfigData(index); - type = PeerConfigData::CTypeToPeerType_t(Pcfg->GetCType()); - // - // Ignore parent and sibling entries corresponding to "localhost". - // This is possible in a cluster configuration where parents and - // siblings are cluster members. Note that in a cluster - // configuration, "icp.config" is shared by all nodes. - // - if (Pcfg->GetIPAddr() == _LocalPeer->GetIP()) { - continue; // ignore - } - - if ((type == PEER_PARENT) || (type == PEER_SIBLING)) { - if (Pcfg->MultiCastMember()) { - mcP = FindPeer(Pcfg->GetMultiCastIPAddr(), Pcfg->GetICPPort()); - if (!mcP) { - //********************************* - // Create multicast peer structure - //********************************* - mcP = new MultiCastPeer(Pcfg->GetMultiCastIPAddr(), Pcfg->GetICPPort(), Pcfg->GetMultiCastTTL(), this); - status = AddPeer(mcP); - ink_assert(status); - status = AddPeerToSendList(mcP); - ink_assert(status); - status = AddPeerToRecvList(mcP); - ink_assert(status); - } - //***************************** - // Add child to MultiCast peer - //***************************** - P = new ParentSiblingPeer(type, Pcfg, this); - status = AddPeer(P); - ink_assert(status); - status = ((MultiCastPeer *)mcP)->AddMultiCastChild(P); - ink_assert(status); - - } else { - //***************************** - // Add parent/sibling peer - //***************************** - P = new ParentSiblingPeer(type, Pcfg, this); - status = AddPeer(P); - ink_assert(status); - status = AddPeerToSendList(P); - ink_assert(status); - } - //**************************************** - // Also, add parent peers to parent list. - //**************************************** - if (type == PEER_PARENT) { - status = AddPeerToParentList(P); - ink_assert(status); - } - } - } - return 0; // Success -} - -void -ICPProcessor::FreePeerList() -{ - // Deallocate all Peer structures - int index; - for (index = 0; index < (_nPeerList + 1); ++index) { - if (_PeerList[index]) { - _PeerList[index] = nullptr; - } - } - // Reset all control data - _nPeerList = -1; - _LocalPeer = (Peer *)nullptr; - _curSendPeer = 0; - _nSendPeerList = -1; - _curRecvPeer = 0; - _nRecvPeerList = -1; - _curParentPeer = 0; - _nParentPeerList = -1; - _ValidPollData = 0; - _last_recv_peer_bias = 0; - - for (index = 0; index < PEER_LIST_SIZE; index++) { - _PeerList[index] = nullptr; - } - for (index = 0; index < SEND_PEER_LIST_SIZE; index++) { - _SendPeerList[index] = nullptr; - } - for (index = 0; index < RECV_PEER_LIST_SIZE; index++) { - _RecvPeerList[index] = nullptr; - } - for (index = 0; index < PARENT_PEER_LIST_SIZE; index++) { - _ParentPeerList[index] = nullptr; - } - memset((void *)_PeerIDtoPollIndex, 0, sizeof(_PeerIDtoPollIndex[PEER_ID_POLL_INDEX_SIZE])); -} - -int -ICPProcessor::SetupListenSockets() -{ - int allow_null_configuration; - - if ((_ICPConfig->globalConfig()->ICPconfigured() == ICP_MODE_RECEIVE_ONLY) && - _ICPConfig->globalConfig()->ICPReplyToUnknownPeer()) { - allow_null_configuration = 1; - } else { - allow_null_configuration = 0; - } - - // Returns 0 on Success. - - // - // Perform some basic sanity checks on the ICP configuration. - // - if (!_LocalPeer) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP setup, no defined local Peer"); - return 1; // Failed - } - - if (GetSendPeers() == 0) { - if (!allow_null_configuration) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP setup, no defined send Peer(s)"); - return 1; // Failed - } - } - if (GetRecvPeers() == 0) { - if (!allow_null_configuration) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP setup, no defined receive Peer(s)"); - return 1; // Failed - } - } - // - // Establish the required sockets for elements on the PeerList[]. - // - Peer *P; - int status; - int index; - ip_port_text_buffer ipb, ipb2; - for (index = 0; index < (_nPeerList + 1); ++index) { - if ((P = _PeerList[index].get())) { - if ((P->GetType() == PEER_PARENT) || (P->GetType() == PEER_SIBLING)) { - ParentSiblingPeer *pPS = (ParentSiblingPeer *)P; - - pPS->GetChan()->setRemote(pPS->GetIP()); - - } else if (P->GetType() == PEER_MULTICAST) { - MultiCastPeer *pMC = (MultiCastPeer *)P; - ink_assert(_mcastCB_handler != nullptr); - status = pMC->GetSendChan()->setup_mc_send(pMC->GetIP(), _LocalPeer->GetIP(), NON_BLOCKING, pMC->GetTTL(), - DISABLE_MC_LOOPBACK, _mcastCB_handler); - if (status) { - // coverity[uninit_use_in_call] - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP MC send setup failed, res=%d, ip=%s bind_ip=%s", status, - ats_ip_nptop(pMC->GetIP(), ipb, sizeof(ipb)), ats_ip_nptop(_LocalPeer->GetIP(), ipb2, sizeof(ipb2))); - return 1; // Failed - } - - status = pMC->GetRecvChan()->setup_mc_receive(pMC->GetIP(), _LocalPeer->GetIP(), NON_BLOCKING, pMC->GetSendChan(), - _mcastCB_handler); - if (status) { - // coverity[uninit_use_in_call] - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP MC recv setup failed, res=%d, ip=%s", status, - ats_ip_nptop(pMC->GetIP(), ipb, sizeof(ipb))); - return 1; // Failed - } - } - } - } - // - // Setup the socket for the local host. - // We funnel all unicast sends and receives through - // the local peer UDP socket. - // - ParentSiblingPeer *pPS = (ParentSiblingPeer *)(GetLocalPeer()); - - NetVCOptions options; - options.local_ip.assign(pPS->GetIP()); - options.local_port = pPS->GetICPPort(); - options.ip_proto = NetVCOptions::USE_UDP; - options.addr_binding = NetVCOptions::INTF_ADDR; - status = pPS->GetChan()->open(options); - if (status) { - // coverity[uninit_use_in_call] ? - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP bind_connect failed, res=%d, ip=%s", status, - ats_ip_nptop(pPS->GetIP(), ipb, sizeof(ipb))); - return 1; // Failed - } - - return 0; // Success -} - -void -ICPProcessor::ShutdownListenSockets() -{ - // - // Close all open sockets for elements on the PeerList[] - // - ink_assert(!PendingQuery()); - Peer *P; - - for (int index = 0; index < (_nPeerList + 1); ++index) { - if ((P = IdToPeer(index))) { - if (P->GetType() == PEER_LOCAL) { - ParentSiblingPeer *pPS = (ParentSiblingPeer *)P; - (void)pPS->GetChan()->close(); - - } else if (P->GetType() == PEER_MULTICAST) { - MultiCastPeer *pMC = (MultiCastPeer *)P; - (void)pMC->GetSendChan()->close(); - (void)pMC->GetRecvChan()->close(); - } - } - } -} - -int -ICPProcessor::Reconfigure(int /* global_config_changed ATS_UNUSED */, int /* peer_config_changed ATS_UNUSED */) -{ - // Returns 0 on Success - // - // At this point, ICP requests processing is disabled and - // no pending ICP requests exist. - // - ink_assert(_ICPConfig->HaveLock()); - ink_assert(!AllowICPQueries()); - ink_assert(!PendingQuery()); - // - // Shutdown and deallocate all structures associated with the - // current configuration. - // - ShutdownListenSockets(); - FreePeerList(); - // - // Copy the new configuration into the working copy and - // rebuild all associated structures. - // - _ICPConfig->UpdateGlobalConfig(); - _ICPConfig->UpdatePeerConfig(); - - int status = -1; - if (_ICPConfig->globalConfig()->ICPconfigured()) { - if ((status = BuildPeerList()) == 0) { - status = SetupListenSockets(); - } - DumpICPConfig(); - } - return status; -} - -ICPProcessor::ReconfigState_t -ICPProcessor::ReconfigureStateMachine(ReconfigState_t s, int gconfig_changed, int pconfig_changed) -{ - //***************************************************************** - // State machine which performs the ICP reconfiguration actions. - // Defined states are as follows: - // 1) (RC_RECONFIG) disable ICP, reconfigure if no request pending, - // else delay and retry. Reconfigure and if success move to - // RC_ENABLE_ICP else RC_DONE. - // 2) (RC_ENABLE_ICP) enable ICP, free ICP configuration lock. - // 3) (RC_DONE) free ICP configuration lock. - //***************************************************************** - ink_assert(_ICPConfig->HaveLock()); - int reconfig_status; - - while (true) { - switch (s) { - case RC_RECONFIG: { - if (!Lock()) { - return RC_RECONFIG; // Unable to get lock, try again - } - - if (PendingQuery()) { - DisableICPQueries(); // disable ICP processing - Unlock(); - CancelPendingReads(); - return RC_RECONFIG; // Pending requests, delay and retry - - } else { - DisableICPQueries(); // disable ICP processing - Unlock(); - // No pending ICP queries, perform reconfiguration - reconfig_status = Reconfigure(gconfig_changed, pconfig_changed); - - if (reconfig_status == 0) { - s = RC_ENABLE_ICP; // reconfig OK, enable ICP - } else { - s = RC_DONE; // reconfig failed, do not enable ICP - } - break; // move to next state - } - } - - case RC_ENABLE_ICP: { - if (!Lock()) { - return RC_ENABLE_ICP; // Unable to get lock, try again - } - - EnableICPQueries(); // Enable ICP processing - Unlock(); - - s = RC_DONE; - break; // move to next state - } - - case RC_DONE: { - // Release configuration lock - _ICPConfig->Unlock(); - return RC_DONE; // Reconfiguration complete - } - default: { - ink_release_assert(0); // Should never happen - } - - } // End of switch - - } // End of while - return RC_DONE; -} - -void -ICPProcessor::CancelPendingReads() -{ - // Cancel pending ICP read by sending a bogus message to - // the local ICP port. - - ICPRequestCont *r = new (ICPRequestCont_allocator.alloc()) ICPRequestCont(this, nullptr, nullptr); - SET_CONTINUATION_HANDLER(r, (ICPRequestContHandler)&ICPRequestCont::NopICPRequestEvent); - r->mutex = new_ProxyMutex(); - - // TODO: Check return value? - ICPRequestCont::BuildICPMsg(ICP_OP_HIT, 0, 0 /* optflags */, 0 /* optdata */, 0 /* shostid */, (void *)nullptr, 0, - &r->_sendMsgHdr, r->_sendMsgIOV, &r->_ICPmsg); - r->_sendMsgHdr.msg_iovlen = 1; - r->_ICPmsg.h.version = ~r->_ICPmsg.h.version; // bogus message - - Peer *lp = GetLocalPeer(); - IpEndpoint local_endpoint; - ats_ip_copy(&local_endpoint.sa, lp->GetIP()); - r->_sendMsgHdr.msg_name = (caddr_t)&local_endpoint; - r->_sendMsgHdr.msg_namelen = sizeof(local_endpoint); - udpNet.sendmsg_re(r, r, lp->GetSendFD(), &r->_sendMsgHdr); -} - -Peer * -ICPProcessor::GenericFindListPeer(IpAddr const &ip, uint16_t port, int validListItems, Ptr *List) -{ - Peer *P; - port = htons(port); - for (int n = 0; n < validListItems; ++n) { - if ((P = List[n].get())) { - if ((P->GetIP() == ip) && ((port == 0) || (ats_ip_port_cast(P->GetIP()) == port))) { - return P; - } - } - } - return nullptr; -} - -Peer * -ICPProcessor::FindPeer(IpAddr const &ip, uint16_t port) -{ - // Find (Peer *) with the given (ip,port) on the global list (PeerList) - return GenericFindListPeer(ip, port, (_nPeerList + 1), _PeerList); -} - -Peer * -ICPProcessor::FindSendListPeer(IpAddr const &ip, uint16_t port) -{ - // Find (Peer *) with the given (ip,port) on the - // scheduler list (SendPeerList) - return GenericFindListPeer(ip, port, (_nSendPeerList + 1), _SendPeerList); -} - -Peer * -ICPProcessor::FindRecvListPeer(IpAddr const &ip, uint16_t port) -{ - // Find (Peer *) with the given (ip,port) on the - // receive list (RecvPeerList) - return GenericFindListPeer(ip, port, (_nRecvPeerList + 1), _RecvPeerList); -} - -int -ICPProcessor::AddPeer(Peer *P) -{ - // Add (Peer *) to the global list (PeerList). Make sure (ip,port) is - // unique. - // Returns 1 - added; 0 - Not added - - // - // Make sure no duplicate exists - // - if (FindPeer(P->GetIP())) { - ip_port_text_buffer x; - // coverity[uninit_use_in_call] - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "bad icp.config, multiple peer definitions for ip=%s", - ats_ip_nptop(P->GetIP(), x, sizeof(x))); - - return 0; // Not added - } else { - // Valid entry - if (_nPeerList + 1 < PEER_LIST_SIZE) { - _nPeerList++; - _PeerList[_nPeerList] = P; - P->SetPeerID(_nPeerList); - return 1; // Added - } else { - return 0; // Not added - } - } -} - -int -ICPProcessor::AddPeerToRecvList(Peer *P) -{ - // Add (Peer *) to the listen list (RecvPeerList). - // Make sure (ip,port) is unique. - // Returns 1 - added; 0 - Not added - - // Assert that no duplicate exists - ink_assert(FindRecvListPeer(IpAddr(P->GetIP()), ats_ip_port_host_order(P->GetIP())) == nullptr); - - if (_nRecvPeerList + 1 < RECV_PEER_LIST_SIZE) { - _nRecvPeerList++; - _RecvPeerList[_nRecvPeerList] = P; - return 1; // Added - } else { - return 0; // Not added - } -} - -int -ICPProcessor::AddPeerToSendList(Peer *P) -{ - // Add (Peer *) to the scheduler list (SendPeerList). - // Make sure (ip,port) is unique. - // Returns 1 - added; 0 - Not added - - // Assert that no duplicate exists - ink_assert(FindSendListPeer(IpAddr(P->GetIP()), ats_ip_port_host_order(P->GetIP())) == nullptr); - - if (_nSendPeerList + 1 < SEND_PEER_LIST_SIZE) { - _nSendPeerList++; - _SendPeerList[_nSendPeerList] = P; - return 1; // Added - } else { - return 0; // Not added - } -} - -int -ICPProcessor::AddPeerToParentList(Peer *P) -{ - // Add (Peer *) to the parent list (ParentPeerList). - // Returns 1 - added; 0 - Not added - - if (_nParentPeerList + 1 < PARENT_PEER_LIST_SIZE) { - _nParentPeerList++; - _ParentPeerList[_nParentPeerList] = P; - return 1; // Added - } else { - return 0; // Not added - } -} - -// End of ICP.cc diff --git a/proxy/ICP.h b/proxy/ICP.h deleted file mode 100644 index 530c24adaea..00000000000 --- a/proxy/ICP.h +++ /dev/null @@ -1,1364 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/**************************************************************************** - - ICP.h - - -****************************************************************************/ - -#ifndef _ICP_H_ -#define _ICP_H_ - -#include "P_Net.h" -#include "P_Cache.h" -#define ET_ICP ET_CALL -#include "URL.h" -#include "ICPevents.h" -#include "ICPProcessor.h" -#include "ts/DynArray.h" - -//********************************************************************* -// ICP Configurables -//********************************************************************* -#define ICP_DEBUG 1 - -//********************************************************************* -// ICP.h -- Internet Cache Protocol (ICP) related data structures. -// -// Message protocol definitions as defined by RFC 2186 -// "Internet Cache Protocol (ICP), version 2". -//********************************************************************* -typedef struct ICPMsgHeader { - uint8_t opcode; - uint8_t version; - uint16_t msglen; - uint32_t requestno; - uint32_t optionflags; - uint32_t optiondata; - uint32_t shostid; -} ICPMsgHdr_t; - -//----------------------- -// opcode definitions -//----------------------- -typedef enum { - ICP_OP_INVALID, // 00 - ICP_OP_QUERY, // 01 - ICP_OP_HIT, // 02 - ICP_OP_MISS, // 03 - ICP_OP_ERR, // 04 - // - ICP_OP_UNUSED5, // 05 unused - ICP_OP_UNUSED6, // 06 unused - ICP_OP_UNUSED7, // 07 unused - ICP_OP_UNUSED8, // 08 unused - ICP_OP_UNUSED9, // 09 unused - // - ICP_OP_SECHO, // 10 - ICP_OP_DECHO, // 11 - // - ICP_OP_UNUSED12, // 12 unused - ICP_OP_UNUSED13, // 13 unused - ICP_OP_UNUSED14, // 14 unused - ICP_OP_UNUSED15, // 15 unused - ICP_OP_UNUSED16, // 16 unused - ICP_OP_UNUSED17, // 17 unused - ICP_OP_UNUSED18, // 18 unused - ICP_OP_UNUSED19, // 19 unused - ICP_OP_UNUSED20, // 20 unused - // - ICP_OP_MISS_NOFETCH, // 21 - ICP_OP_DENIED, // 22 - ICP_OP_HIT_OBJ, // 23 - ICP_OP_END_OF_OPS // 24 mark end of opcodes -} ICPopcode_t; - -#define ICP_OP_LAST (ICP_OP_END_OF_OPS - 1) - -//----------------------- -// version definitions -//----------------------- -#define ICP_VERSION_1 1 -#define ICP_VERSION_2 2 -#define ICP_VERSION_3 3 -#define ICP_VERSION ICP_VERSION_2 - -//-------------------------- -// optionflags definitions -//-------------------------- -#define ICP_FLAG_HIT_OBJ 0x80000000ul -#define ICP_FLAG_SRC_RTT 0x40000000ul - -//----------------- -// ICP Constants -//----------------- -#define MAX_ICP_MSGSIZE (16 * 1024) -#define MAX_ICP_MSG_PAYLOAD_SIZE (MAX_ICP_MSGSIZE - sizeof(ICPmsgHdr_t)) -#define MAX_ICP_QUERY_PAYLOAD_SIZE (MAX_ICP_MSG_PAYLOAD_SIZE - sizeof(uint32_t)) -#define MAX_DEFINED_PEERS 64 -#define MSG_IOVECS 16 - -//------------ -// ICP Data -//------------ -typedef struct ICPData { - char *URL; // null terminated -} ICPData_t; - -//------------- -// ICP Query -//------------- -typedef struct ICPQuery { - uint32_t rhostid; - char *URL; // null terminated (outgoing) -} ICPQuery_t; - -//------------ -// ICP Hit -//------------ -typedef struct ICPHit { - char *URL; // null terminated -} ICPHit_t; - -//------------ -// ICP Miss -//------------ -typedef struct ICPMiss { - char *URL; // null terminated -} ICPMiss_t; - -//------------------ -// ICP Hit Object -//------------------ -typedef struct ICPHitObj { - char *URL; // null terminated - char *p_objsize; // byte aligned uint16_t immediately follows URL null - uint16_t objsize; // decoded object size - char *data; // object data -} ICPHitObj_t; - -//------------------------ -// ICP message descriptor -//------------------------ -typedef struct ICPMsg { - ICPMsgHdr_t h; - union { - ICPData_t data; - ICPQuery_t query; - ICPHit_t hit; - ICPMiss_t miss; - ICPHitObj_t hitobj; - } un; -} ICPMsg_t; - -//****************************************************************** -// ICP implementation specific data structures. -//****************************************************************** - -class BitMap; -class ICPProcessor; -class ICPPeriodicCont; -class ICPHandlerCont; -class ICPPeerReadCont; -class ICPRequestCont; - -typedef enum { - PEER_NONE = 0, - PEER_PARENT = 1, - PEER_SIBLING = 2, - PEER_LOCAL = 3, - PEER_MULTICAST = 4, -} PeerType_t; - -#if !defined(USE_CAS_FOR_ATOMICLOCK) -class AtomicLock -{ -public: - AtomicLock(); - ~AtomicLock(); - int Lock(); - int HaveLock(); - void Unlock(); - -private: - Ptr _mutex; -}; - -#else // USE_CAS_FOR_ATOMICLOCK -class AtomicLock -{ -public: - AtomicLock(); - ~AtomicLock(); - int Lock(); - int HaveLock(); - void Unlock(); - -private: - enum { - UNLOCKED = 0, - LOCKED = 1, - }; - int32_t _lock_word; -}; -#endif // USE_CAS_FOR_ATOMICLOCK - -//----------------------------------------------------------------- -// Class ICPConfigData -- deal with global ICP configuration data -//----------------------------------------------------------------- -class ICPConfigData -{ - friend class ICPConfiguration; - -public: - ICPConfigData() - : _icp_enabled(0), - _icp_port(0), - _icp_interface(0), - _multicast_enabled(0), - _icp_query_timeout(0), - _cache_lookup_local(0), - _stale_lookup(0), - _reply_to_unknown_peer(0), - _default_reply_port(0), - _cache_generation(-1) - { - } - ~ICPConfigData() {} // Note: _icp_interface freed prior to delete - inline int operator==(ICPConfigData &); - inline int - ICPconfigured() - { - return _icp_enabled; - } - inline int - ICPport() - { - return _icp_port; - } - inline char * - ICPinterface() - { - return _icp_interface; - } - inline int - ICPmulticastConfigured() - { - return _multicast_enabled; - } - inline int - ICPqueryTimeout() - { - return _icp_query_timeout; - } - inline int - ICPLocalCacheLookup() - { - return _cache_lookup_local; - } - inline int - ICPStaleLookup() - { - return _stale_lookup; - } - inline int - ICPReplyToUnknownPeer() - { - return _reply_to_unknown_peer; - } - inline int - ICPDefaultReplyPort() - { - return _default_reply_port; - } - inline cache_generation_t - ICPCacheGeneration() const - { - return _cache_generation; - } - -private: - //--------------------------------------------------------- - // ICP Configuration data derived from "records.config" - //--------------------------------------------------------- - int _icp_enabled; // see ICP_MODE_XXX defines - int _icp_port; - char *_icp_interface; - int _multicast_enabled; - int _icp_query_timeout; - int _cache_lookup_local; - int _stale_lookup; - int _reply_to_unknown_peer; - int _default_reply_port; - int64_t _cache_generation; -}; - -//---------------------------------------------------------------- -// Class PeerConfigData -- deal with peer ICP configuration data -//---------------------------------------------------------------- -class PeerConfigData -{ - friend class ICPConfiguration; - friend class ICPProcessor; - -public: - PeerConfigData(); - PeerConfigData(int ctype, IpAddr const &ip_addr, int proxy_port, int icp_port) - : _ctype(ctype), - _ip_addr(ip_addr), - _proxy_port(proxy_port), - _icp_port(icp_port), - _mc_member(0), - _mc_ttl(0), - _my_ip_addr(ip_addr) - { - _hostname[0] = 0; - } - ~PeerConfigData() {} - bool operator==(PeerConfigData &); - inline const char * - GetHostname() - { - return _hostname; - } - inline int - GetCType() - { - return _ctype; - } - inline IpAddr const & - GetIPAddr() - { - return _my_ip_addr; - } - inline int - GetProxyPort() - { - return _proxy_port; - } - inline int - GetICPPort() - { - return _icp_port; - } - inline int - MultiCastMember() - { - return _mc_member; - } - inline IpAddr const & - GetMultiCastIPAddr() - { - return _mc_ip_addr; - } - inline int - GetMultiCastTTL() - { - return _mc_ttl; - } - - // Static member functions - static PeerType_t CTypeToPeerType_t(int); - static int GetHostIPByName(char *, IpAddr &); - - enum { - HOSTNAME_SIZE = 256, - }; - enum { - CTYPE_NONE = 0, - CTYPE_PARENT = 1, - CTYPE_SIBLING = 2, - CTYPE_LOCAL = 3, - }; - -private: - //--------------------------------------------------------- - // Peer Configuration data derived from "icp.config" - //--------------------------------------------------------- - char _hostname[HOSTNAME_SIZE]; - int _ctype; - IpAddr _ip_addr; - int _proxy_port; - int _icp_port; - //------------------- - // MultiCast data - //------------------- - int _mc_member; - IpAddr _mc_ip_addr; - int _mc_ttl; - - //---------------------------------------------- - // Computed data not subject to "==" test - //---------------------------------------------- - IpAddr _my_ip_addr; -}; - -//--------------------------------------------------------------- -// Class ICPConfigUpdateCont -- Continuation which retries -// icp_config_change_callback(). Continuation started -// due to manager config callout or failure to acquire lock. -//--------------------------------------------------------------- -class ICPConfigUpdateCont : public Continuation -{ -public: - ICPConfigUpdateCont(void *data, void *value); - ~ICPConfigUpdateCont() {} - int RetryICPconfigUpdate(int, Event *); - - enum { - RETRY_INTERVAL = 10, - }; - -private: - void *_data; - void *_value; -}; - -//------------------------------------------------------------------ -// Class ICPConfiguration -- Overall management of ICP Config data -//------------------------------------------------------------------ -class ICPConfiguration -{ -public: - ICPConfiguration(); - ~ICPConfiguration(); - int GlobalConfigChange(); - void UpdateGlobalConfig(); - int PeerConfigChange(); - void UpdatePeerConfig(); - - inline ICPConfigData * - globalConfig() - { - return _icp_cdata; - } - inline PeerConfigData * - indexToPeerConfigData(int index) - { - ink_assert(index <= MAX_DEFINED_PEERS); - return _peer_cdata[index]; - } - - // TS configuration management callout for "icp.config". - static int mgr_icp_config_change_callback(const char *, RecDataT, RecData, void *); - - // ICP configuration callout for ET_ICP - static void *icp_config_change_callback(void *, void *, int startup = 0); - - inline int - Lock() - { - return _l.Lock(); - } - inline void - Unlock() - { - _l.Unlock(); - return; - } - inline int - HaveLock() - { - return _l.HaveLock(); - } - - inline int - ICPConfigCallouts() - { - return _icp_config_callouts; - } - -private: - // Class data declarations - AtomicLock _l; - int _icp_config_callouts; - - // All ICP operation is based on "icp_data" and "peer_cdata". - // The "icp_data_current" and "peer_cdata_current" reflect the - // current state of the configuration. "icp_data_current" is - // updated via configuration callouts. "peer_cdata_current" - // is updated by the periodic ICP processor event (ICPPeriodicCont), - // when configuration management signals us with a callout on "icp.config". - // We merge current to working only after disabling ICP operation and - // waiting for pending requests to complete. - // - ICPConfigData *_icp_cdata; - ICPConfigData *_icp_cdata_current; - PeerConfigData *_peer_cdata[MAX_DEFINED_PEERS + 1]; - PeerConfigData *_peer_cdata_current[MAX_DEFINED_PEERS + 1]; -}; - -//------------------------------------------------------------------------ -// Class Peer -- Internal structure representing ICP peers derived from -// configuration data (abstract base class). -//------------------------------------------------------------------------ - -// Peer state -#define PEER_UP (1 << 0) -#define PEER_MULTICAST_COUNT_EVENT (1 << 1) // Member probe event active -#define PEER_DYNAMIC (1 << 2) // Dynamically added, not in config - -struct CacheVConnection; - -class Peer : public RefCountObj -{ -public: - Peer(PeerType_t, ICPProcessor *, bool dynamic_peer = false); - virtual ~Peer() {} - void LogRecvMsg(ICPMsg_t *, int); - - // Pure virtual functions - virtual sockaddr *GetIP() = 0; - virtual Action *SendMsg_re(Continuation *, void *, struct msghdr *, struct sockaddr const *to) = 0; - virtual Action *RecvFrom_re(Continuation *, void *, IOBufferBlock *, int, struct sockaddr *, socklen_t *) = 0; - virtual int GetRecvFD() = 0; - virtual int GetSendFD() = 0; - virtual int ExpectedReplies(BitMap *) = 0; - virtual int ValidSender(sockaddr *) = 0; - virtual void LogSendMsg(ICPMsg_t *, sockaddr const *) = 0; - virtual int IsOnline() = 0; - virtual Connection *GetSendChan() = 0; - virtual Connection *GetRecvChan() = 0; - virtual int ExtToIntRecvSockAddr(sockaddr const *, sockaddr *) = 0; - - enum { - OFFLINE_THRESHOLD = 20, - }; - - inline PeerType_t - GetType() - { - return _type; - } - inline int - GetPeerID() - { - return _id; - } - inline void - SetPeerID(int newid) - { - _id = newid; - } - inline void - SetNext(Peer *p) - { - _next = p; - } - inline Peer * - GetNext() - { - return _next; - } - inline bool - shouldStartRead() - { - return !notFirstRead; - } - inline void - startingRead() - { - notFirstRead = 1; - } - inline void - cancelRead() - { - notFirstRead = 0; - } - inline bool - readActive() - { - return (readAction != NULL); - } - inline bool - isUp() - { - return (_state & PEER_UP); - } - - // these shouldn't be public - // this is for delayed I/O - Ptr buf; - IpEndpoint fromaddr; - socklen_t fromaddrlen; - int notFirstRead; // priming the reads - Action *readAction; // outstanding read - Action *writeAction; // outstanding write - -protected: - PeerType_t _type; - int _id; // handle for this peer - Peer *_next; - ICPProcessor *_ICPpr; - - //-------------- - // State data - //-------------- - int _state; - - //------------------- - // Peer Statistics - //------------------- - struct PeerStats { - ink_hrtime last_send; - ink_hrtime last_receive; - int sent[ICP_OP_LAST + 1]; - int recv[ICP_OP_LAST + 1]; - int total_sent; - int total_received; - int dropped_replies; // arrived after timeout - } _stats; -}; - -//------------------------------------------------ -// Class ParentSiblingPeer (derived from Peer) -//------------------------------------------------ -class ParentSiblingPeer : public Peer -{ -public: - ParentSiblingPeer(PeerType_t, PeerConfigData *, ICPProcessor *, bool dynamic_peer = false); - ~ParentSiblingPeer() - { - if (_pconfig && (_state & PEER_DYNAMIC)) - delete _pconfig; - } - int GetProxyPort(); - int GetICPPort(); - virtual sockaddr *GetIP(); - virtual Action *SendMsg_re(Continuation *, void *, struct msghdr *, struct sockaddr const *to); - virtual Action *RecvFrom_re(Continuation *, void *, IOBufferBlock *, int, struct sockaddr *, socklen_t *); - virtual int GetRecvFD(); - virtual int GetSendFD(); - virtual int ExpectedReplies(BitMap *); - virtual int ValidSender(struct sockaddr *); - virtual void LogSendMsg(ICPMsg_t *, sockaddr const *); - virtual int ExtToIntRecvSockAddr(sockaddr const *in, sockaddr *out); - inline virtual int - IsOnline() - { - return 1; - } - inline virtual Connection * - GetSendChan() - { - return &_chan; - } - inline virtual Connection * - GetRecvChan() - { - return &_chan; - } - inline PeerConfigData * - GetConfig() - { - return _pconfig; - } - inline Connection * - GetChan() - { - return &_chan; - } - -private: - // Class data declarations - PeerConfigData *_pconfig; // associated config data - IpEndpoint _ip; ///< Cache for GetIP(). - Connection _chan; -}; - -//------------------------------------------------ -// Class MultiCastPeer (derived from Peer) -//------------------------------------------------ -class MultiCastPeer : public Peer -{ -public: - MultiCastPeer(IpAddr const &, uint16_t, int, ICPProcessor *); - ~MultiCastPeer() {} - int GetTTL(); - int AddMultiCastChild(Peer *P); - /** Find the multicast child peer with IP address @a ip on @a port. - If @a port is 0 the port is not checked. - */ - Peer *FindMultiCastChild(IpAddr const &ip, ///< IP address. - uint16_t port = 0 ///< Port (host order). - ); - - virtual sockaddr *GetIP(); - virtual Action *SendMsg_re(Continuation *, void *, struct msghdr *, struct sockaddr const *to); - virtual Action *RecvFrom_re(Continuation *, void *, IOBufferBlock *, int, struct sockaddr *, socklen_t *); - virtual int GetRecvFD(); - virtual int GetSendFD(); - virtual int ExpectedReplies(BitMap *); - virtual int ValidSender(struct sockaddr *); - virtual void LogSendMsg(ICPMsg_t *, sockaddr const *); - virtual int IsOnline(); - inline virtual Connection * - GetRecvChan() - { - return &_recv_chan; - } - inline virtual Connection * - GetSendChan() - { - return &_send_chan; - } - inline virtual int - ExtToIntRecvSockAddr(sockaddr const *in, sockaddr *out) - { - Peer *P = FindMultiCastChild(IpAddr(in)); - if (P) { - ats_ip_copy(out, in); - ats_ip_port_cast(out) = ats_ip_port_cast(P->GetIP()); - return 1; - } else { - return 0; - } - } - -private: - // Class data declarations - Connection _send_chan; - Connection _recv_chan; - //--------------------------- - // Multicast specific data - //--------------------------- - IpEndpoint _mc_ip; - int _mc_ttl; - struct multicast_data { - double avg_members; // running avg of multicast responders - int defined_members; // as specified in icp.config - int n_count_events; // responder count events - int count_event_reqno; // reqno associated with count event - int expected_replies; // current expected responders on multicast - } _mc; -}; - -//---------------------------------------------------- -// Class BitMap -- Generic bit map management class -//---------------------------------------------------- -class BitMap -{ -public: - BitMap(int); - ~BitMap(); - void SetBit(int); - void ClearBit(int); - int IsBitSet(int); - -private: - enum { - STATIC_BITMAP_BYTE_SIZE = 16, - BITS_PER_BYTE = 8, - }; - char _static_bitmap[STATIC_BITMAP_BYTE_SIZE]; - char *_bitmap; - int _bitmap_size; - int _bitmap_byte_size; -}; - -//---------------------------------------- -// ICPProcessor -- ICP External interface -//---------------------------------------- -class ICPProcessor -{ - friend class ICPHandlerCont; // Incoming msg periodic handler - friend class ICPPeerReadCont; // Incoming ICP request handler - friend class ICPRequestCont; // Outgoing ICP request handler - -public: - ICPProcessor(); - ~ICPProcessor(); - - // Exported interfaces for other subsystems - void start(); - Action *ICPQuery(Continuation *, URL *); - - // Exported interfaces to other ICP classes - typedef enum { - RC_RECONFIG, - RC_ENABLE_ICP, - RC_DONE, - } ReconfigState_t; - ReconfigState_t ReconfigureStateMachine(ReconfigState_t, int, int); - - Peer *FindPeer(IpAddr const &ip, uint16_t port = 0); - Peer * - FindPeer(IpEndpoint const &ip) - { - return this->FindPeer(IpAddr(&ip), ats_ip_port_host_order(&ip)); - } - Peer * - FindPeer(sockaddr const *ip) - { - return this->FindPeer(IpAddr(ip), ats_ip_port_host_order(ip)); - } - - inline Peer * - GetLocalPeer() - { - return _LocalPeer.get(); - } - inline Peer * - IdToPeer(int id) - { - return _PeerList[id].get(); - } - inline ICPConfiguration * - GetConfig() - { - return _ICPConfig; - } - - inline int - GetFreePeers() - { - return PEER_LIST_SIZE - (_nPeerList + 1); - } - inline int - GetFreeSendPeers() - { - return SEND_PEER_LIST_SIZE - (_nSendPeerList + 1); - } - inline int - GetFreeRecvPeers() - { - return RECV_PEER_LIST_SIZE - (_nRecvPeerList + 1); - } - -private: - inline int - Lock() - { - return _l->Lock(); - } - inline void - Unlock() - { - _l->Unlock(); - return; - } - inline int - HaveLock() - { - return _l->HaveLock(); - } - int BuildPeerList(); - void FreePeerList(); - int SetupListenSockets(); - void ShutdownListenSockets(); - int Reconfigure(int, int); - void InitICPStatCallbacks(); - - inline void - DisableICPQueries() - { - _AllowIcpQueries = 0; - } - inline void - EnableICPQueries() - { - _AllowIcpQueries = 1; - } - inline int - AllowICPQueries() - { - return _AllowIcpQueries; - } - inline int - PendingQuery() - { - return _PendingIcpQueries; - } - inline void - IncPendingQuery() - { - _PendingIcpQueries++; - } - inline void - DecPendingQuery() - { - _PendingIcpQueries--; - } - - Peer *GenericFindListPeer(IpAddr const &, uint16_t, int, Ptr *); - Peer *FindSendListPeer(IpAddr const &, uint16_t); - Peer *FindRecvListPeer(IpAddr const &, uint16_t); - int AddPeer(Peer *); - int AddPeerToSendList(Peer *); - int AddPeerToRecvList(Peer *); - int AddPeerToParentList(Peer *); - - inline int - GetSendPeers() - { - return _nSendPeerList + 1; - } - inline Peer * - GetNthSendPeer(int n, int bias) - { - return _SendPeerList[(bias + n) % (_nSendPeerList + 1)].get(); - } - - inline int - GetRecvPeers() - { - return _nRecvPeerList + 1; - } - inline Peer * - GetNthRecvPeer(int n, int bias) - { - return _RecvPeerList[(bias + n) % (_nRecvPeerList + 1)].get(); - } - - inline int - GetStartingSendPeerBias() - { - return ++_curSendPeer; - } - inline int - GetStartingRecvPeerBias() - { - return ++_curRecvPeer; - } - - inline int - GetParentPeers() - { - return _nParentPeerList + 1; - } - inline Peer * - GetNthParentPeer(int n, int bias) - { - return _ParentPeerList[(bias + n) % (_nParentPeerList + 1)].get(); - } - inline int - GetStartingParentPeerBias() - { - return ++_curParentPeer; - } - - inline void - SetLastRecvPeerBias(int b) - { - _last_recv_peer_bias = b; - } - inline int - GetLastRecvPeerBias() - { - return _last_recv_peer_bias; - } - void CancelPendingReads(); - void DumpICPConfig(); - -private: - // Class data declarations - AtomicLock *_l; - int _Initialized; - int _AllowIcpQueries; - int _PendingIcpQueries; - ICPConfiguration *_ICPConfig; - ICPPeriodicCont *_ICPPeriodic; - ICPHandlerCont *_ICPHandler; - ICPHandlerCont *_mcastCB_handler; - Event *_PeriodicEvent; - Event *_ICPHandlerEvent; - - enum { - PEER_LIST_SIZE = 2 * MAX_DEFINED_PEERS, - SEND_PEER_LIST_SIZE = 2 * MAX_DEFINED_PEERS, - RECV_PEER_LIST_SIZE = 2 * MAX_DEFINED_PEERS, - PARENT_PEER_LIST_SIZE = 2 * MAX_DEFINED_PEERS, - PEER_ID_POLL_INDEX_SIZE = 2 * MAX_DEFINED_PEERS - }; - - // All Peer elements - int _nPeerList; // valid PeerList[] entries - 1 - Ptr _PeerList[PEER_LIST_SIZE]; - Ptr _LocalPeer; - - // Peers which are targets of ICP queries - int _curSendPeer; // index bias for SendPeerList[] - int _nSendPeerList; // valid SendPeerList[] entries - 1 - Ptr _SendPeerList[SEND_PEER_LIST_SIZE]; - - // List of Peers whom we issue reads from - int _curRecvPeer; // index bias for RecvPeerList[] - int _nRecvPeerList; // valid RecvPeerList[] entries - 1 - Ptr _RecvPeerList[RECV_PEER_LIST_SIZE]; - - // Peers on SendPeerList which are "parent" peers - int _curParentPeer; // index bias for ParentPeerList[] - int _nParentPeerList; // valid ParentPeerList[] entries - 1 - Ptr _ParentPeerList[PARENT_PEER_LIST_SIZE]; - - // Peer ID to Poll descriptor index map - int _ValidPollData; - int _PeerIDtoPollIndex[PEER_ID_POLL_INDEX_SIZE]; - int _last_recv_peer_bias; // bias used to build last poll data -}; - -//----------------------------------------------------------------- -// PeriodicCont -- Abstract base class for periodic ICP processor -// continuations -//----------------------------------------------------------------- -class PeriodicCont : public Continuation -{ -public: - PeriodicCont(ICPProcessor *p); - virtual ~PeriodicCont(); - virtual int PeriodicEvent(int, Event *) = 0; - -protected: - ICPProcessor *_ICPpr; -}; - -//--------------------------------------------------------------- -// ICPPeriodicCont -- ICPProcessor periodic event continuation. -// Periodicly look for ICP configuration updates and if -// updates exist schedule ICP reconfiguration. -//--------------------------------------------------------------- -class ICPPeriodicCont : public PeriodicCont -{ -public: - enum { - PERIODIC_INTERVAL = 5000, - }; - enum { - RETRY_INTERVAL_MSECS = 10, - }; - ICPPeriodicCont(ICPProcessor *); - ~ICPPeriodicCont() {} - virtual int PeriodicEvent(int, Event *); - int DoReconfigAction(int, Event *); - -private: - int _last_icp_config_callouts; - int _global_config_changed; - int _peer_config_changed; -}; - -//----------------------------------------------------------------- -// ICPHandlerCont -- Periodic for incoming message processing -//----------------------------------------------------------------- -class ICPHandlerCont : public PeriodicCont -{ -public: - enum { - ICP_HANDLER_INTERVAL = 10, - }; - ICPHandlerCont(ICPProcessor *); - ~ICPHandlerCont() {} - virtual int PeriodicEvent(int, Event *); - virtual int TossEvent(int, Event *); - -#ifdef DEBUG_ICP -// state history -#define MAX_ICP_HISTORY 20 - struct statehistory { - int event; - int newstate; - char *file; - int line; - }; - statehistory _history[MAX_ICP_HISTORY]; - int _nhistory; - -#define RECORD_ICP_STATE_CHANGE(peerreaddata, event_, newstate_) \ - peerreaddata->_history[peerreaddata->_nhistory].event = event_; \ - peerreaddata->_history[peerreaddata->_nhistory].newstate = newstate_; \ - peerreaddata->_history[peerreaddata->_nhistory].file = __FILE__; \ - peerreaddata->_history[peerreaddata->_nhistory].line = __LINE__; \ - peerreaddata->_nhistory = (peerreaddata->_nhistory + 1) % MAX_ICP_HISTORY; - -#else -#define RECORD_ICP_STATE_CHANGE(x, y, z) -#endif - - static int64_t ICPDataBuf_IOBuffer_sizeindex; -}; - -//------------------------------------------------------------------ -// ICPPeerReadCont -- ICP incoming message processing state machine -//------------------------------------------------------------------ -class ICPPeerReadCont : public Continuation -{ -public: - typedef enum { - READ_ACTIVE, - READ_DATA, - READ_DATA_DONE, - PROCESS_READ_DATA, - ADD_PEER, - AWAITING_CACHE_LOOKUP_RESPONSE, - SEND_REPLY, - WRITE_DONE, - GET_ICP_REQUEST, - GET_ICP_REQUEST_MUTEX, - READ_NOT_ACTIVE, - READ_NOT_ACTIVE_EXIT, - READ_PROCESSING_COMPLETE - } PeerReadState_t; - - class PeerReadData - { - public: - PeerReadData(); - void init(); - ~PeerReadData(); - void reset(int full_reset = 0); - - ink_hrtime _start_time; - ICPPeerReadCont *_mycont; - Ptr _peer; - PeerReadState_t _next_state; - int _cache_lookup_local; - Ptr _buf; // the buffer with the ICP message in it - ICPMsg_t *_rICPmsg; - int _rICPmsg_len; - IpEndpoint _sender; // sender of rICPmsg - URL _cachelookupURL; - int _queryResult; - ICPRequestCont *_ICPReqCont; - int _bytesReceived; - // response data - struct msghdr _mhdr; - struct iovec _iov[MSG_IOVECS]; - }; - - ICPPeerReadCont(); - void init(ICPProcessor *, Peer *, int); - ~ICPPeerReadCont(); - void reset(int full_reset = 0); - int ICPPeerReadEvent(int, Event *); - int ICPPeerQueryCont(int, Event *); - int ICPPeerQueryEvent(int, Event *); - int StaleCheck(int, Event *); - int PeerReadStateMachine(PeerReadData *, Event *); - - enum { - RETRY_INTERVAL = 10, - }; - - // Freshness specific data - CacheVConnection *_object_vc; - HTTPInfo *_object_read; - HdrHeapSDKHandle *_cache_req_hdr_heap_handle; - HdrHeapSDKHandle *_cache_resp_hdr_heap_handle; - // HTTP Config - HttpConfigParams *_http_config_params; - -private: - // Class data - ICPProcessor *_ICPpr; - PeerReadData *_state; - ink_hrtime _start_time; - int _recursion_depth; -}; - -//---------------------------------------------------------------------- -// ICPRequestCont -- ICP Request continuation (Outgoing ICP requests) -//---------------------------------------------------------------------- -class ICPRequestCont : public Continuation -{ - friend class ICPProcessor; - -public: - ICPRequestCont(ICPProcessor *i = 0, Continuation *c = 0, URL *u = 0); - ~ICPRequestCont(); - void *operator new(size_t size, void *mem); - void operator delete(void *mem); - inline void - SetRequestStartTime() - { - _start_time = Thread::get_hrtime(); - } - inline ink_hrtime - GetRequestStartTime() - { - return _start_time; - } - inline class Action * - GetActionPtr() - { - return &_act; - } - - enum { - RETRY_INTERVAL = 10, - }; - enum { - ICP_REQUEST_HASH_SIZE = 1024, - }; - - //*********************************************************************** - // ICPPeerReadCont::PeerReadStateMachine() to - // ICPRequestCont::ICPStateMachine() calling sequence definition. - // - // ICPRequestEvent(ICP_RESPONSE_MESSAGE, ICPRequestEventArgs_t *) - // - //*********************************************************************** - typedef struct ICPRequestEventArgs { - ICPMsg_t *rICPmsg; - int rICPmsg_len; - Peer *peer; - } ICPRequestEventArgs_t; - //*********************************************************************** - int ICPRequestEvent(int, Event *); - int NopICPRequestEvent(int, Event *); - - // Static member functions - static void NetToHostICPMsg(ICPMsg_t *, ICPMsg_t *); - static int BuildICPMsg(ICPopcode_t op, unsigned int sequence_number, int optflags, int optdata, int shostid, void *data, - int datalen, struct msghdr *mhdr, struct iovec *iov, ICPMsg_t *icpmsg); - - static unsigned int ICPReqSeqNumber(); - static int ICPRequestHash(unsigned int); - static int AddICPRequest(unsigned int, ICPRequestCont *); - static ICPRequestCont *FindICPRequest(unsigned int); - static int RemoveICPRequest(unsigned int); - -private: - typedef enum { - ICP_START, - ICP_OFF_TERMINATE, - ICP_QUEUE_REQUEST, - ICP_AWAITING_RESPONSE, - ICP_DEQUEUE_REQUEST, - ICP_POST_COMPLETION, - ICP_WAIT_SEND_COMPLETE, - ICP_REQUEST_NOT_ACTIVE, - ICP_DONE - } ICPstate_t; - int ICPStateMachine(int, void *); - int ICPResponseMessage(int, ICPMsg_t *, Peer *); - void remove_from_pendingActions(Action *); - void remove_all_pendingActions(); - - // Static data - static uint32_t ICPRequestSeqno; - - // Passed request data - Continuation *_cont; - URL *_url; - - // Return data - IpEndpoint _ret_sockaddr; - ICPreturn_t _ret_status; - class Action _act; - - // Internal working data - ink_hrtime _start_time; - ICPProcessor *_ICPpr; - Event *_timeout; - - // outstanding actions - int npending_actions; - DynArray *pendingActions; - - ICPMsg_t _ICPmsg; - struct msghdr _sendMsgHdr; - struct iovec _sendMsgIOV[MSG_IOVECS]; - - unsigned int _sequence_number; - int _expected_replies; - BitMap _expected_replies_list; - int _received_replies; - ICPstate_t _next_state; -}; - -extern ClassAllocator ICPRequestCont_allocator; - -typedef int (*PluginFreshnessCalcFunc)(void *contp); -extern PluginFreshnessCalcFunc pluginFreshnessCalcFunc; - -inline void * -ICPRequestCont::operator new(size_t /* size ATS_UNUSED */, void *mem) -{ - return mem; -} - -inline void -ICPRequestCont::operator delete(void *mem) -{ - ICPRequestCont_allocator.free((ICPRequestCont *)mem); -} - -extern struct RecRawStatBlock *icp_rsb; - -enum { - icp_stat_def, - config_mgmt_callouts_stat, - reconfig_polls_stat, - reconfig_events_stat, - invalid_poll_data_stat, - no_data_read_stat, - short_read_stat, - invalid_sender_stat, - read_not_v2_icp_stat, - icp_remote_query_requests_stat, - icp_remote_responses_stat, - icp_cache_lookup_success_stat, - icp_cache_lookup_fail_stat, - query_response_write_stat, - query_response_partial_write_stat, - no_icp_request_for_response_stat, - icp_response_request_nolock_stat, - icp_start_icpoff_stat, - send_query_partial_write_stat, - icp_queries_no_expected_replies_stat, - icp_query_hits_stat, - icp_query_misses_stat, - invalid_icp_query_response_stat, - icp_query_requests_stat, - total_icp_response_time_stat, - total_udp_send_queries_stat, - total_icp_request_time_stat, - icp_total_reloads, - icp_pending_reloads, - icp_reload_start_aborts, - icp_reload_connect_aborts, - icp_reload_read_aborts, - icp_reload_write_aborts, - icp_reload_successes, - icp_stat_count -}; - -#define ICP_EstablishStaticConfigInteger(_ix, _n) REC_EstablishStaticConfigInt32(_ix, _n) - -#define ICP_EstablishStaticConfigStringAlloc(_ix, n) REC_EstablishStaticConfigStringAlloc(_ix, n) - -#define ICP_INCREMENT_DYN_STAT(x) RecIncrRawStat(icp_rsb, mutex->thread_holding, (int)x, 1) -#define ICP_DECREMENT_DYN_STAT(x) RecIncrRawStat(icp_rsb, mutex->thread_holding, (int)x, -1) -#define ICP_SUM_DYN_STAT(x, y) RecIncrRawStat(icp_rsb, mutex->thread_holding, (int)x, (y)) -#define ICP_READ_DYN_STAT(x, C, S) \ - RecGetRawStatCount(icp_rsb, (int)x, &C); \ - RecGetRawStatSum(icp_rsb, (int)x, &S); - -#define ICP_ReadConfigString REC_ReadConfigString -#define ICP_RegisterConfigUpdateFunc REC_RegisterConfigUpdateFunc - -// End of ICP.h - -#endif // _ICP_H_ diff --git a/proxy/ICPConfig.cc b/proxy/ICPConfig.cc deleted file mode 100644 index 95487210526..00000000000 --- a/proxy/ICPConfig.cc +++ /dev/null @@ -1,1518 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/**************************************************************************** - - ICPConfig.cc - - -****************************************************************************/ - -#include "ts/ink_platform.h" -#include "ts/ink_file.h" -#include "P_EventSystem.h" -#include "P_Cache.h" -#include "P_Net.h" -#include "P_RecProcess.h" -#include "Main.h" -#include "ICP.h" -#include "ICPProcessor.h" -#include "ICPlog.h" -#include "BaseManager.h" -#include "ts/I_Layout.h" - -//-------------------------------------------------------------------------- -// Each ICP peer is described in "icp.config" with the -// following info: -// hostname (string) -- hostname, used only if (host_ip_str == 0) -// host_ip_str (string) -- decimal dot notation; if null get IP -// addresss via lookup on hostname -// ctype (int) -- 1=Parent, 2=Sibling, 3=local -// proxy_port (int) -- TCP Port # -// icp_port (int) -- UDP Port # -// multicast_member -- 0=No 1=Yes -// multicast_ip_str (string) -- decimal dot notation -// multicast_ttl (int) -- (1 - 2; default 1) -// -//############################################################################# -// -// ICP global configuration options are described in "records.config" using -// the following entries. -// -// proxy.config.icp.icp_configuration STRING (default "icp.config") -// proxy.config.icp.enabled INT (0=No 1=Yes) -// proxy.config.icp.icp_port INT 3130 -// proxy.config.icp.icp_interface STRING hme0 -// proxy.config.icp.multicast_enabled INT (0=No 1=Yes) -// proxy.config.icp.query_timeout INT (seconds default is 2 secs) -// proxy.config.icp.lookup_local INT (default is cluster lookup) -// -// Example (1 parent and 1 sibling): -// ============================================ -// proxy.config.icp.enabled INT 1 -// proxy.config.icp.multicast_enabled INT 0 -// proxy.config.icp.query_timeout INT 2 -// -// === "icp.config" entries === -// -// hostname: "host1" -// host_ip_str: "209.1.33.10" -// ctype: 1 -// proxy_port: 8080 -// icp_port: 3130 -// multicast_member 0 -// multicast_ip_str: "0.0.0.0" -// multicast_ttl: 0 -// -// hostname: "host2" -// host_ip_str: "209.1.33.11" -// ctype: 2 -// proxy_port: 8080 -// icp_port: 3130 -// multicast_member 0 -// multicast_ip_str: "0.0.0.0" -// multicast_ttl: 0 -// -// Example (1 parent and 1 sibling using MultiCast): -// ============================================================ -// proxy.config.icp.enabled INT 1 -// proxy.config.icp.multicast_enabled INT 1 -// proxy.config.icp.query_timeout INT 2 -// -// === "icp.config" entries === -// -// hostname: "host1" -// host_ip_str: "209.1.33.10" -// ctype: 1 -// proxy_port: 8080 -// icp_port: 3130 -// multicast_member 1 -// multicast_ip_str: "239.128.16.128" -// multicast_ttl: 1 -// -// hostname: "host2" -// host_ip_str: "209.1.33.11" -// ctype: 2 -// proxy_port: 8080 -// icp_port: 3130 -// multicast_member 1 -// multicast_ip_str: "239.128.16.128" -// multicast_ttl: 1 -// - -//------------------------------------ -// Class AtomicLock member functions -//------------------------------------ -#if !defined(USE_CAS_FOR_ATOMICLOCK) -AtomicLock::AtomicLock() -{ - _mutex = new_ProxyMutex(); -} - -AtomicLock::~AtomicLock() -{ -} - -int -AtomicLock::Lock() -{ - EThread *et = this_ethread(); - ink_assert(et != nullptr); - return MUTEX_TAKE_TRY_LOCK(_mutex, et); -} - -int -AtomicLock::HaveLock() -{ - EThread *et = this_ethread(); - ink_assert(et != nullptr); - return (_mutex->thread_holding == et); -} - -void -AtomicLock::Unlock() -{ - EThread *et = this_ethread(); - ink_assert(et != nullptr); - MUTEX_UNTAKE_LOCK(_mutex, et); -} - -#else // USE_CAS_FOR_ATOMICLOCK -AtomicLock::AtomicLock() : lock_word(0) -{ -} - -AtomicLock::~AtomicLock() -{ -} - -int -AtomicLock::Lock() -{ - bool status = ink_atomic_cas(&_lock_word, AtomicLock::UNLOCKED, AtomicLock::LOCKED); - return status; -} - -int -AtomicLock::HaveLock() -{ - return (_lock_word == LOCKED); -} - -void -AtomicLock::Unlock() -{ - ink_assert(_lock_word == AtomicLock::LOCKED); - _lock_word = AtomicLock::UNLOCKED; -} -#endif // USE_CAS_FOR_ATOMICLOCK - -//--------------------------------------------------------------------- -// Class BitMap -- Member functions. -// Generic bitmap management class -// Note: Bit positions are zero based (0 .. (bitmap_maxsize-1) ) -//--------------------------------------------------------------------- -BitMap::BitMap(int bitmap_maxsize) -{ - if (bitmap_maxsize <= (int)(STATIC_BITMAP_BYTE_SIZE * BITS_PER_BYTE)) { - _bitmap = _static_bitmap; - _bitmap_size = bitmap_maxsize; - _bitmap_byte_size = STATIC_BITMAP_BYTE_SIZE; - } else { - _bitmap_byte_size = (bitmap_maxsize + (BITS_PER_BYTE - 1)) / BITS_PER_BYTE; - _bitmap = new char[_bitmap_byte_size]; - _bitmap_size = bitmap_maxsize; - } - memset((void *)_bitmap, 0, _bitmap_byte_size); -} - -BitMap::~BitMap() -{ - if (_bitmap_size > (int)(STATIC_BITMAP_BYTE_SIZE * BITS_PER_BYTE)) { - delete[] _bitmap; - } -} - -void -BitMap::SetBit(int bit) -{ - if (bit >= _bitmap_size) { - return; - } - - char *pbyte = &_bitmap[bit / BITS_PER_BYTE]; - *pbyte |= (1 << (bit % BITS_PER_BYTE)); -} - -void -BitMap::ClearBit(int bit) -{ - if (bit >= _bitmap_size) { - return; - } - - char *pbyte = &_bitmap[bit / BITS_PER_BYTE]; - *pbyte &= ~(1 << (bit % BITS_PER_BYTE)); -} - -int -BitMap::IsBitSet(int bit) -{ - if (bit >= _bitmap_size) { - return 0; - } - - char *pbyte = &_bitmap[bit / BITS_PER_BYTE]; - if (*pbyte & (1 << (bit % BITS_PER_BYTE))) { - return 1; - } else { - return 0; - } -} - -//----------------------------------------------------------------------- -// Class ICPConfigData member functions -// Manage global ICP configuration data from the TS configuration. -// Support class for ICPConfiguration. -//----------------------------------------------------------------------- -int -ICPConfigData::operator==(ICPConfigData &ICPData) -{ - if (ICPData._icp_enabled != _icp_enabled) { - return 0; - } - if (ICPData._icp_port != _icp_port) { - return 0; - } - if (ICPData._icp_interface != _icp_interface) { - return 0; - } - if (ICPData._multicast_enabled != _multicast_enabled) { - return 0; - } - if (ICPData._icp_query_timeout != _icp_query_timeout) { - return 0; - } - if (ICPData._cache_lookup_local != _cache_lookup_local) { - return 0; - } - if (ICPData._stale_lookup != _stale_lookup) { - return 0; - } - if (ICPData._reply_to_unknown_peer != _reply_to_unknown_peer) { - return 0; - } - if (ICPData._default_reply_port != _default_reply_port) { - return 0; - } - return 1; -} - -//------------------------------------------------------------------------ -// Class PeerConfigData member functions -// Manage ICP Peer configuration data from the TS configuration. -// Support class for ICPConfiguration. -//------------------------------------------------------------------------ -PeerConfigData::PeerConfigData() : _ctype(CTYPE_NONE), _proxy_port(0), _icp_port(0), _mc_member(0), _mc_ttl(0) -{ - memset(_hostname, 0, HOSTNAME_SIZE); -} - -PeerType_t -PeerConfigData::CTypeToPeerType_t(int ctype) -{ - switch (ctype) { - case (int)CTYPE_PARENT: - return PEER_PARENT; - - case (int)CTYPE_SIBLING: - return PEER_SIBLING; - - case (int)CTYPE_LOCAL: - return PEER_LOCAL; - - default: - return PEER_NONE; - } -} - -int -PeerConfigData::GetHostIPByName(char *hostname, IpAddr &rip) -{ - // Short circuit NULL hostname case - if (nullptr == hostname || 0 == *hostname) { - return 1; // Unable to map to IP address - } - - addrinfo hints; - addrinfo *ai; - sockaddr const *best = nullptr; - - ink_zero(hints); - hints.ai_family = AF_UNSPEC; - hints.ai_flags = AI_ADDRCONFIG; - if (0 == getaddrinfo(hostname, nullptr, &hints, &ai)) { - for (addrinfo *spot = ai; spot; spot = spot->ai_next) { - // If current address is valid, and either we don't have one yet - // or this address is less than our current, set it as current. - if (ats_is_ip(spot->ai_addr) && (!best || -1 == ats_ip_addr_cmp(spot->ai_addr, best))) { - best = spot->ai_addr; - } - } - if (best) { - rip.assign(best); - } - freeaddrinfo(ai); - } - return best ? 0 : 1; -} - -bool -PeerConfigData::operator==(PeerConfigData &PeerData) -{ - if (strncmp(PeerData._hostname, _hostname, PeerConfigData::HOSTNAME_SIZE) != 0) { - return false; - } - if (PeerData._ctype != _ctype) { - return false; - } - if (PeerData._ip_addr != _ip_addr) { - return false; - } - if (PeerData._proxy_port != _proxy_port) { - return false; - } - if (PeerData._icp_port != _icp_port) { - return false; - } - if (PeerData._mc_member != _mc_member) { - return false; - } - if (PeerData._mc_ip_addr != _mc_ip_addr) { - return false; - } - if (PeerData._mc_ttl != _mc_ttl) { - return false; - } - return true; -} - -//----------------------------------------------------------------------- -// Class ICPConfigUpdateCont member functions -// Retry callout to ICPConfiguration::icp_config_change_callback() -//----------------------------------------------------------------------- -ICPConfigUpdateCont::ICPConfigUpdateCont(void *d, void *v) : Continuation(new_ProxyMutex()), _data(d), _value(v) -{ -} - -int -ICPConfigUpdateCont::RetryICPconfigUpdate(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) -{ - ICPConfiguration::icp_config_change_callback(_data, _value); - delete this; - return EVENT_DONE; -} - -//-------------------------------------------------------------------------- -// Class ICPConfiguration member functions -// Overall manager of ICP configuration data from TS configuration. -//-------------------------------------------------------------------------- -typedef int (ICPConfigUpdateCont::*ICPCfgContHandler)(int, void *); -ICPConfiguration::ICPConfiguration() : _icp_config_callouts(0) -{ - //********************************************************* - // Allocate working and current ICPConfigData structures - //********************************************************* - _icp_cdata = new ICPConfigData(); - _icp_cdata_current = new ICPConfigData(); - - //******************************************************************** - // Read ICP config and setup update callbacks for "icp_cdata_current" - //******************************************************************** - ICP_EstablishStaticConfigInteger(_icp_cdata_current->_icp_enabled, "proxy.config.icp.enabled"); - ICP_EstablishStaticConfigInteger(_icp_cdata_current->_icp_port, "proxy.config.icp.icp_port"); - ICP_EstablishStaticConfigStringAlloc(_icp_cdata_current->_icp_interface, "proxy.config.icp.icp_interface"); - ICP_EstablishStaticConfigInteger(_icp_cdata_current->_multicast_enabled, "proxy.config.icp.multicast_enabled"); - ICP_EstablishStaticConfigInteger(_icp_cdata_current->_icp_query_timeout, "proxy.config.icp.query_timeout"); - ICP_EstablishStaticConfigInteger(_icp_cdata_current->_cache_lookup_local, "proxy.config.icp.lookup_local"); - ICP_EstablishStaticConfigInteger(_icp_cdata_current->_stale_lookup, "proxy.config.icp.stale_icp_enabled"); - ICP_EstablishStaticConfigInteger(_icp_cdata_current->_reply_to_unknown_peer, "proxy.config.icp.reply_to_unknown_peer"); - ICP_EstablishStaticConfigInteger(_icp_cdata_current->_default_reply_port, "proxy.config.icp.default_reply_port"); - REC_EstablishStaticConfigInteger(_icp_cdata_current->_cache_generation, "proxy.config.http.cache.generation"); - - UpdateGlobalConfig(); // sync working copy with current - - //********************************************************** - // Allocate working and current PeerConfigData structures - //********************************************************** - for (int n = 0; n <= MAX_DEFINED_PEERS; ++n) { - _peer_cdata[n] = new PeerConfigData; - _peer_cdata_current[n] = new PeerConfigData; - } - - //********************************************************* - // Initialize Peer data by simulating an update callout. - //********************************************************* - char icp_config_filename[PATH_NAME_MAX] = ""; - ICP_ReadConfigString(icp_config_filename, "proxy.config.icp.icp_configuration", sizeof(icp_config_filename) - 1); - (void)icp_config_change_callback((void *)this, (void *)icp_config_filename, 1); - UpdatePeerConfig(); // sync working copy with current - - //*************************************** - // Setup update callout on "icp.config" - //*************************************** - ICP_RegisterConfigUpdateFunc("proxy.config.icp.icp_configuration", mgr_icp_config_change_callback, (void *)this); -} - -ICPConfiguration::~ICPConfiguration() -{ -// TBD: Need to disable update callbacks before deallocating data. -// How do we do this? For now, this never happens. -#ifdef OMIT - if (_icp_cdata) { - // TBD: Make sure _icp_cdata->_icp_interface has been freed - delete ((void *)_icp_cdata); - } - if (_icp_cdata_current) - delete ((void *)_icp_cdata_current); - if (_peer_cdata) - delete ((void *)_peer_cdata); - if (_peer_cdata_current) - delete ((void *)_peer_cdata_current); -#endif // OMIT -} - -int -ICPConfiguration::GlobalConfigChange() -{ - return (!(*_icp_cdata == *_icp_cdata_current)); -} - -void -ICPConfiguration::UpdateGlobalConfig() -{ - *_icp_cdata = *_icp_cdata_current; -} - -int -ICPConfiguration::PeerConfigChange() -{ - // Note: Entry zero reserved for "localhost" - for (int i = 1; i <= MAX_DEFINED_PEERS; ++i) { - if (!(*_peer_cdata[i] == *_peer_cdata_current[i])) { - return 1; - } - } - return 0; -} - -void -ICPConfiguration::UpdatePeerConfig() -{ - // Note: Entry zero reserved for "localhost" - for (int i = 1; i <= MAX_DEFINED_PEERS; ++i) { - // - // Broken on DEC and Solaris x86 - // *_peer_cdata[i] = *_peer_cdata_current[i]; - // - memcpy(_peer_cdata[i], _peer_cdata_current[i], sizeof(*_peer_cdata[i])); - // Setup IP address - if ((_peer_cdata[i]->_ip_addr.isValid()) && _peer_cdata[i]->_hostname[0]) { - // IP address not specified, lookup using hostname. - (void)PeerConfigData::GetHostIPByName(_peer_cdata[i]->_hostname, _peer_cdata[i]->_my_ip_addr); - } else { - // IP address specified by user, lookup on hostname not required. - _peer_cdata[i]->_my_ip_addr = _peer_cdata[i]->_ip_addr; - } - } -} - -int -ICPConfiguration::mgr_icp_config_change_callback(const char * /* name ATS_UNUSED */, RecDataT /* data_type ATS_UNUSED */, - RecData data, void *cookie) -{ - //***************************************************************** - // Callout invoked by Configuration management when changes occur - // to icp.config - //***************************************************************** - - // Map this manager configuration callout onto ET_ICP - - ICPConfigUpdateCont *rh = new ICPConfigUpdateCont(cookie, data.rec_string); - SET_CONTINUATION_HANDLER(rh, (ICPCfgContHandler)&ICPConfigUpdateCont::RetryICPconfigUpdate); - eventProcessor.schedule_imm(rh, ET_ICP); - return EVENT_DONE; -} - -namespace -{ -inline char * -next_field(char *text, char fs) -{ - text = strchr(text, fs); - // Compress contiguous whitespace by leaving zret pointing at the last space. - if (text && *text == fs) { - while (text[1] == fs) { - ++text; - } - } - return text; -} -} - -void * -ICPConfiguration::icp_config_change_callback(void *data, void *value, int startup) -{ - EThread *thread = this_ethread(); - ProxyMutex *mutex = thread->mutex.get(); - - // - // Cast passed parameters to correct types - // - char *filename = (char *)value; - ICPConfiguration *ICPconfig = (ICPConfiguration *)data; - - // - // Determine if data is locked, if so defer update action - // - if (!startup && !ICPconfig->Lock()) { - // Build retry continuation - ICPConfigUpdateCont *rh = new ICPConfigUpdateCont(data, value); - SET_CONTINUATION_HANDLER(rh, (ICPCfgContHandler)&ICPConfigUpdateCont::RetryICPconfigUpdate); - eventProcessor.schedule_in(rh, HRTIME_MSECONDS(ICPConfigUpdateCont::RETRY_INTERVAL), ET_ICP); - return EVENT_DONE; - } - ICP_INCREMENT_DYN_STAT(config_mgmt_callouts_stat); - ICPconfig->_icp_config_callouts++; - - // - // Allocate working buffer for PeerConfigData[] - // - PeerConfigData *P = new PeerConfigData[MAX_DEFINED_PEERS + 1]; - - // - // Build pathname to "icp.config" and open file - // - ink_release_assert(filename != nullptr); - - ats_scoped_str config_path(Layout::get()->relative_to(Layout::get()->sysconfdir, filename)); - int fd = open(config_path, O_RDONLY); - if (fd < 0) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, open failed"); - delete[] P; - return EVENT_DONE; - } - //*********************************************************************** - // Parse records in "icp.config" - // Each line is formatted as follows with ":" separator for each field - // - hostname (string) -- Identifier for entry - // - host_ip_str (string) -- decimal dot notation - // - ctype (int) -- 1=Parent, 2=Sibling, 3=Local - // - proxy_port (int) -- TCP Port # - // - icp_port (int) -- UDP Port # - // - multicast_member -- 0=No 1=Yes - // - multicast_ip_str (string) -- decimal dot notation - // - multicast_ttl (int) -- (1 - 2; default 1) - //*********************************************************************** - const int colons_per_entry = 8; // expected ':' separators per entry - - int error = 0; - int ln = 0; - int n_colons; - char line[512]; - char *cur; - char *next; - char *p; - char fs = ':'; // field separator. - int len; // length of current input line (original). - - int n = 1; // Note: Entry zero reserved for "localhost" data - - ////////////////////////////////////////////////////////////////////// - // Read and parse "icp.config" entries. - // - // Note: ink_file_fd_readline() null terminates returned buffer - ////////////////////////////////////////////////////////////////////// - while ((len = ink_file_fd_readline(fd, sizeof(line) - 1, line)) > 0) { - ln++; - cur = line; - while (isspace(*cur)) { - ++cur, --len; // skip leading space. - } - if (!*cur || *cur == '#') { - continue; - } - - if (n >= MAX_DEFINED_PEERS) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, maximum peer entries exceeded"); - error = 1; - break; - } - //*********************************** - // Verify general syntax of entry - //*********************************** - /* Ugly. The original field separator was colon, but we can't have that - if we want to support IPv6. So - since each line is required to have a - separator at the end of the line, we look there and require it to be - consistent. It still must be an acceptable character. - */ - char *last = cur + len - 1; // last character. - if ('\n' == *last) { - --last; // back over trailing LF. - } - if (nullptr == strchr(" ;:|,", *last)) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, invalid separator [value %d]", *last); - error = 1; - break; - } - fs = *last; - - n_colons = 0; - p = cur; - while (nullptr != (p = next_field(p, fs))) { - ++p; - ++n_colons; - } - if (n_colons != colons_per_entry) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, invalid syntax, line %d: expected %d fields, found %d", ln, - colons_per_entry, n_colons); - error = 1; - break; - } - //******************* - // Extract hostname - //******************* - next = next_field(cur, fs); - *next++ = 0; - if (cur != (next - 1)) { - ink_strlcpy(P[n]._hostname, cur, PeerConfigData::HOSTNAME_SIZE); - } else { - P[n]._hostname[0] = 0; - } - //********************* - // Extract host_ip_str - //********************* - cur = next; - next = next_field(next, fs); - *next++ = 0; - if (cur != (next - 1)) { - if (0 != P[n]._ip_addr.load(cur)) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, bad host ip_addr, line %d", ln); - error = 1; - break; - } - } else { - P[n]._ip_addr.invalidate(); - } - - if (!P[n]._hostname[0] && !P[n]._ip_addr.isValid()) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, bad hostname, line %d", ln); - error = 1; - break; - } - //****************** - // Extract ctype - //****************** - cur = next; - next = next_field(next, fs); - *next++ = 0; - if (cur != (next - 1)) { - P[n]._ctype = atoi(cur); - if ((P[n]._ctype != PeerConfigData::CTYPE_PARENT) && (P[n]._ctype != PeerConfigData::CTYPE_SIBLING) && - (P[n]._ctype != PeerConfigData::CTYPE_LOCAL)) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, bad ctype, line %d", ln); - error = 1; - break; - } - } else { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, 2bad ctype, line %d", ln); - error = 1; - break; - } - //********************* - // Extract proxy_port - //********************* - cur = next; - next = next_field(next, fs); - *next++ = 0; - if (cur != (next - 1)) { - if ((P[n]._proxy_port = atoi(cur)) <= 0) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, bad proxy_port, line %d", ln); - error = 1; - break; - } - } else { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, 2bad proxy_port, line %d", ln); - error = 1; - break; - } - //********************* - // Extract icp_port - //********************* - cur = next; - next = next_field(next, fs); - *next++ = 0; - if (cur != (next - 1)) { - if ((P[n]._icp_port = atoi(cur)) <= 0) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, bad icp_port, line %d", ln); - error = 1; - break; - } - } else { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, 2bad icp_port, line %d", ln); - error = 1; - break; - } - //**************************** - // Extract multicast_member - //**************************** - cur = next; - next = next_field(next, fs); - *next++ = 0; - if (cur != (next - 1)) { - if ((P[n]._mc_member = atoi(cur)) < 0) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, bad mc_member, line %d", ln); - error = 1; - break; - } - if ((P[n]._mc_member != 0) && (P[n]._mc_member != 1)) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, bad mc_member (2), line %d", ln); - error = 1; - break; - } - } else { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, 2bad mc_member, line %d", ln); - error = 1; - break; - } - //**************************** - // Extract multicast_ip_str - //**************************** - cur = next; - next = next_field(next, fs); - *next++ = 0; - if (cur != (next - 1)) { - P[n]._mc_ip_addr.load(cur); - // Validate only if "multicast_member" is set. - if (P[n]._mc_member != 0 && !P[n]._mc_ip_addr.isMulticast()) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, bad multicast ip_addr, line %d", ln); - error = 1; - break; - } - } else { - P[n]._mc_ip_addr.invalidate(); - } - //************************ - // Extract multicast_ttl - //************************ - // Note: last entry is always terminated with a ":" - cur = next; - next = next_field(next, fs); - *next++ = 0; - if (cur != (next - 1)) { - P[n]._mc_ttl = atoi(cur); - if ((P[n]._mc_ttl = atoi(cur)) <= 0) { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, bad mc_ttl, line %d", ln); - error = 1; - break; - } - } else { - RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, 2bad mc_ttl, line %d", ln); - error = 1; - break; - } - n++; // bump PeerConfigData[] index - } - close(fd); - - if (!error) { - for (int i = 0; i <= MAX_DEFINED_PEERS; i++) { - *ICPconfig->_peer_cdata_current[i] = P[i]; - } - } - delete[] P; // free working buffer - if (!startup) { - ICPconfig->Unlock(); - } - return EVENT_DONE; -} - -//------------------------------------------------------- -// Class Peer member functions (abstract base class) -//------------------------------------------------------- -Peer::Peer(PeerType_t t, ICPProcessor *icpPr, bool dynamic_peer) - : buf(nullptr), - notFirstRead(0), - readAction(nullptr), - writeAction(nullptr), - _type(t), - _next(nullptr), - _ICPpr(icpPr), - _state(PEER_UP) -{ - notFirstRead = 0; - if (dynamic_peer) { - _state |= PEER_DYNAMIC; - } - memset((void *)&this->_stats, 0, sizeof(this->_stats)); - ink_zero(fromaddr); - fromaddrlen = sizeof(fromaddr); - _id = 0; -} - -void -Peer::LogRecvMsg(ICPMsg_t *m, int valid) -{ - // Note: ICPMsg_t (m) is in native byte order - - // Note numerous stats on a per peer basis - _stats.last_receive = Thread::get_hrtime(); - if ((m->h.opcode >= ICP_OP_QUERY) && (m->h.opcode <= ICP_OP_LAST)) { - _stats.recv[m->h.opcode]++; - } else { - _stats.recv[ICP_OP_INVALID]++; - } - _stats.total_received++; - - if (!valid) { - // Message arrived, but ICP request no longer on pending list - _stats.dropped_replies++; - } - if ((_state & PEER_UP) == 0) { - ip_port_text_buffer ipb; - // Currently marked down so we still send but do not expect reply. - // Now mark up so we will wait for reply. - _state |= PEER_UP; - _stats.total_received = _stats.total_sent; // restart timeout count - - Debug("icp", "Peer [%s] now back online", ats_ip_nptop(this->GetIP(), ipb, sizeof(ipb))); - } -} - -//--------------------------------------------------------------- -// Class ParentSiblingPeer (derived from Peer) member functions -// ICP object describing Parent or Sibling Peers. -//--------------------------------------------------------------- -ParentSiblingPeer::ParentSiblingPeer(PeerType_t t, PeerConfigData *p, ICPProcessor *icpPr, bool dynamic_peer) - : Peer(t, icpPr, dynamic_peer), _pconfig(p) -{ - ats_ip_set(&_ip.sa, _pconfig->GetIPAddr(), htons(_pconfig->GetICPPort())); -} - -int -ParentSiblingPeer::GetProxyPort() -{ - return _pconfig->GetProxyPort(); -} - -int -ParentSiblingPeer::GetICPPort() -{ - return _pconfig->GetICPPort(); -} - -sockaddr * -ParentSiblingPeer::GetIP() -{ - // The real data is in _pconfig, but I don't think ever changes so - // it should be OK to have set this in the constructor. - return &_ip.sa; -} - -Action * -ParentSiblingPeer::SendMsg_re(Continuation *cont, void *token, struct msghdr *msg, sockaddr const *to) -{ - // Note: All sends are funneled through the local peer UDP socket. - - Peer *lp = _ICPpr->GetLocalPeer(); - - if (to) { - // Send to specified host - Peer *p = _ICPpr->FindPeer(IpAddr(to), ntohs(ats_ip_port_cast(to))); - ink_assert(p); - - msg->msg_name = &p->GetSendChan()->addr; - msg->msg_namelen = ats_ip_size(&p->GetSendChan()->addr); - Action *a = udpNet.sendmsg_re(cont, token, lp->GetSendFD(), msg); - return a; - } else { - // Send to default host - msg->msg_name = &_chan.addr; - msg->msg_namelen = ats_ip_size(&_chan.addr.sa); - Action *a = udpNet.sendmsg_re(cont, token, lp->GetSendFD(), msg); - return a; - } -} - -Action * -ParentSiblingPeer::RecvFrom_re(Continuation *cont, void *token, IOBufferBlock *bufblock, int size, struct sockaddr *from, - socklen_t *fromlen) -{ - // Note: All receives are funneled through the local peer UDP socket. - - Peer *lp = _ICPpr->GetLocalPeer(); - Action *a = udpNet.recvfrom_re(cont, token, lp->GetRecvFD(), from, fromlen, bufblock, size, true, 0); - return a; -} - -int -ParentSiblingPeer::GetRecvFD() -{ - return _chan.fd; -} - -int -ParentSiblingPeer::GetSendFD() -{ - return _chan.fd; -} - -int -ParentSiblingPeer::ExpectedReplies(BitMap *expected_replies_list) -{ - if (((_state & PEER_UP) == 0) || ((_stats.total_sent - _stats.total_received) > Peer::OFFLINE_THRESHOLD)) { - if (_state & PEER_UP) { - ip_port_text_buffer ipb; - _state &= ~PEER_UP; - Debug("icp", "Peer [%s] marked offline", ats_ip_nptop(this->GetIP(), ipb, sizeof(ipb))); - } - // - // We will continue to send messages, but will not wait for a reply - // until we receive a response. - // - return 0; - } else { - expected_replies_list->SetBit(this->GetPeerID()); - return 1; - } -} - -int -ParentSiblingPeer::ValidSender(sockaddr *fr) -{ - if (_type == PEER_LOCAL) { - // - // We are currently funneling all unicast receives - // through the local peer UDP socket. As long as - // the sender is known within the ICP configuration, - // consider it valid. - // - Peer *p = _ICPpr->FindPeer(fr); - if (p) { - return 1; // Valid sender - } else { - return 0; // Invalid sender - } - - } else { - // Make sure the sockaddr_in corresponds to this peer - // Need to update once we have support for comparing address - // and port in a socakddr. - if (ats_ip_addr_eq(this->GetIP(), fr) && (ats_ip_port_cast(this->GetIP()) == ats_ip_port_cast(fr))) { - return 1; // Sender is this peer - } else { - return 0; // Sender is not this peer - } - } -} - -void -ParentSiblingPeer::LogSendMsg(ICPMsg_t *m, sockaddr const * /* sa ATS_UNUSED */) -{ - // Note: ICPMsg_t (m) is in network byte order - - // Note numerous stats on a per peer basis - _stats.last_send = Thread::get_hrtime(); - _stats.sent[m->h.opcode]++; - _stats.total_sent++; -} - -int -ParentSiblingPeer::ExtToIntRecvSockAddr(sockaddr const *in, sockaddr *out) -{ - Peer *p = _ICPpr->FindPeer(IpAddr(in)); - if (p && (p->GetType() != PEER_LOCAL)) { - // Map from received (ip, port) to defined (ip, port). - ats_ip_copy(out, p->GetIP()); - return 1; - } else { - return 0; - } -} - -//----------------------------------------------------------- -// Class MultiCastPeer (derived from Peer) member functions -// ICP object describing MultiCast Peers. -//----------------------------------------------------------- -MultiCastPeer::MultiCastPeer(IpAddr const &addr, uint16_t mc_port, int ttl, ICPProcessor *icpPr) - : Peer(PEER_MULTICAST, icpPr), _mc_ttl(ttl) -{ - ats_ip_set(&_mc_ip.sa, addr, htons(mc_port)); - memset(&this->_mc, 0, sizeof(this->_mc)); -} - -int -MultiCastPeer::GetTTL() -{ - return _mc_ttl; -} - -sockaddr * -MultiCastPeer::GetIP() -{ - return &_mc_ip.sa; -} - -Action * -MultiCastPeer::SendMsg_re(Continuation *cont, void *token, struct msghdr *msg, sockaddr const *to) -{ - Action *a; - - if (to) { - // Send to MultiCast group member (UniCast) - Peer *p = FindMultiCastChild(IpAddr(to), ats_ip_port_host_order(to)); - ink_assert(p); - a = ((ParentSiblingPeer *)p)->SendMsg_re(cont, token, msg, nullptr); - } else { - // Send to MultiCast group - msg->msg_name = (caddr_t)&_send_chan.addr; - msg->msg_namelen = sizeof(_send_chan.addr); - a = udpNet.sendmsg_re(cont, token, _send_chan.fd, msg); - } - return a; -} - -Action * -MultiCastPeer::RecvFrom_re(Continuation *cont, void *token, IOBufferBlock * /* bufblock ATS_UNUSED */, int len, - struct sockaddr *from, socklen_t *fromlen) -{ - Action *a = udpNet.recvfrom_re(cont, token, _recv_chan.fd, from, fromlen, buf.get(), len, true, 0); - return a; -} - -int -MultiCastPeer::GetRecvFD() -{ - return _recv_chan.fd; -} - -int -MultiCastPeer::GetSendFD() -{ - return _send_chan.fd; -} - -int -MultiCastPeer::ExpectedReplies(BitMap *expected_replies_list) -{ - // TBD: Expected replies should be calculated as a running average - // from replies returned from a periodic inquiry message. - - int replies = 0; - ParentSiblingPeer *p = (ParentSiblingPeer *)this->_next; - while (p) { - replies += p->ExpectedReplies(expected_replies_list); - p = (ParentSiblingPeer *)p->GetNext(); - } - return replies; -} - -int -MultiCastPeer::ValidSender(sockaddr *sa) -{ - // TBD: Use hash function - // Make sure sockaddr_in corresponds to a defined peer in the - // MultiCast group. - Peer *P = _next; - while (P) { - if (ats_ip_addr_eq(P->GetIP(), sa) && (ats_ip_port_cast(P->GetIP()) == ats_ip_port_cast(sa))) { - return 1; - } else { - P = P->GetNext(); - } - } - return 0; -} - -void -MultiCastPeer::LogSendMsg(ICPMsg_t *m, sockaddr const *sa) -{ - // Note: ICPMsg_t (m) is in network byte order - if (sa) { - // UniCast send on MultiCast interface, only update stats for - // target Peer. - // - Peer *p; - p = FindMultiCastChild(IpAddr(sa), ats_ip_port_host_order(sa)); - if (p) { - ((ParentSiblingPeer *)p)->LogSendMsg(m, sa); - } - - } else { - // Note numerous stats on MultiCast peer and each member peer - _stats.last_send = Thread::get_hrtime(); - _stats.sent[m->h.opcode]++; - _stats.total_sent++; - - Peer *p = _next; - while (p) { - ((ParentSiblingPeer *)p)->LogSendMsg(m, sa); - p = p->GetNext(); - } - } -} - -int -MultiCastPeer::IsOnline() -{ - return (_ICPpr->GetConfig()->globalConfig()->ICPmulticastConfigured()); -} - -int -MultiCastPeer::AddMultiCastChild(Peer *P) -{ - // Add (Peer *) to the given MultiCast structure. - // Make sure child (ip,port) is unique. - sockaddr const *ip = P->GetIP(); - if (FindMultiCastChild(IpAddr(ip), ats_ip_port_host_order(ip))) { - ip_text_buffer x; - Warning("bad icp.config, multiple multicast child definitions for ip=%s", ats_ip_ntop(ip, x, sizeof(x))); - return 0; // Not added, already exists - } else { - P->SetNext(this->_next); - this->_next = P; - ++_mc.defined_members; - return 1; // Added - } -} - -Peer * -MultiCastPeer::FindMultiCastChild(IpAddr const &addr, uint16_t port) -{ - // Locate child (Peer *) with the given (ip,port). This is split out - // rather than using a sockaddr so we can indicate the port is to not - // be checked (@a port == 0). - Peer *curP = this->_next; - while (curP) { - sockaddr const *peer_ip = curP->GetIP(); - if (addr == peer_ip && (!port || port == ats_ip_port_host_order(peer_ip))) { - return curP; - } else { - curP = curP->GetNext(); - } - } - return nullptr; -} - -//------------------------------------------------------------------------- -// Class PeriodicCont member functions (abstract base class) -// Look for TS ICP configuration changes by periodically looking. -//------------------------------------------------------------------------- -typedef int (ICPPeriodicCont::*ICPPeriodicContHandler)(int, void *); -PeriodicCont::PeriodicCont(ICPProcessor *icpP) : Continuation(nullptr), _ICPpr(icpP) -{ - mutex = new_ProxyMutex(); -} - -PeriodicCont::~PeriodicCont() -{ - mutex = nullptr; -} - -//----------------------------------------- -// Class ICPPeriodicCont member functions -//----------------------------------------- -ICPPeriodicCont::ICPPeriodicCont(ICPProcessor *icpP) - : PeriodicCont(icpP), _last_icp_config_callouts(0), _global_config_changed(0), _peer_config_changed(0) -{ -} - -int -ICPPeriodicCont::PeriodicEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) -{ - int do_reconfig = 0; - ICPConfiguration *C = _ICPpr->GetConfig(); - - if (C->GlobalConfigChange()) { - do_reconfig = 1; - } - - int configcallouts = C->ICPConfigCallouts(); - if (_last_icp_config_callouts != configcallouts) { - // We have a "icp.config" change callout which we - // have not processed. - _last_icp_config_callouts = configcallouts; - do_reconfig = 1; - } - - if (do_reconfig) { - // - // We have a configuration change, create worker continuation. - // - ICPPeriodicCont *rc = new ICPPeriodicCont(_ICPpr); - SET_CONTINUATION_HANDLER(rc, (ICPPeriodicContHandler)&ICPPeriodicCont::DoReconfigAction); - eventProcessor.schedule_imm(rc); - } - return EVENT_CONT; -} - -int -ICPPeriodicCont::DoReconfigAction(int event, Event *e) -{ - //************************************************************ - // Initiate reconfiguration action if any global or peer - // configuration changes have occured. - //************************************************************ - ICPConfiguration *C = _ICPpr->GetConfig(); - - for (;;) { - switch (event) { - case EVENT_IMMEDIATE: - case EVENT_INTERVAL: { - ink_assert(!_global_config_changed && !_peer_config_changed); - if (C->Lock()) { - ICP_INCREMENT_DYN_STAT(reconfig_polls_stat); - if (C->GlobalConfigChange()) { - _global_config_changed = 1; - } - // - // TS Configuration management makes callouts whenever changes - // are made to "icp.config", which describes the ICP peer - // configuration. - // - if (C->PeerConfigChange()) { - _peer_config_changed = 1; - } - if (_global_config_changed || _peer_config_changed) { - // - // Start the reconfiguration sequence. - // - ICP_INCREMENT_DYN_STAT(reconfig_events_stat); - ICPProcessor::ReconfigState_t NextState; - - NextState = _ICPpr->ReconfigureStateMachine(ICPProcessor::RC_RECONFIG, _global_config_changed, _peer_config_changed); - if (NextState == ICPProcessor::RC_DONE) { - // Completed all reconfiguration actions. - // ReconfigureStateMachine() has invoked C->Unlock() - delete this; - return EVENT_DONE; - } else { - // Delay and restart update. - _global_config_changed = 0; - _peer_config_changed = 0; - C->Unlock(); - e->schedule_in(HRTIME_MSECONDS(RETRY_INTERVAL_MSECS)); - return EVENT_CONT; - } - - } else { - // No configuration changes detected. - C->Unlock(); - } - - } else { - // Missed lock, retry later - e->schedule_in(HRTIME_MSECONDS(RETRY_INTERVAL_MSECS)); - return EVENT_CONT; - } - delete this; - return EVENT_DONE; - } - default: { - ink_release_assert(!"ICPPeriodicCont::DoReconfigAction() bad event"); - } - } // End of switch - } // End of for - - return EVENT_DONE; -} - -//---------------------------------------------------------------- -// Class ICPlog member functions -// Basic accessor object used by the new logging subsystem -// for squid access log data for ICP queries. -//---------------------------------------------------------------- -ink_hrtime -ICPlog::GetElapsedTime() -{ - return (Thread::get_hrtime() - _s->_start_time); -} - -sockaddr const * -ICPlog::GetClientIP() -{ - return &_s->_sender.sa; -} - -in_port_t -ICPlog::GetClientPort() -{ - return _s->_sender.port(); -} - -SquidLogCode -ICPlog::GetAction() -{ - if (_s->_queryResult == CACHE_EVENT_LOOKUP) { - return SQUID_LOG_UDP_HIT; - } else { - return SQUID_LOG_UDP_MISS; - } -} - -const char * -ICPlog::GetCode() -{ - static const char *const ICPCodeStr = "000"; - return ICPCodeStr; -} - -int -ICPlog::GetSize() -{ - return ntohs(_s->_rICPmsg->h.msglen); -} - -const char * -ICPlog::GetMethod() -{ - return HTTP_METHOD_ICP_QUERY; -} - -const char * -ICPlog::GetURI() -{ - return (const char *)_s->_rICPmsg->un.query.URL; -} - -const char * -ICPlog::GetIdent() -{ - static const char *const ICPidentStr = ""; - return ICPidentStr; -} - -SquidHierarchyCode -ICPlog::GetHierarchy() -{ - return SQUID_HIER_NONE; -} - -const char * -ICPlog::GetFromHost() -{ - static const char *const FromHostStr = ""; - return FromHostStr; -} - -const char * -ICPlog::GetContentType() -{ - static const char *const ICPcontentTypeStr = ""; - return ICPcontentTypeStr; -} - -//***************************************************************************** -// ICP Debug support. -//***************************************************************************** -// -static const char *ICPstatNames[] = {"icp_stat_def", - "config_mgmt_callouts_stat", - "reconfig_polls_stat", - "reconfig_events_stat", - "invalid_poll_data_stat", - "no_data_read_stat", - "short_read_stat", - "invalid_sender_stat", - "read_not_v2_icp_stat", - "icp_remote_query_requests_stat", - "icp_remote_responses_stat", - "icp_cache_lookup_success_stat", - "icp_cache_lookup_fail_stat", - "query_response_write_stat", - "query_response_partial_write_stat", - "no_icp_request_for_response_stat", - "icp_response_request_nolock_stat", - "icp_start_icpoff_stat", - "send_query_partial_write_stat", - "icp_queries_no_expected_replies_stat", - "icp_query_hits_stat", - "icp_query_misses_stat", - "invalid_icp_query_response_stat", - "icp_query_requests_stat", - "total_icp_response_time_stat", - "total_udp_send_queries_stat", - "total_icp_request_time_stat", - "icp_total_reloads", - "icp_pending_reloads", - "icp_reload_start_aborts", - "icp_reload_connect_aborts", - "icp_reload_read_aborts", - "icp_reload_write_aborts", - "icp_reload_successes", - "icp_stat_count", - ""}; - -void -dumpICPstatEntry(int i, const char *name) -{ - int l = strlen(name); - int64_t sval, cval; - - RecRawStat *p = RecGetGlobalRawStatPtr(icp_rsb, i); - sval = p->sum; - cval = p->count; - - printf("%-32s %12" PRId64 " %16" PRId64 " %17.4f\n", &name[l > 31 ? l - 31 : 0], cval, sval, - cval ? (((double)sval) / ((double)cval)) : 0.0); -} - -void -dumpICPstats() -{ - printf("\n"); - int i; - for (i = 0; i < icp_stat_count; ++i) { - dumpICPstatEntry(i, ICPstatNames[i]); - } -} - -void -ICPProcessor::DumpICPConfig() -{ - Peer *P; - PeerType_t type; - int id; - ip_port_text_buffer ipb; - - Debug("icp", "On=%d, MultiCast=%d, Timeout=%d LocalCacheLookup=%d", GetConfig()->globalConfig()->ICPconfigured(), - GetConfig()->globalConfig()->ICPmulticastConfigured(), GetConfig()->globalConfig()->ICPqueryTimeout(), - GetConfig()->globalConfig()->ICPLocalCacheLookup()); - Debug("icp", "StaleLookup=%d, ReplyToUnknowPeer=%d, DefaultReplyPort=%d", GetConfig()->globalConfig()->ICPStaleLookup(), - GetConfig()->globalConfig()->ICPReplyToUnknownPeer(), GetConfig()->globalConfig()->ICPDefaultReplyPort()); - - for (int i = 0; i < (_nPeerList + 1); i++) { - P = IdToPeer(i); - id = P->GetPeerID(); - type = P->GetType(); - const char *str_type; - - switch (type) { - case PEER_PARENT: { - str_type = "P"; - break; - } - case PEER_SIBLING: { - str_type = "S"; - break; - } - case PEER_LOCAL: { - str_type = "L"; - break; - } - case PEER_MULTICAST: { - str_type = "M"; - break; - } - default: { - str_type = "N"; - break; - } - } // End of switch - - if (*str_type == 'M') { - Debug("icp", "[%d]: Type=%s IP=%s", id, str_type, ats_ip_nptop(P->GetIP(), ipb, sizeof(ipb))); - } else { - ParentSiblingPeer *Pps = static_cast(P); - Debug("icp", "[%d]: Type=%s IP=%s PPort=%d Host=%s", id, str_type, ats_ip_nptop(P->GetIP(), ipb, sizeof(ipb)), - Pps->GetConfig()->GetProxyPort(), Pps->GetConfig()->GetHostname()); - - Debug("icp", "[%d]: MC ON=%d MC_IP=%s MC_TTL=%d", id, Pps->GetConfig()->MultiCastMember(), - Pps->GetConfig()->GetMultiCastIPAddr().toString(ipb, sizeof(ipb)), Pps->GetConfig()->GetMultiCastTTL()); - } - } -} - -//***************************************************************************** - -// End of ICPConfig.cc diff --git a/proxy/ICPProcessor.cc b/proxy/ICPProcessor.cc deleted file mode 100644 index 2cd53a15413..00000000000 --- a/proxy/ICPProcessor.cc +++ /dev/null @@ -1,58 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/**************************************************************************** - - ICPProcessor.cc - - -****************************************************************************/ - -#include "ICP.h" -#include "ICPProcessor.h" - -//************************************************************** -// Wrapper Class to hide the true internals of ICPProcessor. -// Used only for external access. -//************************************************************** -ICPProcessorExt::ICPProcessorExt(ICPProcessor *icpPr) : _ICPpr(icpPr) -{ -} - -ICPProcessorExt::~ICPProcessorExt() -{ -} - -void -ICPProcessorExt::start() -{ - _ICPpr->start(); -} - -Action * -ICPProcessorExt::ICPQuery(Continuation *c, URL *url) -{ - return _ICPpr->ICPQuery(c, url); -} - -// End of ICPProcessor.cc diff --git a/proxy/ICPProcessor.h b/proxy/ICPProcessor.h deleted file mode 100644 index 1039ddeb0d7..00000000000 --- a/proxy/ICPProcessor.h +++ /dev/null @@ -1,79 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/**************************************************************************** - - ICPProcessor.h - - -****************************************************************************/ - -#ifndef _ICPProcessor_h_ -#define _ICPProcessor_h_ -#include "P_EventSystem.h" -#include "URL.h" -#include "ICPevents.h" - -//###################################################### -// State definitions for "proxy.config.icp.enabled" -//###################################################### -#define ICP_MODE_OFF 0 -#define ICP_MODE_RECEIVE_ONLY 1 -#define ICP_MODE_SEND_RECEIVE 2 - -extern void initialize_thread_for_icp(EThread *e); -class ICPProcessor; - -//*************************************************************************** -// External Interface to ICP -// Calling Sequence: -// ================= -// void icpProcessor.start() -// Returns: -// None. -// -// Action * icpProcessor.ICPQuery(Continuation *, URL *) -// Returns: -// Invokes continuation handleEvent(ICPreturn_t, struct sockaddr_in *) -// where ICPreturn_t is ICP_LOOKUP_FOUND or ICP_LOOKUP_FAILED and -// struct sockaddr_in (ip,port) is host containing URL data. -//*************************************************************************** -class ICPProcessorExt -{ -public: - ICPProcessorExt(ICPProcessor *); - ~ICPProcessorExt(); - - // Exported interfaces - void start(); - Action *ICPQuery(Continuation *, URL *); - -private: - ICPProcessor *_ICPpr; -}; - -extern ICPProcessorExt icpProcessor; - -// End of ICPProcessor.h - -#endif // _ICPProcessor_h_ diff --git a/proxy/ICPStats.cc b/proxy/ICPStats.cc deleted file mode 100644 index f4224c1e87a..00000000000 --- a/proxy/ICPStats.cc +++ /dev/null @@ -1,98 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/**************************************************************************** - - ICPStats.cc - - -****************************************************************************/ - -#include "Main.h" -#include "P_EventSystem.h" -#include "P_Cache.h" -#include "P_RecProcess.h" -#include "ICP.h" - -struct RecRawStatBlock *icp_rsb; - -void -ICPProcessor::InitICPStatCallbacks() -{ - icp_rsb = RecAllocateRawStatBlock((int)icp_stat_count); - - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.config_mgmt_callouts", RECD_INT, RECP_PERSISTENT, - (int)config_mgmt_callouts_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.reconfig_polls", RECD_INT, RECP_PERSISTENT, (int)reconfig_polls_stat, - RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.reconfig_events", RECD_INT, RECP_PERSISTENT, - (int)reconfig_events_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.invalid_poll_data", RECD_INT, RECP_PERSISTENT, - (int)invalid_poll_data_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.no_data_read", RECD_INT, RECP_PERSISTENT, (int)no_data_read_stat, - RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.short_read", RECD_INT, RECP_PERSISTENT, (int)short_read_stat, - RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.invalid_sender", RECD_INT, RECP_PERSISTENT, (int)invalid_sender_stat, - RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.read_not_v2_icp", RECD_INT, RECP_PERSISTENT, - (int)read_not_v2_icp_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.icp_remote_query_requests", RECD_INT, RECP_PERSISTENT, - (int)icp_remote_query_requests_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.icp_remote_responses", RECD_INT, RECP_PERSISTENT, - (int)icp_remote_responses_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.cache_lookup_success", RECD_INT, RECP_PERSISTENT, - (int)icp_cache_lookup_success_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.cache_lookup_fail", RECD_INT, RECP_PERSISTENT, - (int)icp_cache_lookup_fail_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.query_response_write", RECD_INT, RECP_PERSISTENT, - (int)query_response_write_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.query_response_partial_write", RECD_INT, RECP_PERSISTENT, - (int)query_response_partial_write_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.no_icp_request_for_response", RECD_INT, RECP_PERSISTENT, - (int)no_icp_request_for_response_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.icp_response_request_nolock", RECD_INT, RECP_PERSISTENT, - (int)icp_response_request_nolock_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.icp_start_icpoff", RECD_INT, RECP_PERSISTENT, - (int)icp_start_icpoff_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.send_query_partial_write", RECD_INT, RECP_PERSISTENT, - (int)send_query_partial_write_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.icp_queries_no_expected_replies", RECD_INT, RECP_PERSISTENT, - (int)icp_queries_no_expected_replies_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.icp_query_hits", RECD_INT, RECP_PERSISTENT, (int)icp_query_hits_stat, - RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.icp_query_misses", RECD_INT, RECP_PERSISTENT, - (int)icp_query_misses_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.invalid_icp_query_response", RECD_INT, RECP_PERSISTENT, - (int)invalid_icp_query_response_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.icp_query_requests", RECD_INT, RECP_PERSISTENT, - (int)icp_query_requests_stat, RecRawStatSyncCount); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.total_icp_response_time", RECD_FLOAT, RECP_PERSISTENT, - (int)total_icp_response_time_stat, RecRawStatSyncMHrTimeAvg); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.total_udp_send_queries", RECD_INT, RECP_PERSISTENT, - (int)total_udp_send_queries_stat, RecRawStatSyncSum); - RecRegisterRawStat(icp_rsb, RECT_PROCESS, "proxy.process.icp.total_icp_request_time", RECD_FLOAT, RECP_PERSISTENT, - (int)total_icp_request_time_stat, RecRawStatSyncMHrTimeAvg); -} - -// End of ICPStats.cc diff --git a/proxy/ICPevents.h b/proxy/ICPevents.h deleted file mode 100644 index b4667f50060..00000000000 --- a/proxy/ICPevents.h +++ /dev/null @@ -1,42 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#ifndef _ICPEvents_h_ -#define _ICPEvents_h_ - -#include "I_EventSystem.h" - -/** Events specific to ICP. */ -typedef enum { - ICP_LOOKUP_FOUND = ICP_EVENT_EVENTS_START + 0, - ICP_LOOKUP_FAILED = ICP_EVENT_EVENTS_START + 1, - ICP_RESPONSE_MESSAGE = ICP_EVENT_EVENTS_START + 2, - - ///////////////////////////////////////////////////// - // Events specific to object freshness check - ///////////////////////////////////////////////////// - ICP_STALE_OBJECT = ICP_EVENT_EVENTS_START + 10, - ICP_FRESH_OBJECT = ICP_EVENT_EVENTS_START + 11 -} ICPreturn_t; - -#endif // _ICPevents_h_ diff --git a/proxy/ICPlog.h b/proxy/ICPlog.h deleted file mode 100644 index cb744491c9f..00000000000 --- a/proxy/ICPlog.h +++ /dev/null @@ -1,65 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/**************************************************************************** - - ICPlog.h - - -****************************************************************************/ - -#ifndef _ICPlog_h_ -#define _ICPlog_h_ - -#include "HTTP.h" - -// -// Logging object which encapsulates ICP query info required -// by the new logging subsystem to produce squid access log -// data for ICP queries. -// -class ICPlog -{ -public: - inline ICPlog(ICPPeerReadCont::PeerReadData *s) { _s = s; } - ~ICPlog() {} - ink_hrtime GetElapsedTime(); - sockaddr const *GetClientIP(); - in_port_t GetClientPort(); - SquidLogCode GetAction(); - const char *GetCode(); - int GetSize(); - const char *GetMethod(); - const char *GetURI(); - const char *GetIdent(); - SquidHierarchyCode GetHierarchy(); - const char *GetFromHost(); - const char *GetContentType(); - -private: - ICPPeerReadCont::PeerReadData *_s; -}; - -// End of ICPlog.h - -#endif // _ICPlog_h_ diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index 86468f8c37b..ac0c818db51 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -4532,21 +4532,6 @@ TSLifecycleHookAdd(TSLifecycleHookID id, TSCont contp) lifecycle_hooks->append(id, (INKContInternal *)contp); } -void -TSHttpIcpDynamicSet(int value) -{ - int32_t old_value, new_value; - - new_value = (value == 0) ? 0 : 1; - old_value = icp_dynamic_enabled; - while (old_value != new_value) { - if (ink_atomic_cas(&icp_dynamic_enabled, old_value, new_value)) { - break; - } - old_value = icp_dynamic_enabled; - } -} - /* HTTP sessions */ void TSHttpSsnHookAdd(TSHttpSsn ssnp, TSHttpHookID id, TSCont contp) diff --git a/proxy/Main.cc b/proxy/Main.cc index acd14a5acc7..9c7548cfcb6 100644 --- a/proxy/Main.cc +++ b/proxy/Main.cc @@ -76,7 +76,6 @@ extern "C" int plock(int); #include "HttpProxyServerMain.h" #include "HttpBodyFactory.h" #include "logging/Log.h" -#include "ICPProcessor.h" #include "CacheControl.h" #include "IPAllow.h" #include "ParentSelection.h" diff --git a/proxy/Makefile.am b/proxy/Makefile.am index a46e19dc467..0b5e394cc06 100644 --- a/proxy/Makefile.am +++ b/proxy/Makefile.am @@ -136,14 +136,6 @@ traffic_server_SOURCES = \ Crash.cc \ EventName.cc \ FetchSM.cc \ - ICP.cc \ - ICP.h \ - ICPConfig.cc \ - ICPProcessor.cc \ - ICPProcessor.h \ - ICPStats.cc \ - ICPevents.h \ - ICPlog.h \ IPAllow.cc \ IPAllow.h \ InkAPI.cc \ diff --git a/proxy/config/icp.config.default b/proxy/config/icp.config.default deleted file mode 100644 index 7fa54a41dbb..00000000000 --- a/proxy/config/icp.config.default +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################### -# -# ICP Configuration -- Defines ICP parent/sibling configuration -# -# Documentation: -# https://docs.trafficserver.apache.org/en/latest/admin-guide/files/icp.config.en.html -# -# Each line is formatted with a separator between fields. This can be -# a space, ':', ';', ',', or '|' but must be consistent for the -# entire line. There must be a terminating separator as the last -# character. The separator for the line is determined by this -# character. Note: if you use an IPv6 address, you must *not* use -# colon as a field separator. -# -# - hostname (string) -- Identifier for entry -# - host_ip_str (string) -- decimal dot notation -# - ctype (int) -- 1=Parent, 2=Sibling -# - proxy_port (int) -- TCP Port # -# - icp_port (int) -- UDP Port # -# - multicast_member -- 0=No 1=Yes -# - multicast_ip_str (string) -- decimal dot notation for IPv4 -# 224.0.0.0 - 239.255.255.255 -# colon notation for IPv6 -# FF05::2 -# - multicast_ttl (int) -- (1 - 2; default 1) -# -# :::::::: -# -# Example #1 (1 parent and 2 siblings): -# ============================================================== -# host1:209.1.33.10:1:8080:3130:0:0.0.0.0:1: -# host2;209.1.33.11;2;8080;3130;0;0.0.0.0;1; -# host3|fe80::208:54ff:fe47:d94d|2|8080|3130|0|::|1| -# -# -# Example #2 (1 parent and 1 sibling using MultiCast): -# ============================================================================ -# host1 209.1.33.10 1 8080 3130 1 239.128.16.128 1 -# host2 209.1.33.11 2:8080:3130 1 239.128.16.128 1 -# Note: trailing space in previous lines. -# -############################################################################### diff --git a/proxy/config/ip_allow.config.default b/proxy/config/ip_allow.config.default index 51e8904138a..226bcdb9953 100644 --- a/proxy/config/ip_allow.config.default +++ b/proxy/config/ip_allow.config.default @@ -12,7 +12,7 @@ # Multiple method keywords can be specified (method=GET method=HEAD), or # multiple methods can be separated by an '|' (method=GET|HEAD). The method # keyword is optional and it is defaulted to ALL. -# Available methods: ALL, GET, CONNECT, DELETE, HEAD, ICP_QUERY, OPTIONS, +# Available methods: ALL, GET, CONNECT, DELETE, HEAD, OPTIONS, # POST, PURGE, PUT, TRACE, PUSH # # Rules are applied in the order listed starting from the top. diff --git a/proxy/config/logging.config.default b/proxy/config/logging.config.default index af8d6248d85..e0e212e45d7 100644 --- a/proxy/config/logging.config.default +++ b/proxy/config/logging.config.default @@ -79,7 +79,6 @@ -- the specified size. -- -- log.protocol.http (number) --- log.protocol.icp (number) -- Server protocol constants for constructing % filters. -- Removed parameters. @@ -98,8 +97,7 @@ -- parameter can be implemented with a filter on the % (log -- entry type) log field, eg. -- --- all = filter.accept(string.format('%% CONTAIN %d,%d', log.protocol.http, log.protocol.icp)) --- icp_only = filter.accept(string.format('%% CONTAIN %d', log.protocol.icp)) +-- all = filter.accept(string.format('%% CONTAIN %d', log.protocol.http)) -- http_only = filter.accept(string.format('%% CONTAIN %d', log.protocol.http)) -- -- ServerHosts: diff --git a/proxy/config/remap.config.default b/proxy/config/remap.config.default index 1c21331c458..bfe1435c96f 100644 --- a/proxy/config/remap.config.default +++ b/proxy/config/remap.config.default @@ -143,7 +143,7 @@ # # @action=allow|deny # @src_ip=IP-address -# @method=HTTP method string (CONNECT|DELETE|GET|HEAD|ICP_QUERY|OPTIONS|POST|PURGE|PUT|TRACE|PUSH) +# @method=HTTP method string (CONNECT|DELETE|GET|HEAD|OPTIONS|POST|PURGE|PUT|TRACE|PUSH) # @plugin= # @pparam= # diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc index 3be7064da90..73b4ab008d1 100644 --- a/proxy/hdrs/HTTP.cc +++ b/proxy/hdrs/HTTP.cc @@ -54,7 +54,6 @@ const char *HTTP_METHOD_CONNECT; const char *HTTP_METHOD_DELETE; const char *HTTP_METHOD_GET; const char *HTTP_METHOD_HEAD; -const char *HTTP_METHOD_ICP_QUERY; const char *HTTP_METHOD_OPTIONS; const char *HTTP_METHOD_POST; const char *HTTP_METHOD_PURGE; @@ -66,7 +65,6 @@ int HTTP_WKSIDX_CONNECT; int HTTP_WKSIDX_DELETE; int HTTP_WKSIDX_GET; int HTTP_WKSIDX_HEAD; -int HTTP_WKSIDX_ICP_QUERY; int HTTP_WKSIDX_OPTIONS; int HTTP_WKSIDX_POST; int HTTP_WKSIDX_PURGE; @@ -79,7 +77,6 @@ int HTTP_LEN_CONNECT; int HTTP_LEN_DELETE; int HTTP_LEN_GET; int HTTP_LEN_HEAD; -int HTTP_LEN_ICP_QUERY; int HTTP_LEN_OPTIONS; int HTTP_LEN_POST; int HTTP_LEN_PURGE; @@ -187,17 +184,16 @@ http_init() mime_init(); url_init(); - HTTP_METHOD_CONNECT = hdrtoken_string_to_wks("CONNECT"); - HTTP_METHOD_DELETE = hdrtoken_string_to_wks("DELETE"); - HTTP_METHOD_GET = hdrtoken_string_to_wks("GET"); - HTTP_METHOD_HEAD = hdrtoken_string_to_wks("HEAD"); - HTTP_METHOD_ICP_QUERY = hdrtoken_string_to_wks("ICP_QUERY"); - HTTP_METHOD_OPTIONS = hdrtoken_string_to_wks("OPTIONS"); - HTTP_METHOD_POST = hdrtoken_string_to_wks("POST"); - HTTP_METHOD_PURGE = hdrtoken_string_to_wks("PURGE"); - HTTP_METHOD_PUT = hdrtoken_string_to_wks("PUT"); - HTTP_METHOD_TRACE = hdrtoken_string_to_wks("TRACE"); - HTTP_METHOD_PUSH = hdrtoken_string_to_wks("PUSH"); + HTTP_METHOD_CONNECT = hdrtoken_string_to_wks("CONNECT"); + HTTP_METHOD_DELETE = hdrtoken_string_to_wks("DELETE"); + HTTP_METHOD_GET = hdrtoken_string_to_wks("GET"); + HTTP_METHOD_HEAD = hdrtoken_string_to_wks("HEAD"); + HTTP_METHOD_OPTIONS = hdrtoken_string_to_wks("OPTIONS"); + HTTP_METHOD_POST = hdrtoken_string_to_wks("POST"); + HTTP_METHOD_PURGE = hdrtoken_string_to_wks("PURGE"); + HTTP_METHOD_PUT = hdrtoken_string_to_wks("PUT"); + HTTP_METHOD_TRACE = hdrtoken_string_to_wks("TRACE"); + HTTP_METHOD_PUSH = hdrtoken_string_to_wks("PUSH"); // HTTP methods index calculation. Don't forget to count them! // Don't change the order of calculation! Each index has related bitmask (see http quick filter) @@ -209,8 +205,6 @@ http_init() HTTP_WKSIDX_METHODS_CNT++; HTTP_WKSIDX_HEAD = hdrtoken_wks_to_index(HTTP_METHOD_HEAD); HTTP_WKSIDX_METHODS_CNT++; - HTTP_WKSIDX_ICP_QUERY = hdrtoken_wks_to_index(HTTP_METHOD_ICP_QUERY); - HTTP_WKSIDX_METHODS_CNT++; HTTP_WKSIDX_OPTIONS = hdrtoken_wks_to_index(HTTP_METHOD_OPTIONS); HTTP_WKSIDX_METHODS_CNT++; HTTP_WKSIDX_POST = hdrtoken_wks_to_index(HTTP_METHOD_POST); @@ -224,17 +218,16 @@ http_init() HTTP_WKSIDX_PUSH = hdrtoken_wks_to_index(HTTP_METHOD_PUSH); HTTP_WKSIDX_METHODS_CNT++; - HTTP_LEN_CONNECT = hdrtoken_wks_to_length(HTTP_METHOD_CONNECT); - HTTP_LEN_DELETE = hdrtoken_wks_to_length(HTTP_METHOD_DELETE); - HTTP_LEN_GET = hdrtoken_wks_to_length(HTTP_METHOD_GET); - HTTP_LEN_HEAD = hdrtoken_wks_to_length(HTTP_METHOD_HEAD); - HTTP_LEN_ICP_QUERY = hdrtoken_wks_to_length(HTTP_METHOD_ICP_QUERY); - HTTP_LEN_OPTIONS = hdrtoken_wks_to_length(HTTP_METHOD_OPTIONS); - HTTP_LEN_POST = hdrtoken_wks_to_length(HTTP_METHOD_POST); - HTTP_LEN_PURGE = hdrtoken_wks_to_length(HTTP_METHOD_PURGE); - HTTP_LEN_PUT = hdrtoken_wks_to_length(HTTP_METHOD_PUT); - HTTP_LEN_TRACE = hdrtoken_wks_to_length(HTTP_METHOD_TRACE); - HTTP_LEN_PUSH = hdrtoken_wks_to_length(HTTP_METHOD_PUSH); + HTTP_LEN_CONNECT = hdrtoken_wks_to_length(HTTP_METHOD_CONNECT); + HTTP_LEN_DELETE = hdrtoken_wks_to_length(HTTP_METHOD_DELETE); + HTTP_LEN_GET = hdrtoken_wks_to_length(HTTP_METHOD_GET); + HTTP_LEN_HEAD = hdrtoken_wks_to_length(HTTP_METHOD_HEAD); + HTTP_LEN_OPTIONS = hdrtoken_wks_to_length(HTTP_METHOD_OPTIONS); + HTTP_LEN_POST = hdrtoken_wks_to_length(HTTP_METHOD_POST); + HTTP_LEN_PURGE = hdrtoken_wks_to_length(HTTP_METHOD_PURGE); + HTTP_LEN_PUT = hdrtoken_wks_to_length(HTTP_METHOD_PUT); + HTTP_LEN_TRACE = hdrtoken_wks_to_length(HTTP_METHOD_TRACE); + HTTP_LEN_PUSH = hdrtoken_wks_to_length(HTTP_METHOD_PUSH); HTTP_VALUE_BYTES = hdrtoken_string_to_wks("bytes"); HTTP_VALUE_CHUNKED = hdrtoken_string_to_wks("chunked"); diff --git a/proxy/hdrs/HTTP.h b/proxy/hdrs/HTTP.h index 4e9c1bffb56..6015461e61b 100644 --- a/proxy/hdrs/HTTP.h +++ b/proxy/hdrs/HTTP.h @@ -210,9 +210,7 @@ enum SquidHitMissCode { SQUID_HIT_LEVEL_8 = 'I', SQUID_HIT_LEVEl_9 = 'J', SQUID_MISS_NONE = '1', - SQUID_MISS_ICP_AUTH = '2', SQUID_MISS_HTTP_NON_CACHE = '3', - SQUID_MISS_ICP_STOPLIST = '4', SQUID_MISS_HTTP_NO_DLE = '5', SQUID_MISS_HTTP_NO_LE = '6', SQUID_MISS_HTTP_CONTENT = '7', @@ -324,7 +322,6 @@ extern const char *HTTP_METHOD_CONNECT; extern const char *HTTP_METHOD_DELETE; extern const char *HTTP_METHOD_GET; extern const char *HTTP_METHOD_HEAD; -extern const char *HTTP_METHOD_ICP_QUERY; extern const char *HTTP_METHOD_OPTIONS; extern const char *HTTP_METHOD_POST; extern const char *HTTP_METHOD_PURGE; @@ -336,7 +333,6 @@ extern int HTTP_WKSIDX_CONNECT; extern int HTTP_WKSIDX_DELETE; extern int HTTP_WKSIDX_GET; extern int HTTP_WKSIDX_HEAD; -extern int HTTP_WKSIDX_ICP_QUERY; extern int HTTP_WKSIDX_OPTIONS; extern int HTTP_WKSIDX_POST; extern int HTTP_WKSIDX_PURGE; @@ -349,7 +345,6 @@ extern int HTTP_LEN_CONNECT; extern int HTTP_LEN_DELETE; extern int HTTP_LEN_GET; extern int HTTP_LEN_HEAD; -extern int HTTP_LEN_ICP_QUERY; extern int HTTP_LEN_OPTIONS; extern int HTTP_LEN_POST; extern int HTTP_LEN_PURGE; diff --git a/proxy/hdrs/HdrToken.cc b/proxy/hdrs/HdrToken.cc index 9efbaf2b6c4..a1ba721ff73 100644 --- a/proxy/hdrs/HdrToken.cc +++ b/proxy/hdrs/HdrToken.cc @@ -104,7 +104,8 @@ static const char *_hdrtoken_strs[] = { "rtsp", "mmsu", "mmst", "mms", "wss", "ws", // HTTP methods - "CONNECT", "DELETE", "GET", "POST", "HEAD", "ICP_QUERY", "OPTIONS", "PURGE", "PUT", "TRACE", "PUSH", + // replaced ICP with DNT(DO NOT TRACK is a placeholder and not a method) as it breaks cache compatibility as wksid is stored in cache. + "CONNECT", "DELETE", "GET", "POST", "HEAD", "DNT" , "OPTIONS", "PURGE", "PUT", "TRACE", "PUSH", // Header extensions "X-ID", "X-Forwarded-For", "TE", "Strict-Transport-Security", "100-continue", @@ -136,7 +137,6 @@ static HdrTokenTypeBinding _hdrtoken_strs_type_initializers[] = { {"DELETE", HDRTOKEN_TYPE_METHOD}, {"GET", HDRTOKEN_TYPE_METHOD}, {"HEAD", HDRTOKEN_TYPE_METHOD}, - {"ICP_QUERY", HDRTOKEN_TYPE_METHOD}, {"OPTIONS", HDRTOKEN_TYPE_METHOD}, {"POST", HDRTOKEN_TYPE_METHOD}, {"PURGE", HDRTOKEN_TYPE_METHOD}, @@ -206,6 +206,7 @@ static HdrTokenFieldInfo _hdrtoken_strs_field_initializers[] = { {"Message-ID", MIME_SLOTID_NONE, MIME_PRESENCE_NONE, HTIF_NONE}, {"Newsgroups", MIME_SLOTID_NONE, MIME_PRESENCE_NONE, HTIF_NONE}, {"Organization", MIME_SLOTID_NONE, MIME_PRESENCE_NONE, HTIF_NONE}, + {"DNT", MIME_SLOTID_NONE, MIME_PRESENCE_NONE, HTIF_NONE}, {"Path", MIME_SLOTID_NONE, MIME_PRESENCE_PATH, HTIF_NONE}, {"Pragma", MIME_SLOTID_PRAGMA, MIME_PRESENCE_PRAGMA, (HTIF_COMMAS | HTIF_MULTVALS)}, {"Proxy-Authenticate", MIME_SLOTID_NONE, MIME_PRESENCE_PROXY_AUTHENTICATE, (HTIF_HOPBYHOP | HTIF_PROXYAUTH)}, @@ -349,7 +350,8 @@ static const char *_hdrtoken_commonly_tokenized_strs[] = { "rtsp", "mmsu", "mmst", "mms", "wss", "ws", // HTTP methods - "CONNECT", "DELETE", "GET", "POST", "HEAD", "ICP_QUERY", "OPTIONS", "PURGE", "PUT", "TRACE", "PUSH", + // replaced ICP with DNT(DO NOT TRACK is a placeholder and not a method) as it breaks cache compatibility as wksid is stored in cache. + "CONNECT", "DELETE", "GET", "POST", "HEAD", "DNT", "OPTIONS", "PURGE", "PUT", "TRACE", "PUSH", // Header extensions "X-ID", "X-Forwarded-For", "TE", "Strict-Transport-Security", "100-continue", diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index c28faab514f..5bd2bab7e0e 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -28,7 +28,6 @@ #include "HTTP.h" #include "ProcessManager.h" #include "ProxyConfig.h" -#include "ICPProcessor.h" #include "P_Net.h" #include "P_RecUtils.h" #include @@ -1284,9 +1283,6 @@ HttpConfig::reconfigure() params->enable_http_stats = INT_TO_BOOL(m_master.enable_http_stats); params->oride.normalize_ae_gzip = INT_TO_BOOL(m_master.oride.normalize_ae_gzip); - params->icp_enabled = (m_master.icp_enabled == ICP_MODE_SEND_RECEIVE ? 1 : 0); // INT_TO_BOOL - params->stale_icp_enabled = INT_TO_BOOL(m_master.stale_icp_enabled); - params->oride.cache_heuristic_min_lifetime = m_master.oride.cache_heuristic_min_lifetime; params->oride.cache_heuristic_max_lifetime = m_master.oride.cache_heuristic_max_lifetime; params->oride.cache_heuristic_lm_factor = min(max(m_master.oride.cache_heuristic_lm_factor, 0.0f), 1.0f); diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index cc1b42ccf3f..504ca337365 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -858,9 +858,6 @@ class HttpConfig static HttpConfigParams m_master; }; -// DI's request to disable ICP on the fly -extern volatile int32_t icp_dynamic_enabled; - ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// // @@ -896,8 +893,6 @@ inline HttpConfigParams::HttpConfigParams() use_client_target_addr(0), use_client_source_port(0), enable_http_stats(1), - icp_enabled(0), - stale_icp_enabled(0), cache_post_method(0), push_method_enabled(0), referer_filter_enabled(0), diff --git a/proxy/http/HttpDebugNames.cc b/proxy/http/HttpDebugNames.cc index b1204e6a09a..a85ec276b13 100644 --- a/proxy/http/HttpDebugNames.cc +++ b/proxy/http/HttpDebugNames.cc @@ -26,7 +26,6 @@ #include "StatPages.h" #include "HttpTunnel.h" #include "Transform.h" -#include "ICPevents.h" #include "HttpSM.h" #include "HttpUpdateSM.h" @@ -212,14 +211,6 @@ HttpDebugNames::get_event_name(int event) case HTTP_TUNNEL_EVENT_CONSUMER_DETACH: return ("HTTP_TUNNEL_EVENT_CONSUMER_DETACH"); - ////////////////////////// - // ICP Events - ////////////////////////// - case ICP_LOOKUP_FOUND: - return ("ICP_LOOKUP_FOUND"); - case ICP_LOOKUP_FAILED: - return ("ICP_LOOKUP_FAILED"); - ////////////////////////////// // CongestionControl Events ////////////////////////////// @@ -283,9 +274,6 @@ HttpDebugNames::get_action_name(HttpTransact::StateMachineAction_t e) case HttpTransact::SM_ACTION_DNS_REVERSE_LOOKUP: return ("SM_ACTION_DNS_REVERSE_LOOKUP"); - case HttpTransact::SM_ACTION_ICP_QUERY: - return ("SM_ACTION_ICP_QUERY"); - case HttpTransact::SM_ACTION_CACHE_PREPARE_UPDATE: return ("SM_ACTION_CACHE_PREPARE_UPDATE"); diff --git a/proxy/http/HttpProxyServerMain.cc b/proxy/http/HttpProxyServerMain.cc index 99b0e2cfd5d..7b59eef1077 100644 --- a/proxy/http/HttpProxyServerMain.cc +++ b/proxy/http/HttpProxyServerMain.cc @@ -238,9 +238,6 @@ init_HttpProxyServer(int n_accept_threads) ink_mutex_init(&debug_cs_list_mutex, "HttpCS Debug List"); #endif - // DI's request to disable/reenable ICP on the fly - icp_dynamic_enabled = 1; - // Used to give plugins the ability to create http requests // The equivalent of the connecting to localhost on the proxy // port but without going through the operating system diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 89446c2ab80..3c51716dcfa 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -34,7 +34,6 @@ #include "StatPages.h" #include "Log.h" #include "LogAccessHttp.h" -#include "ICP.h" #include "PluginVC.h" #include "ReverseProxy.h" #include "RemapProcessor.h" @@ -2362,94 +2361,6 @@ HttpSM::state_handle_stat_page(int event, void *data) return 0; } -/////////////////////////////////////////////////////////////// -// -// HttpSM::state_auth_callback() -// -/////////////////////////////////////////////////////////////// -// int -// HttpSM::state_auth_callback(int event, void *data) -//{ -// STATE_ENTER(&HttpSM::state_auth_lookup, event); - -// ink_release_assert(ua_entry != NULL); -// pending_action = NULL; - -// if (event == AUTH_MODULE_EVENT) { -// authAdapter.HandleAuthResponse(event, data); -//} else { -// ink_release_assert(!"Unknown authentication module event"); -//} -/************************************************************************\ - * pending_action=ACTION_RESULT_DONE only if Authentication step has * - * been done & authorization is left * - * pending_action=NULL only if we have to set_next_state. * - * pending_action=something else. Don't do anything. * - * One more callback is pending * -\************************************************************************/ - -// if (authAdapter.stateChangeRequired()) { -// set_next_state(); -//} -// OLD AND UGLY: if (pending_action == NULL) { -// OLD AND UGLY: pending_action=NULL; -// OLD AND UGLY: } else if(pending_action == ACTION_RESULT_DONE) { -// OLD AND UGLY: pending_action=NULL; -// OLD AND UGLY: } - -// return EVENT_DONE; -//} - -/////////////////////////////////////////////////////////////// -// -// HttpSM::state_icp_lookup() -// -/////////////////////////////////////////////////////////////// -int -HttpSM::state_icp_lookup(int event, void *data) -{ - STATE_ENTER(&HttpSM::state_icp_lookup, event); - - // ua_entry is NULL for scheduled updates - ink_release_assert(ua_entry != nullptr || t_state.req_flavor == HttpTransact::REQ_FLAVOR_SCHEDULED_UPDATE || - t_state.req_flavor == HttpTransact::REQ_FLAVOR_REVPROXY); - pending_action = nullptr; - - switch (event) { - case ICP_LOOKUP_FOUND: - - DebugSM("http", "ICP says ICP_LOOKUP_FOUND"); - t_state.icp_lookup_success = true; - t_state.icp_ip_result = *(struct sockaddr_in *)data; - - /* - * Disable ICP loop detection since the Cidera network - * insists on trying to preload the cache from a - * a sibling cache. - * - * // inhibit bad ICP looping behavior - * if (t_state.icp_ip_result.sin_addr.s_addr == - * t_state.client_info.ip) { - * DebugSM("http","Loop in ICP config, bypassing..."); - * t_state.icp_lookup_success = false; - * } - */ - break; - - case ICP_LOOKUP_FAILED: - DebugSM("http", "ICP says ICP_LOOKUP_FAILED"); - t_state.icp_lookup_success = false; - break; - default: - ink_release_assert(0); - break; - } - - call_transact_and_set_next_state(HttpTransact::HandleICPLookup); - - return 0; -} - ///////////////////////////////////////////////////////////////////////////////// // HttpSM::state_cache_open_write() // @@ -5115,23 +5026,6 @@ HttpSM::do_http_server_open(bool raw) return; } -void -HttpSM::do_icp_lookup() -{ - ink_assert(pending_action == nullptr); - - URL *o_url = &t_state.cache_info.original_url; - - Action *icp_lookup_action_handle = icpProcessor.ICPQuery(this, o_url->valid() ? o_url : t_state.cache_info.lookup_url); - - if (icp_lookup_action_handle != ACTION_RESULT_DONE) { - ink_assert(!pending_action); - pending_action = icp_lookup_action_handle; - } - - return; -} - void HttpSM::do_api_callout_internal() { @@ -5302,7 +5196,7 @@ HttpSM::mark_server_down_on_client_abort() // for revalidation or select it from a round // // robin set // // // - // Note: we do not want to mark parent or icp // + // Note: we do not want to mark parent // // proxies as down with this metric because // // that upstream proxy may be working but // // the actual origin server is one that is hung // @@ -7592,12 +7486,6 @@ HttpSM::set_next_state() break; } - case HttpTransact::SM_ACTION_ICP_QUERY: { - HTTP_SM_SET_DEFAULT_HANDLER(&HttpSM::state_icp_lookup); - do_icp_lookup(); - break; - } - case HttpTransact::SM_ACTION_CACHE_ISSUE_WRITE_TRANSFORM: { ink_assert(t_state.cache_info.transform_action == HttpTransact::CACHE_PREPARE_TO_WRITE); diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h index e9bd219b3cd..3fb62d869d4 100644 --- a/proxy/http/HttpSM.h +++ b/proxy/http/HttpSM.h @@ -371,7 +371,6 @@ class HttpSM : public Continuation int state_hostdb_reverse_lookup(int event, void *data); int state_mark_os_down(int event, void *data); int state_handle_stat_page(int event, void *data); - int state_icp_lookup(int event, void *data); int state_auth_callback(int event, void *data); int state_add_to_list(int event, void *data); int state_remove_from_list(int event, void *data); @@ -423,7 +422,6 @@ class HttpSM : public Continuation void do_cache_prepare_update(); void do_cache_prepare_action(HttpCacheSM *c_sm, CacheHTTPInfo *object_read_info, bool retry, bool allow_multiple = false); void do_cache_delete_all_alts(Continuation *cont); - void do_icp_lookup(); void do_auth_callout(); void do_api_callout(); void do_api_callout_internal(); diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index df9d7ef171e..7e96383b113 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -2635,65 +2635,43 @@ HttpTransact::HandleCacheOpenReadHit(State *s) DebugTxn("http_seq", "[HttpTransact::HandleCacheOpenReadHit] " "Revalidate document with server"); - if (s->http_config_param->icp_enabled && icp_dynamic_enabled && s->http_config_param->stale_icp_enabled && - needs_authenticate == false && needs_cache_auth == false && !s->hdr_info.client_request.is_pragma_no_cache_set() && - !s->hdr_info.client_request.is_cache_control_set(HTTP_VALUE_NO_CACHE)) { - DebugTxn("http_trans", "[HandleCacheOpenReadHit] ICP is configured" - " and no no-cache in request; checking ICP for a STALE hit"); - - s->stale_icp_lookup = true; - - // we haven't done the ICP lookup yet. The following is to - // fake an icp_info to cater for build_request's needs - s->icp_info.http_version.set(1, 0); - if (!s->txn_conf->keep_alive_enabled_out) { - s->icp_info.keep_alive = HTTP_NO_KEEPALIVE; - } else { - s->icp_info.keep_alive = HTTP_KEEPALIVE; - } + find_server_and_update_current_info(s); - update_current_info(&s->current, &s->icp_info, HttpTransact::ICP_SUGGESTED_HOST, 1); + // We do not want to try to revalidate documents if we think + // the server is down due to the something report problem + // + // Note: we only want to skip origin servers because 1) + // parent proxies have their own negative caching + // scheme & 2) If we skip down parents, every page + // we serve is potentially stale + // + if (s->current.request_to == ORIGIN_SERVER && is_server_negative_cached(s) && response_returnable == true && + is_stale_cache_response_returnable(s) == true) { + server_up = false; + update_current_info(&s->current, nullptr, UNDEFINED_LOOKUP, 0); + DebugTxn("http_trans", "CacheOpenReadHit - server_down, returning stale document"); } - - if (s->stale_icp_lookup == false) { - find_server_and_update_current_info(s); - - // We do not want to try to revalidate documents if we think - // the server is down due to the something report problem - // - // Note: we only want to skip origin servers because 1) - // parent proxies have their own negative caching - // scheme & 2) If we skip down parents, every page - // we serve is potentially stale - // - if (s->current.request_to == ORIGIN_SERVER && is_server_negative_cached(s) && response_returnable == true && - is_stale_cache_response_returnable(s) == true) { + // a parent lookup could come back as PARENT_FAIL if in parent.config, go_direct == false and + // there are no available parents (all down). + else if (s->current.request_to == HOST_NONE && s->parent_result.result == PARENT_FAIL) { + if (is_server_negative_cached(s) && response_returnable == true && is_stale_cache_response_returnable(s) == true) { server_up = false; update_current_info(&s->current, nullptr, UNDEFINED_LOOKUP, 0); DebugTxn("http_trans", "CacheOpenReadHit - server_down, returning stale document"); - } - // a parent lookup could come back as PARENT_FAIL if in parent.config, go_direct == false and - // there are no available parents (all down). - else if (s->current.request_to == HOST_NONE && s->parent_result.result == PARENT_FAIL) { - if (is_server_negative_cached(s) && response_returnable == true && is_stale_cache_response_returnable(s) == true) { - server_up = false; - update_current_info(&s->current, nullptr, UNDEFINED_LOOKUP, 0); - DebugTxn("http_trans", "CacheOpenReadHit - server_down, returning stale document"); - } else { - handle_parent_died(s); - return; - } + } else { + handle_parent_died(s); + return; } } - if (server_up || s->stale_icp_lookup) { + if (server_up) { // set a default version for the outgoing request HTTPVersion http_version; if (s->current.server != nullptr) { bool check_hostdb = get_ka_info_from_config(s, s->current.server); DebugTxn("http_trans", "CacheOpenReadHit - check_hostdb %d", check_hostdb); - if (!s->stale_icp_lookup && (check_hostdb || !s->current.server->dst_addr.isValid())) { + if (check_hostdb || !s->current.server->dst_addr.isValid()) { // We must be going a PARENT PROXY since so did // origin server DNS lookup right after state Start // @@ -2728,9 +2706,6 @@ HttpTransact::HandleCacheOpenReadHit(State *s) // in other words, we would not have looked up the cache for a // connect request, so the next action can not be origin_server_raw_open. s->next_action = how_to_open_connection(s); - if (s->stale_icp_lookup && s->next_action == SM_ACTION_ORIGIN_SERVER_OPEN) { - s->next_action = SM_ACTION_ICP_QUERY; - } ink_release_assert(s->next_action != SM_ACTION_ORIGIN_SERVER_RAW_OPEN); return; @@ -3027,19 +3002,15 @@ HttpTransact::handle_cache_write_lock(State *s) HandleCacheOpenReadHitFreshness(s); } else { StateMachineAction_t next; - if (s->stale_icp_lookup == false) { - next = how_to_open_connection(s); - if (next == SM_ACTION_ORIGIN_SERVER_OPEN || next == SM_ACTION_ORIGIN_SERVER_RAW_OPEN) { - s->next_action = next; - TRANSACT_RETURN(next, nullptr); - } else { - // hehe! - s->next_action = next; - ink_assert(s->next_action == SM_ACTION_DNS_LOOKUP); - return; - } + next = how_to_open_connection(s); + if (next == SM_ACTION_ORIGIN_SERVER_OPEN || next == SM_ACTION_ORIGIN_SERVER_RAW_OPEN) { + s->next_action = next; + TRANSACT_RETURN(next, nullptr); } else { - next = SM_ACTION_ICP_QUERY; + // hehe! + s->next_action = next; + ink_assert(s->next_action == SM_ACTION_DNS_LOOKUP); + return; } TRANSACT_RETURN(next, nullptr); @@ -3055,7 +3026,6 @@ HttpTransact::handle_cache_write_lock(State *s) // // // Possible Next States From Here: -// - HttpTransact::ICP_QUERY; // - HttpTransact::SM_ACTION_DNS_LOOKUP; // - HttpTransact::ORIGIN_SERVER_OPEN; // - HttpTransact::PROXY_INTERNAL_CACHE_NOOP; @@ -3095,25 +3065,6 @@ HttpTransact::HandleCacheOpenReadMiss(State *s) s->cache_info.action = CACHE_PREPARE_TO_WRITE; } - // We should not issue an ICP lookup if the request has a - // no-cache header. First check if the request has a no - // cache header. Then, if icp is enabled and the request - // does not have a no-cache header, issue an icp lookup. - - // does the request have a no-cache? - bool no_cache_in_request = false; - - if (s->hdr_info.client_request.is_pragma_no_cache_set() || s->hdr_info.client_request.is_cache_control_set(HTTP_VALUE_NO_CACHE)) { - no_cache_in_request = true; - } - // if ICP is enabled and above test indicates that request - // does not have a no-cache, issue icp query to sibling cache. - if (s->http_config_param->icp_enabled && icp_dynamic_enabled != 0 && (no_cache_in_request == false)) { - DebugTxn("http_trans", "[HandleCacheOpenReadMiss] " - "ICP is configured and no no-cache in request; checking ICP"); - s->next_action = SM_ACTION_ICP_QUERY; - return; - } /////////////////////////////////////////////////////////////// // a normal miss would try to fetch the document from the // // origin server, unless the origin server isn't resolvable, // @@ -3159,78 +3110,6 @@ HttpTransact::HandleCacheOpenReadMiss(State *s) return; } -/////////////////////////////////////////////////////////////////////////////// -// Name : HandleICPLookup -// Description: -// -// Details : -// -// -// -// Possible Next States From Here: -// - HttpTransact::SM_ACTION_DNS_LOOKUP; -// - HttpTransact::PROXY_INTERNAL_CACHE_NOOP; -// - result of how_to_open_connection() -// -/////////////////////////////////////////////////////////////////////////////// -void -HttpTransact::HandleICPLookup(State *s) -{ - SET_VIA_STRING(VIA_DETAIL_CACHE_TYPE, VIA_DETAIL_ICP); - if (s->icp_lookup_success == true) { - HTTP_INCREMENT_DYN_STAT(http_icp_suggested_lookups_stat); - DebugTxn("http_trans", "[HandleICPLookup] Success, sending request to icp suggested host."); - ats_ip4_set(&s->icp_info.dst_addr, s->icp_ip_result.sin_addr.s_addr); - s->icp_info.dst_addr.port() = ntohs(s->icp_ip_result.sin_port); - - // TODO in this case we should go to the miss case - // just a little shy about using goto's, that's all. - ink_release_assert((s->icp_info.dst_addr.port() != s->client_info.dst_addr.port()) || - (ats_ip_addr_cmp(&s->icp_info.dst_addr.sa, &Machine::instance()->ip.sa) != 0)); - - // Since the ICPDNSLookup is not called, these two - // values are not initialized. - // Force them to be initialized - s->icp_info.http_version.set(1, 0); - if (!s->txn_conf->keep_alive_enabled_out) { - s->icp_info.keep_alive = HTTP_NO_KEEPALIVE; - } else { - s->icp_info.keep_alive = HTTP_KEEPALIVE; - } - - s->icp_info.name = (char *)s->arena.alloc(17); - unsigned char *p = (unsigned char *)&s->icp_ip_result.sin_addr.s_addr; - snprintf(s->icp_info.name, 17, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); - - update_current_info(&s->current, &s->icp_info, ICP_SUGGESTED_HOST, 1); - s->next_hop_scheme = URL_WKSIDX_HTTP; - } else { - SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_NOT_CACHED); - DebugTxn("http_trans", "[HandleICPLookup] Failure, sending request to forward server."); - s->parent_info.name = nullptr; - ink_zero(s->parent_info.dst_addr); - - find_server_and_update_current_info(s); - if (!ats_is_ip(&s->current.server->dst_addr)) { - if (s->current.request_to == PARENT_PROXY) { - TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, PPDNSLookup); - } else { - ink_release_assert(0); - } - return; - } - } - if (!s->stale_icp_lookup) { - build_request(s, &s->hdr_info.client_request, &s->hdr_info.server_request, s->current.server->http_version); - } else { - ink_assert(s->hdr_info.server_request.valid()); - s->stale_icp_lookup = false; - } - s->next_action = how_to_open_connection(s); - - return; -} - /////////////////////////////////////////////////////////////////////////////// // Name : OriginServerRawOpen // Description: called for ssl tunneling @@ -3292,13 +3171,12 @@ HttpTransact::OriginServerRawOpen(State *s) // This is the entry into a coin-sorting machine. There are many different // bins that the response can fall into. First, the response can be invalid // if for example it is not a response, or not complete, or the connection -// was closed, etc. Then, the response can be from an icp-suggested-host, -// from a parent proxy or from the origin server. The next action to take -// differs for all three of these cases. Finally, good responses can either -// require a cache action, be it deletion, update, or writing or may just -// need to be tunnelled to the client. This latter case should be handled -// with as little processing as possible, since it should represent a fast -// path. +// was closed, etc. Then, the response can be from parent proxy or from +// the origin server. The next action to take differs for all three of these +// cases. Finally, good responses can either require a cache action, +// be it deletion, update, or writing or may just need to be tunnelled +// to the client. This latter case should be handled with as little processing +// as possible, since it should represent a fast path. // // // Possible Next States From Here: @@ -3339,9 +3217,6 @@ HttpTransact::HandleResponse(State *s) } switch (s->current.request_to) { - case ICP_SUGGESTED_HOST: - handle_response_from_icp_suggested_host(s); - break; case PARENT_PROXY: handle_response_from_parent(s); break; @@ -3349,7 +3224,7 @@ HttpTransact::HandleResponse(State *s) handle_response_from_server(s); break; default: - ink_assert(!("s->current.request_to is not ICP, P.P. or O.S. - hmmm.")); + ink_assert(!("s->current.request_to is not P.P. or O.S. - hmmm.")); break; } @@ -3448,64 +3323,6 @@ HttpTransact::HandleStatPage(State *s) s->next_action = SM_ACTION_INTERNAL_CACHE_NOOP; } -/////////////////////////////////////////////////////////////////////////////// -// Name : handle_response_from_icp_suggested_host -// Description: response came from the host suggested by the icp lookup -// -// Details : -// -// If the response was bad (for whatever reason), may try to open a -// connection with a parent proxy, if there are any, else the request -// should be sent to the client. -// If the response is good, handle_forward_server_connection_open is -// called. -// -// -// Possible Next States From Here: -// -/////////////////////////////////////////////////////////////////////////////// -void -HttpTransact::handle_response_from_icp_suggested_host(State *s) -{ - DebugTxn("http_trans", "[handle_response_from_icp_suggested_host] (hrfish)"); - HTTP_RELEASE_ASSERT(s->current.server == &s->icp_info); - - s->icp_info.state = s->current.state; - switch (s->current.state) { - case CONNECTION_ALIVE: - DebugTxn("http_trans", "[hrfish] connection alive"); - SET_VIA_STRING(VIA_DETAIL_ICP_CONNECT, VIA_DETAIL_ICP_SUCCESS); - handle_forward_server_connection_open(s); - break; - default: - DebugTxn("http_trans", "[hrfish] connection not alive"); - SET_VIA_STRING(VIA_DETAIL_ICP_CONNECT, VIA_DETAIL_ICP_FAILURE); - - // If the request is not retryable, bail - if (is_request_retryable(s) == false) { - handle_server_died(s); - return; - } - // send request to parent proxy now if there is - // one or else directly to the origin server. - find_server_and_update_current_info(s); - if (!ats_is_ip(&s->current.server->dst_addr)) { - if (s->current.request_to == PARENT_PROXY) { - TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, PPDNSLookup); - } else { - ink_release_assert(0); - } - return; - } - ink_assert(s->hdr_info.server_request.valid()); - s->next_action = how_to_open_connection(s); - if (s->current.server == &s->server_info && s->next_hop_scheme == URL_WKSIDX_HTTP) { - HttpTransactHeaders::remove_host_name_from_url(&s->hdr_info.server_request); - } - break; - } -} - /////////////////////////////////////////////////////////////////////////////// // Name : handle_response_from_parent // Description: response came from a parent proxy @@ -3518,7 +3335,7 @@ HttpTransact::handle_response_from_icp_suggested_host(State *s) // bad the next parent proxy (if any) is looked up. If there are no more // parent proxies that can be looked up, the response is sent to the // origin server. If the response is good handle_forward_server_connection_open -// is called, as with handle_response_from_icp_suggested_host. +// is called. // // // Possible Next States From Here: @@ -3658,7 +3475,7 @@ HttpTransact::handle_response_from_parent(State *s) break; default: // This handles: - // UNDEFINED_LOOKUP, ICP_SUGGESTED_HOST, + // UNDEFINED_LOOKUP // INCOMING_ROUTER break; } @@ -3959,7 +3776,7 @@ HttpTransact::handle_server_connection_not_open(State *s) // // Details : // -// "Forward server" includes the icp-suggested-host or the parent proxy +// "Forward server" includes the parent proxy // or the origin server. This function first determines if the forward // server uses HTTP 0.9, in which case it simply tunnels the response // to the client. Else, it updates @@ -6889,7 +6706,7 @@ HttpTransact::handle_request_keep_alive_headers(State *s, HTTPVersion ver, HTTPH case KA_CONNECTION: ink_assert(s->current.server->keep_alive != HTTP_NO_KEEPALIVE); if (ver == HTTPVersion(1, 0)) { - if (s->current.request_to == PARENT_PROXY || s->current.request_to == ICP_SUGGESTED_HOST) { + if (s->current.request_to == PARENT_PROXY) { heads->value_set(MIME_FIELD_PROXY_CONNECTION, MIME_LEN_PROXY_CONNECTION, "keep-alive", 10); } else { heads->value_set(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION, "keep-alive", 10); @@ -6903,7 +6720,7 @@ HttpTransact::handle_request_keep_alive_headers(State *s, HTTPVersion ver, HTTPH if (s->current.server->keep_alive != HTTP_NO_KEEPALIVE || (ver == HTTPVersion(1, 1))) { /* Had keep-alive */ s->current.server->keep_alive = HTTP_NO_KEEPALIVE; - if (s->current.request_to == PARENT_PROXY || s->current.request_to == ICP_SUGGESTED_HOST) { + if (s->current.request_to == PARENT_PROXY) { heads->value_set(MIME_FIELD_PROXY_CONNECTION, MIME_LEN_PROXY_CONNECTION, "close", 5); } else { heads->value_set(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION, "close", 5); diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h index 809348c304b..24ac31a6636 100644 --- a/proxy/http/HttpTransact.h +++ b/proxy/http/HttpTransact.h @@ -130,8 +130,6 @@ enum ViaStringIndex_t { VIA_DETAIL_CACHE_DESCRIPTOR, VIA_DETAIL_CACHE_TYPE, VIA_DETAIL_CACHE_LOOKUP, - VIA_DETAIL_ICP_DESCRIPTOR, - VIA_DETAIL_ICP_CONNECT, VIA_DETAIL_PP_DESCRIPTOR, VIA_DETAIL_PP_CONNECT, VIA_DETAIL_SERVER_DESCRIPTOR, @@ -198,7 +196,7 @@ enum ViaString_t { // cache type VIA_DETAIL_CACHE_DESCRIPTOR_STRING = 'c', VIA_DETAIL_CACHE = 'C', - VIA_DETAIL_ICP = 'I', + VIA_DETAIL_CLUSTER = 'L', VIA_DETAIL_PARENT = 'P', VIA_DETAIL_SERVER = 'S', // result of cache lookup @@ -211,10 +209,6 @@ enum ViaString_t { VIA_DETAIL_MISS_CLIENT = 'U', VIA_DETAIL_MISS_METHOD = 'D', VIA_DETAIL_MISS_COOKIE = 'K', - // result of icp suggested host lookup - VIA_DETAIL_ICP_DESCRIPTOR_STRING = 'i', - VIA_DETAIL_ICP_SUCCESS = 'S', - VIA_DETAIL_ICP_FAILURE = 'F', // result of pp suggested host lookup VIA_DETAIL_PP_DESCRIPTOR_STRING = 'p', VIA_DETAIL_PP_SUCCESS = 'S', @@ -351,7 +345,6 @@ class HttpTransact enum LookingUp_t { ORIGIN_SERVER, UNDEFINED_LOOKUP, - ICP_SUGGESTED_HOST, PARENT_PROXY, INCOMING_ROUTER, HOST_NONE, @@ -453,8 +446,6 @@ class HttpTransact SM_ACTION_CACHE_PREPARE_UPDATE, SM_ACTION_CACHE_ISSUE_UPDATE, - SM_ACTION_ICP_QUERY, - SM_ACTION_ORIGIN_SERVER_OPEN, SM_ACTION_ORIGIN_SERVER_RAW_OPEN, SM_ACTION_ORIGIN_SERVER_RR_MARK_DOWN, @@ -837,7 +828,6 @@ class HttpTransact bool is_revalidation_necessary; // Added to check if revalidation is necessary - YTS Team, yamsat bool request_will_not_selfloop; // To determine if process done - YTS Team, yamsat ConnectionAttributes client_info; - ConnectionAttributes icp_info; ConnectionAttributes parent_info; ConnectionAttributes server_info; // ConnectionAttributes router_info; @@ -890,9 +880,6 @@ class HttpTransact int64_t internal_msg_buffer_size; // out int64_t internal_msg_buffer_fast_allocator_size; - struct sockaddr_in icp_ip_result; // in - bool icp_lookup_success; // in - int scheme; // out int next_hop_scheme; // out int orig_scheme; // pre-mapped scheme @@ -947,7 +934,6 @@ class HttpTransact bool api_req_cacheable; bool api_resp_cacheable; bool api_server_addr_set; - bool stale_icp_lookup; UpdateCachedObject_t api_update_cached_object; LockUrl_t api_lock_url; StateMachineAction_t saved_update_next_action; @@ -1028,7 +1014,6 @@ class HttpTransact internal_msg_buffer_type(NULL), internal_msg_buffer_size(0), internal_msg_buffer_fast_allocator_size(-1), - icp_lookup_success(false), scheme(-1), next_hop_scheme(scheme), orig_scheme(scheme), @@ -1061,7 +1046,6 @@ class HttpTransact api_req_cacheable(false), api_resp_cacheable(false), api_server_addr_set(false), - stale_icp_lookup(false), api_update_cached_object(UPDATE_CACHED_OBJECT_NONE), api_lock_url(LOCK_URL_FIRST), saved_update_next_action(SM_ACTION_UNDEFINED), @@ -1103,7 +1087,6 @@ class HttpTransact via_string[VIA_DETAIL_SEPARATOR] = VIA_DETAIL_SEPARATOR_STRING; via_string[VIA_DETAIL_TUNNEL_DESCRIPTOR] = VIA_DETAIL_TUNNEL_DESCRIPTOR_STRING; via_string[VIA_DETAIL_CACHE_DESCRIPTOR] = VIA_DETAIL_CACHE_DESCRIPTOR_STRING; - via_string[VIA_DETAIL_ICP_DESCRIPTOR] = VIA_DETAIL_ICP_DESCRIPTOR_STRING; via_string[VIA_DETAIL_PP_DESCRIPTOR] = VIA_DETAIL_PP_DESCRIPTOR_STRING; via_string[VIA_DETAIL_SERVER_DESCRIPTOR] = VIA_DETAIL_SERVER_DESCRIPTOR_STRING; via_string[MAX_VIA_INDICES] = '\0'; @@ -1213,7 +1196,6 @@ class HttpTransact static void HandleCacheOpenReadMiss(State *s); static void build_response_from_cache(State *s, HTTPWarningCode warning_code); static void handle_cache_write_lock(State *s); - static void HandleICPLookup(State *s); static void HandleResponse(State *s); static void HandleUpdateCachedObject(State *s); static void HandleUpdateCachedObjectContinue(State *s); @@ -1221,7 +1203,6 @@ class HttpTransact static void handle_100_continue_response(State *s); static void handle_transform_ready(State *s); static void handle_transform_cache_write(State *s); - static void handle_response_from_icp_suggested_host(State *s); static void handle_response_from_parent(State *s); static void handle_response_from_server(State *s); static void delete_server_rr_entry(State *s, int max_retries); diff --git a/proxy/http/HttpTransactCache.cc b/proxy/http/HttpTransactCache.cc index f5068de6e12..ed8fd852788 100644 --- a/proxy/http/HttpTransactCache.cc +++ b/proxy/http/HttpTransactCache.cc @@ -185,9 +185,6 @@ HttpTransactCache::SelectFromAlternates(CacheHTTPInfoVector *cache_vector, HTTPH RELEASE_PRINT_LOCK() } - // ToDo: Need a way to detect if it's ICP here or not, and then "return 0;". That's what the old - // code did, in a very convoluted way ... - if (!client_request->valid()) { return 0; } diff --git a/proxy/http/HttpTransactHeaders.cc b/proxy/http/HttpTransactHeaders.cc index 4809c75e453..d4b0649097d 100644 --- a/proxy/http/HttpTransactHeaders.cc +++ b/proxy/http/HttpTransactHeaders.cc @@ -94,7 +94,7 @@ HttpTransactHeaders::insert_supported_methods_in_response(HTTPHdr *response, int { int method_output_lengths[32]; const char *methods[] = { - HTTP_METHOD_CONNECT, HTTP_METHOD_DELETE, HTTP_METHOD_GET, HTTP_METHOD_HEAD, HTTP_METHOD_ICP_QUERY, HTTP_METHOD_OPTIONS, + HTTP_METHOD_CONNECT, HTTP_METHOD_DELETE, HTTP_METHOD_GET, HTTP_METHOD_HEAD, HTTP_METHOD_OPTIONS, HTTP_METHOD_POST, HTTP_METHOD_PURGE, HTTP_METHOD_PUT, HTTP_METHOD_PUSH, HTTP_METHOD_TRACE, }; char inline_buffer[64]; @@ -572,8 +572,6 @@ HttpTransactHeaders::generate_and_set_squid_codes(HTTPHdr *header, char *via_str //////////////////////// if ((via_string[VIA_CACHE_RESULT] == VIA_IN_CACHE_FRESH) || (via_string[VIA_CACHE_RESULT] == VIA_IN_RAM_CACHE_FRESH)) { hier_code = SQUID_HIER_NONE; - } else if (via_string[VIA_DETAIL_ICP_CONNECT] == VIA_DETAIL_ICP_SUCCESS) { - hier_code = SQUID_HIER_SIBLING_HIT; } else if (via_string[VIA_DETAIL_PP_CONNECT] == VIA_DETAIL_PP_SUCCESS) { hier_code = SQUID_HIER_PARENT_HIT; } else if (via_string[VIA_DETAIL_CACHE_TYPE] == VIA_DETAIL_PARENT) { diff --git a/proxy/http/README.via b/proxy/http/README.via index ec635b4a995..133ff20970c 100644 --- a/proxy/http/README.via +++ b/proxy/http/README.via @@ -51,7 +51,7 @@ Then there are the detailed via codes which follow a ":" - tcips + tcps tunneling information F tunneling due to a header field (such as presence of If-Range header) @@ -61,22 +61,18 @@ cache type C cache - I icp + L cluster (not used) cache lookup result N conditional hit (client sent conditional, fresh in cache, returned 304) H cache hit - I conditional miss (client sent conditional, fresh in cache, returned 412) + I conditional miss (client sent conditional, fresh in cache, returned 412) M cache miss (url not in cache) S cache hit, but expired C cache hit, but config forces revalidate U cache hit, but client forces revalidate (e.g. Pragma: no-cache) D cache hit, but method forces revalidated (e.g. not anonymous) - icp conn info - S connection opened successfully - F connection open failed - pp conn info S connection opened successfully F connection open failed diff --git a/proxy/http/remap/RemapConfig.cc b/proxy/http/remap/RemapConfig.cc index 31f276e3401..d461b30c013 100644 --- a/proxy/http/remap/RemapConfig.cc +++ b/proxy/http/remap/RemapConfig.cc @@ -488,8 +488,6 @@ remap_validate_filter_args(acl_filter_rule **rule_pp, const char **argv, int arg m = HTTP_WKSIDX_GET; } else if (!strcasecmp(argptr, "HEAD")) { m = HTTP_WKSIDX_HEAD; - } else if (!strcasecmp(argptr, "ICP_QUERY")) { - m = HTTP_WKSIDX_ICP_QUERY; } else if (!strcasecmp(argptr, "OPTIONS")) { m = HTTP_WKSIDX_OPTIONS; } else if (!strcasecmp(argptr, "POST")) { diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc index 0f8c26b3579..317b3cb230a 100644 --- a/proxy/logging/Log.cc +++ b/proxy/logging/Log.cc @@ -597,18 +597,18 @@ Log::init_fields() SQUID_LOG_ERR_FUTURE_1, "ERR_FUTURE_1", SQUID_LOG_ERR_UNKNOWN, "ERR_UNKNOWN"); Ptr cache_hit_miss_map = make_ptr(new LogFieldAliasTable); - cache_hit_miss_map->init(23, SQUID_HIT_RESERVED, "HIT", SQUID_HIT_LEVEL_1, "HIT_RAM", // Also SQUID_HIT_RAM + cache_hit_miss_map->init(21, SQUID_HIT_RESERVED, "HIT", SQUID_HIT_LEVEL_1, "HIT_RAM", // Also SQUID_HIT_RAM SQUID_HIT_LEVEL_2, "HIT_SSD", // Also SQUID_HIT_SSD SQUID_HIT_LEVEL_3, "HIT_DISK", // Also SQUID_HIT_DISK SQUID_HIT_LEVEL_4, "HIT_CLUSTER", // Also SQUID_HIT_CLUSTER SQUID_HIT_LEVEL_5, "HIT_NET", // Also SQUID_HIT_NET SQUID_HIT_LEVEL_6, "HIT_LEVEL_6", SQUID_HIT_LEVEL_7, "HIT_LEVEL_7", SQUID_HIT_LEVEL_8, "HIT_LEVEL_8", - SQUID_HIT_LEVEl_9, "HIT_LEVEL_9", SQUID_MISS_NONE, "MISS", SQUID_MISS_ICP_AUTH, "MISS_ICP_AUTH", - SQUID_MISS_HTTP_NON_CACHE, "MISS_HTTP_NON_CACHE", SQUID_MISS_ICP_STOPLIST, "MISS_ICP_STOPLIST", - SQUID_MISS_HTTP_NO_DLE, "MISS_HTTP_NO_DLE", SQUID_MISS_HTTP_NO_LE, "MISS_HTTP_NO_LE", - SQUID_MISS_HTTP_CONTENT, "MISS_HTTP_CONTENT", SQUID_MISS_PRAGMA_NOCACHE, "MISS_PRAGMA_NOCACHE", - SQUID_MISS_PASS, "MISS_PASS", SQUID_MISS_PRE_EXPIRED, "MISS_PRE_EXPIRED", SQUID_MISS_ERROR, "MISS_ERROR", - SQUID_MISS_CACHE_BYPASS, "MISS_CACHE_BYPASS", SQUID_HIT_MISS_INVALID_ASSIGNED_CODE, "INVALID_CODE"); + SQUID_HIT_LEVEl_9, "HIT_LEVEL_9", SQUID_MISS_NONE, "MISS", SQUID_MISS_HTTP_NON_CACHE, + "MISS_HTTP_NON_CACHE", SQUID_MISS_HTTP_NO_DLE, "MISS_HTTP_NO_DLE", SQUID_MISS_HTTP_NO_LE, + "MISS_HTTP_NO_LE", SQUID_MISS_HTTP_CONTENT, "MISS_HTTP_CONTENT", SQUID_MISS_PRAGMA_NOCACHE, + "MISS_PRAGMA_NOCACHE", SQUID_MISS_PASS, "MISS_PASS", SQUID_MISS_PRE_EXPIRED, "MISS_PRE_EXPIRED", + SQUID_MISS_ERROR, "MISS_ERROR", SQUID_MISS_CACHE_BYPASS, "MISS_CACHE_BYPASS", + SQUID_HIT_MISS_INVALID_ASSIGNED_CODE, "INVALID_CODE"); field = new LogField("cache_result_code", "crc", LogField::sINT, &LogAccess::marshal_cache_result_code, &LogAccess::unmarshal_cache_code, make_alias_map(cache_code_map)); @@ -839,7 +839,7 @@ Log::init_fields() ink_hash_table_insert(field_symbol_hash, "fsiz", field); Ptr entry_type_map = make_ptr(new LogFieldAliasTable); - entry_type_map->init(N_LOG_ENTRY_TYPES, LOG_ENTRY_HTTP, "LOG_ENTRY_HTTP", LOG_ENTRY_ICP, "LOG_ENTRY_ICP"); + entry_type_map->init(N_LOG_ENTRY_TYPES, LOG_ENTRY_HTTP, "LOG_ENTRY_HTTP"); field = new LogField("log_entry_type", "etype", LogField::sINT, &LogAccess::marshal_entry_type, &LogAccess::unmarshal_entry_type, make_alias_map(entry_type_map)); global_field_list.add(field, false); diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc index ce3a1e9eb9d..66d2a06eca9 100644 --- a/proxy/logging/LogAccess.cc +++ b/proxy/logging/LogAccess.cc @@ -23,7 +23,7 @@ @section description This file implements the LogAccess class. However, LogAccess is an abstract base class, providing an interface that logging uses to get - information from a module, such as HTTP or ICP. Each module derives a + information from a module, such as HTTP. Each module derives a specific implementation from this base class (such as LogAccessHttp), and implements the virtual accessor functions there. diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h index f1d724349f8..698395f0170 100644 --- a/proxy/logging/LogAccess.h +++ b/proxy/logging/LogAccess.h @@ -131,7 +131,6 @@ enum LogEntryType { LOG_ENTRY_HTTP = 0, - LOG_ENTRY_ICP, N_LOG_ENTRY_TYPES, }; diff --git a/proxy/logging/LogAccessICP.cc b/proxy/logging/LogAccessICP.cc deleted file mode 100644 index 3cd88104bbc..00000000000 --- a/proxy/logging/LogAccessICP.cc +++ /dev/null @@ -1,292 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/*************************************************************************** - LogAccessICP.cc - - This file implements the LogAccessICP class, which specializes the - LogAccess class for ICP logging. Some of the field requests are not - relevant to ICP logging, and for those we simply return a default value - (NULL strings, 0 values). - - - ***************************************************************************/ -#include "ts/ink_platform.h" -#include "HTTP.h" -#include "ICP.h" -#include "ICPlog.h" -#include "LogAccessICP.h" -#include "LogUtils.h" - -/*------------------------------------------------------------------------- - LogAccessICP - -------------------------------------------------------------------------*/ - -LogAccessICP::LogAccessICP(ICPlog *icp_log) : m_icp_log(icp_log) -{ - ink_assert(m_icp_log != nullptr); -} - -/*------------------------------------------------------------------------- - LogAccessICP::~LogAccessICP - -------------------------------------------------------------------------*/ - -LogAccessICP::~LogAccessICP() -{ -} - -/*------------------------------------------------------------------------- - The marshalling routines ... - -------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_client_host_ip(char *buf) -{ - return marshal_ip(buf, m_icp_log->GetClientIP()); -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_client_host_port(char *buf) -{ - if (buf) { - uint16_t port = ntohs(m_icp_log->GetClientPort()); - marshal_int(buf, port); - } - return INK_MIN_ALIGN; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_client_auth_user_name(char *buf) -{ - char *str = (char *)m_icp_log->GetIdent(); - int len = LogAccess::strlen(str); - if (buf) { - marshal_str(buf, str, len); - } - return len; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_client_req_text(char *buf) -{ - int len = marshal_client_req_http_method(nullptr) + marshal_client_req_url(nullptr) + marshal_client_req_http_version(nullptr); - - if (buf) { - int offset = 0; - offset += marshal_client_req_http_method(&buf[offset]); - offset += marshal_client_req_url(&buf[offset]); - offset += marshal_client_req_http_version(&buf[offset]); - len = offset; - } - return len; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_client_req_http_method(char *buf) -{ - char *str = (char *)m_icp_log->GetMethod(); - int len = LogAccess::strlen(str); - - if (buf) { - marshal_str(buf, str, len); - } - return len; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_client_req_url(char *buf) -{ - char *str = (char *)m_icp_log->GetURI(); - int len = LogAccess::strlen(str); - if (buf) { - marshal_str(buf, str, len); - } - return len; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_client_req_url_canon(char *buf) -{ - int escapified_len; - Arena arena; - - // FIXME: need to ensure that m_icp_log->GetURI() is NUL-terminated - // - char *uri_str = (char *)m_icp_log->GetURI(); - int uri_len = ::strlen(uri_str); - char *str = LogUtils::escapify_url(&arena, uri_str, uri_len, &escapified_len); - - int len = round_strlen(escapified_len + 1); // the padded len - if (buf) { - marshal_str(buf, str, len); - } - return len; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_proxy_resp_content_type(char *buf) -{ - // FIXME: need to ensure that m_icp_log->GetContentType() is NUL-terminated - // - char *ct_str = (char *)m_icp_log->GetContentType(); - int ct_len = ::strlen(ct_str); - - // FIXME: need to be sure remove_content_type_attributecan mutate ct_str - // - LogUtils::remove_content_type_attributes(ct_str, &ct_len); - int len = LogAccess::strlen(ct_str); - if (buf) { - marshal_str(buf, ct_str, len); - } - return len; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_proxy_resp_squid_len(char *buf) -{ - if (buf) { - int64_t val = m_icp_log->GetSize(); - marshal_int(buf, val); - } - return INK_MIN_ALIGN; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_proxy_resp_content_len(char *buf) -{ - if (buf) { - int64_t val = m_icp_log->GetSize(); - marshal_int(buf, val); - } - return INK_MIN_ALIGN; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_proxy_resp_status_code(char *buf) -{ - if (buf) { - int64_t status = 0; // '000' for ICP - marshal_int(buf, status); - } - return INK_MIN_ALIGN; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_cache_result_code(char *buf) -{ - if (buf) { - SquidLogCode code = m_icp_log->GetAction(); - marshal_int(buf, (int64_t)code); - } - return INK_MIN_ALIGN; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_proxy_hierarchy_route(char *buf) -{ - if (buf) { - SquidHierarchyCode code = m_icp_log->GetHierarchy(); - marshal_int(buf, (int64_t)code); - } - return INK_MIN_ALIGN; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_server_host_name(char *buf) -{ - char *str = (char *)m_icp_log->GetFromHost(); - int len = LogAccess::strlen(str); - if (buf) { - marshal_str(buf, str, len); - } - return len; -} - -/*------------------------------------------------------------------------- - -------------------------------------------------------------------------*/ - -int -LogAccessICP::marshal_transfer_time_ms(char *buf) -{ - if (buf) { - ink_hrtime elapsed = m_icp_log->GetElapsedTime(); - elapsed /= HRTIME_MSECOND; - int64_t val = (int64_t)elapsed; - marshal_int(buf, val); - } - return INK_MIN_ALIGN; -} - -int -LogAccessICP::marshal_transfer_time_s(char *buf) -{ - if (buf) { - ink_hrtime elapsed = m_icp_log->GetElapsedTime(); - elapsed /= HRTIME_SECOND; - int64_t val = (int64_t)elapsed; - marshal_int(buf, val); - } - return INK_MIN_ALIGN; -} diff --git a/proxy/logging/LogAccessICP.h b/proxy/logging/LogAccessICP.h deleted file mode 100644 index 4d19f4d10d1..00000000000 --- a/proxy/logging/LogAccessICP.h +++ /dev/null @@ -1,94 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#ifndef LOG_ACCESS_ICP_H -#define LOG_ACCESS_ICP_H - -#include "LogAccess.h" - -class ICPlog; - -/*------------------------------------------------------------------------- - LogAccessICP - - This class extends the logging system interface as implemented by the - ICPlog class. - -------------------------------------------------------------------------*/ - -class LogAccessICP : public LogAccess -{ -public: - LogAccessICP(ICPlog *icp_log); - virtual ~LogAccessICP(); - - LogEntryType - entry_type() const - { - return LOG_ENTRY_ICP; - } - - // - // client -> proxy fields - // - virtual int marshal_client_host_ip(char *); // STR - virtual int marshal_client_host_port(char *); // INT - virtual int marshal_client_auth_user_name(char *); // STR - virtual int marshal_client_req_text(char *); // STR - virtual int marshal_client_req_http_method(char *); // INT - virtual int marshal_client_req_url(char *); // STR - virtual int marshal_client_req_url_canon(char *); // STR - - // - // proxy -> client fields - // - virtual int marshal_proxy_resp_content_type(char *); // STR - virtual int marshal_proxy_resp_squid_len(char *); // INT - virtual int marshal_proxy_resp_content_len(char *); // INT - virtual int marshal_proxy_resp_status_code(char *); // INT - virtual int marshal_cache_result_code(char *); // INT - - // - // proxy -> server fields - // - virtual int marshal_proxy_hierarchy_route(char *); // INT - - // - // server -> proxy fields - // - virtual int marshal_server_host_name(char *); // STR - - // - // other fields - // - virtual int marshal_transfer_time_ms(char *); // INT - virtual int marshal_transfer_time_s(char *); // INT - -private: - ICPlog *m_icp_log; - - // -- member functions that are not allowed -- - LogAccessICP(const LogAccessICP &rhs); - LogAccessICP &operator=(LogAccessICP &rhs); -}; - -#endif diff --git a/proxy/logging/LogBindings.cc b/proxy/logging/LogBindings.cc index 2d7dbaebd89..72569ba7ad2 100644 --- a/proxy/logging/LogBindings.cc +++ b/proxy/logging/LogBindings.cc @@ -426,7 +426,6 @@ MakeLogBindings(BindingInstance &binding, LogConfig *conf) // Constants for the log object "Protocol" field. binding.bind_constant("log.protocol.http", lua_Integer(LOG_ENTRY_HTTP)); - binding.bind_constant("log.protocol.icp", lua_Integer(LOG_ENTRY_ICP)); // We register the same metatable for each logging object, since none // of them have any real API; they are just handles to internal logging diff --git a/proxy/logging/Makefile.am b/proxy/logging/Makefile.am index 53e40e7b53f..883a2b28810 100644 --- a/proxy/logging/Makefile.am +++ b/proxy/logging/Makefile.am @@ -46,8 +46,6 @@ liblogging_a_SOURCES = \ LogAccess.h \ LogAccessHttp.cc \ LogAccessHttp.h \ - LogAccessICP.cc \ - LogAccessICP.h \ LogBindings.cc \ LogBindings.h \ LogBuffer.cc \ diff --git a/tests/getting_started.md b/tests/getting_started.md index 386268ea487..f73bb60e3dd 100644 --- a/tests/getting_started.md +++ b/tests/getting_started.md @@ -84,7 +84,6 @@ A number of file object are define to help with adding values to a given configu * cache.config * congestion.config * hosting.config - * icp.config * ip_allow.config * log_hosts.config * logging.config diff --git a/tests/gold_tests/autest-site/trafficserver.test.ext b/tests/gold_tests/autest-site/trafficserver.test.ext index 1f5a05dca57..f4442e05ce2 100644 --- a/tests/gold_tests/autest-site/trafficserver.test.ext +++ b/tests/gold_tests/autest-site/trafficserver.test.ext @@ -179,10 +179,6 @@ def MakeATSProcess(obj, name, command='traffic_server', select_ports=True): tmpname = os.path.join(config_dir, fname) p.Disk.File(tmpname, id=make_id(fname), typename="ats:config") - fname = "icp.config" - tmpname = os.path.join(config_dir, fname) - p.Disk.File(tmpname, id=make_id(fname), typename="ats:config") - fname = "ip_allow.config" tmpname = os.path.join(config_dir, fname) p.Disk.File(tmpname, id=make_id(fname), typename="ats:config")