diff options
author | Walter Doekes <walter+asterisk@wjd.nu> | 2012-10-16 21:38:00 +0000 |
---|---|---|
committer | Walter Doekes <walter+asterisk@wjd.nu> | 2012-10-16 21:38:00 +0000 |
commit | 8a65f47e88a8de9dfa5426441c06aaa63e6374a0 (patch) | |
tree | e38e2fd56f07b130a428d393aa69cd1286064b34 /channels/chan_sip.c | |
parent | b2f9542f617a5b99dc8742426fe84da919343f56 (diff) |
Don't do SIP contact/route DNS if we're not using the result.
In many cases (for peers behind NAT or for TCP sockets) we do not need
to look up any hostname in the Contact (or Route) when sending an
in-dialog request. This should reduce netsock2.c: getaddrinfo errors in
certain scenarios.
Review: https://reviewboard.asterisk.org/r/2156
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@375110 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 7227ddd5f..03f0de6e6 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -11811,7 +11811,16 @@ static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, ui if (p->route && !(sipmethod == SIP_CANCEL || (sipmethod == SIP_ACK && (p->invitestate == INV_COMPLETED || p->invitestate == INV_CANCELLED)))) { - set_destination(p, p->route->hop); + if (p->socket.type != SIP_TRANSPORT_UDP && p->socket.tcptls_session) { + /* For TCP/TLS sockets that are connected we won't need + * to do any hostname/IP lookups */ + } else if (ast_test_flag(&p->flags[0], SIP_NAT_FORCE_RPORT)) { + /* For NATed traffic, we ignore the contact/route and + * simply send to the received-from address. No need + * for lookups. */ + } else { + set_destination(p, p->route->hop); + } add_route(req, is_strict ? p->route->next : p->route); } add_max_forwards(p, req); |