]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_iax2: Reload of iax peer results in loss of host address/port
authorRichard Begg <asterisk@meric.id.au>
Tue, 14 Mar 2017 21:51:41 +0000 (08:51 +1100)
committerRichard Begg <asterisk@meric.id.au>
Tue, 14 Mar 2017 21:51:41 +0000 (08:51 +1100)
When using a non-dynamic peer address, build_peer() invalidates the
peer address structure by setting the address family to unspecified.
However, if dnsmgr is enabled, the subsequent call to ast_dnsmgr_lookup()
will not amend the peer address if the cache is still valid, resulting
in peer connectivity failures.
To fix this, we call ast_dnsmgr_refresh() instead.

ASTERISK-26865

Change-Id: Id8a89a2f771ebbaf32255a35fe596a6dcb97a082

channels/chan_iax2.c

index db5e4fa4d3b567d421d02659c7e5c3f6e4edc865..e8c47ce9f756215deecfc1d97ded81e92145c221 100644 (file)
@@ -12928,7 +12928,13 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, st
                                        /* Non-dynamic.  Make sure we become that way if we're not */
                                        AST_SCHED_DEL(sched, peer->expire);
                                        ast_clear_flag64(peer, IAX_DYNAMIC);
-                                       peer->addr.ss.ss_family = AST_AF_UNSPEC;
+                                       if (peer->dnsmgr) {
+                                               // Make sure we refresh dnsmgr if we're using it
+                                               ast_dnsmgr_refresh(peer->dnsmgr);
+                                       } else {
+                                               // Or just invalidate the address
+                                               peer->addr.ss.ss_family = AST_AF_UNSPEC;
+                                       }
                                        if (ast_dnsmgr_lookup(v->value, &peer->addr, &peer->dnsmgr, srvlookup ? "_iax._udp" : NULL)) {
                                                return peer_unref(peer);
                                        }