Uploaded image for project: 'Traffic Server'
  1. Traffic Server
  2. TS-4570

Return to TS_HTTP_OS_DNS_HOOK after explicit DNS

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.0.0
    • Component/s: Core, TS API
    • Labels:
      None

      Description

      Consider the case of a plugin that has out -of-band routing knowledge equivalent to DNS. So for a domain, it might have a number of possible IP addresses. Remap plugins can implement TSRemapOSResponse, which is called in the connection result handling path, but there's no facility for global plugins to reroute the request.

      In my case, I'm largely doing forward proxying, so I don't have a remap rule for everything I need to route. Hence I'm a global plugin.

      Here is a relatively hacky patch that backs the state machine back up to TS_HTTP_OS_DNS_HOOK if we get a connection failure, have retries left, and a plugin has called TSHttpTxnServerAddrSet.

      $ git diff proxy/http/HttpTransact.cc
      diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
      index 5ef0430..3363af1 100644
      --- a/proxy/http/HttpTransact.cc
      +++ b/proxy/http/HttpTransact.cc
      @@ -3762,6 +3762,11 @@ HttpTransact::handle_response_from_server(State *s)
               // families - that is locked in by the client source address.
               s->state_machine->ua_session->set_host_res_style(ats_host_res_match(&s->current.server->dst_addr.sa));
               TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, OSDNSLookup);
      +      } else if (s->api_server_addr_set) {
      +        // If the address was set by a plugin, give it another chance.
      +        s->dns_info.os_addr_style = DNSLookupInfo::OS_ADDR_TRY_HOSTDB;
      +        s->current.attempts++;
      +        TRANSACT_RETURN(SM_ACTION_API_OS_DNS, OSDNSLookup);
             } else if ((s->dns_info.srv_lookup_success || s->host_db_info.is_rr_elt()) &&
                        (s->txn_conf->connect_attempts_rr_retries > 0) &&
                        (s->current.attempts % s->txn_conf->connect_attempts_rr_retries == 0)) {
      

      Note that some plugins might be unprepared for TS_HTTP_OS_DNS_HOOK to be called multiple times, so we should document that.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jamespeach James Peach
                Reporter:
                jamespeach James Peach
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: