You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2019/08/08 19:53:44 UTC

[trafficserver] branch master updated (2c8859c -> 7658b08)

This is an automated email from the ASF dual-hosted git repository.

amc pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


    from 2c8859c  Documentation for testing in Sphinx
     new 0236a4e  Fix IP address based loop detection.
     new 7658b08  Loop detection: add additional check for going to the same addr/port as the inbound already connected to. Closes #3654

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 proxy/http/HttpSM.cc       |  5 ++---
 proxy/http/HttpTransact.cc | 35 ++++++++++++++++++-----------------
 2 files changed, 20 insertions(+), 20 deletions(-)


[trafficserver] 01/02: Fix IP address based loop detection.

Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 0236a4e8d13376bdebb050cba76a440af6ae2d94
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Mon Aug 5 08:09:20 2019 -0500

    Fix IP address based loop detection.
---
 proxy/http/HttpSM.cc       | 5 ++---
 proxy/http/HttpTransact.cc | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index a530522..10b82e6 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -504,9 +504,8 @@ HttpSM::attach_client_session(ProxyTransaction *client_vc, IOBufferReader *buffe
 
   ats_ip_copy(&t_state.client_info.src_addr, netvc->get_remote_addr());
   ats_ip_copy(&t_state.client_info.dst_addr, netvc->get_local_addr());
-  t_state.client_info.dst_addr.port() = netvc->get_local_port();
-  t_state.client_info.is_transparent  = netvc->get_is_transparent();
-  t_state.client_info.port_attribute  = static_cast<HttpProxyPort::TransportType>(netvc->attributes);
+  t_state.client_info.is_transparent = netvc->get_is_transparent();
+  t_state.client_info.port_attribute = static_cast<HttpProxyPort::TransportType>(netvc->attributes);
 
   // Record api hook set state
   hooks_set = client_vc->has_hooks();
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 2e708ec..b6d90ce 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -6423,7 +6423,7 @@ HttpTransact::will_this_request_self_loop(State *s)
   if (s->dns_info.lookup_success) {
     if (ats_ip_addr_eq(s->host_db_info.ip(), &Machine::instance()->ip.sa)) {
       in_port_t host_port  = s->hdr_info.client_request.url_get()->port_get();
-      in_port_t local_port = s->client_info.src_addr.host_order_port();
+      in_port_t local_port = s->client_info.dst_addr.host_order_port();
       if (host_port == local_port) {
         switch (s->dns_info.looking_up) {
         case ORIGIN_SERVER:


[trafficserver] 02/02: Loop detection: add additional check for going to the same addr/port as the inbound already connected to. Closes #3654

Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 7658b085675087043d3ffd5b2dc9b88bb0dfd301
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Mon Aug 5 08:45:42 2019 -0500

    Loop detection: add additional check for going to the same addr/port as the inbound already connected to.
    Closes #3654
---
 proxy/http/HttpTransact.cc | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index b6d90ce..7dd0f53 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -6421,24 +6421,25 @@ HttpTransact::will_this_request_self_loop(State *s)
   // check if we are about to self loop //
   ////////////////////////////////////////
   if (s->dns_info.lookup_success) {
-    if (ats_ip_addr_eq(s->host_db_info.ip(), &Machine::instance()->ip.sa)) {
-      in_port_t host_port  = s->hdr_info.client_request.url_get()->port_get();
-      in_port_t local_port = s->client_info.dst_addr.host_order_port();
-      if (host_port == local_port) {
-        switch (s->dns_info.looking_up) {
-        case ORIGIN_SERVER:
-          TxnDebug("http_transact", "host ip and port same as local ip and port - bailing");
-          break;
-        case PARENT_PROXY:
-          TxnDebug("http_transact", "parent proxy ip and port same as local ip and port - bailing");
-          break;
-        default:
-          TxnDebug("http_transact", "unknown's ip and port same as local ip and port - bailing");
-          break;
-        }
-        build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Cycle Detected", "request#cycle_detected");
-        return true;
+    in_port_t dst_port   = s->hdr_info.client_request.url_get()->port_get(); // going to this port.
+    in_port_t local_port = s->client_info.dst_addr.host_order_port();        // already connected proxy port.
+    // It's a loop if connecting to the same port as it already connected to the proxy and
+    // it's a proxy address or the same address it already connected to.
+    if (dst_port == local_port && (ats_ip_addr_eq(s->host_db_info.ip(), &Machine::instance()->ip.sa) ||
+                                   ats_ip_addr_eq(s->host_db_info.ip(), s->client_info.dst_addr))) {
+      switch (s->dns_info.looking_up) {
+      case ORIGIN_SERVER:
+        TxnDebug("http_transact", "host ip and port same as local ip and port - bailing");
+        break;
+      case PARENT_PROXY:
+        TxnDebug("http_transact", "parent proxy ip and port same as local ip and port - bailing");
+        break;
+      default:
+        TxnDebug("http_transact", "unknown's ip and port same as local ip and port - bailing");
+        break;
       }
+      build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Cycle Detected", "request#cycle_detected");
+      return true;
     }
 
     // Now check for a loop using the Via string.