[ 
https://issues.apache.org/jira/browse/TS-4570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15348857#comment-15348857
 ] 

ASF GitHub Bot commented on TS-4570:
------------------------------------

GitHub user jpeach opened a pull request:

    https://github.com/apache/trafficserver/pull/740

    TS-4570: Return to TS_HTTP_OS_DNS_HOOK if server address is set.

    Using HostDB, Traffic Server will try to connect to all the resolved
    IP addresses if the connection fail. However if a plugin sets the
    address using some out-of-band knowledge and TSHttpTxnServerAddrSet,
    it onlt gets to set the address once.
    
    This change returns the state machine to the OS_DNS_HOOK API callout
    so that the plugin can have an opportunity to set a different server
    address.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jpeach/trafficserver fix/4570

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/trafficserver/pull/740.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #740
    
----
commit ab84e0eb928207ff4d8cb1c11d54203a6bf157d7
Author: James Peach <[email protected]>
Date:   2016-06-24T23:07:54Z

    TS-4570: Return to TS_HTTP_OS_DNS_HOOK if server address is set.
    
    Using HostDB, Traffic Server will try to connect to all the resolved
    IP addresses if the connection fail. However if a plugin sets the
    address using some out-of-band knowledge and TSHttpTxnServerAddrSet,
    it onlt gets to set the address once.
    
    This change returns the state machine to the OS_DNS_HOOK API callout
    so that the plugin can have an opportunity to set a different server
    address.

----


> Return to TS_HTTP_OS_DNS_HOOK after explicit DNS
> ------------------------------------------------
>
>                 Key: TS-4570
>                 URL: https://issues.apache.org/jira/browse/TS-4570
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: Core, TS API
>            Reporter: James Peach
>             Fix For: sometime
>
>
> 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}}.
> {code}
> $ 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)) {
> {code}
> Note that some plugins might be unprepared for {{TS_HTTP_OS_DNS_HOOK}} to be 
> called multiple times, so we should document that.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to