summaryrefslogtreecommitdiff
path: root/pbx/pbx_dundi.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2012-09-06 02:52:37 +0000
committerMatthew Jordan <mjordan@digium.com>2012-09-06 02:52:37 +0000
commit34d3cbc7ac156df81ec776cd064c409196db5823 (patch)
tree44b86c02c950d241197cbfb3ffe1e46424e89aca /pbx/pbx_dundi.c
parent4058ea15ab8682c32c37af10edeb18cd5e57edb2 (diff)
Fix DUNDi message routing bug when neighboring peer is unreachable
Consider a scenario where DUNDi peer PBX1 has two peers that are its neighbors, PBX2 and PBX3, and where PBX2 and PBX3 are also neighbors. If the connection is temporarily broken between PBX1 and PBX3, PBX1 should not include PBX3 in the list of peers it sends to PBX2 in a DPDISCOVER message, as it cannot send messages to PBX3. If it does, PBX2 will assume that PBX3 already received the message and fail to forward the message on to PBX3 itself. This patch fixes this by only including peers in a DPDISCOVER message that are reachable by the sending node. This includes all peers with an empty address (00:00:00:00:00:00) and that are have been reached by a qualify message. This patch also prevents attempting to qualify a dynamic peer with an empty address until that peer registers. The patch uploaded by Peter was modified slightly for this commit. (closes issue ASTERISK-19309) Reported by: Peter Racz patches: dundi_routing.patch uploaded by Peter Racz (license 6290) ........ Merged revisions 372417 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 372418 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 372419 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372420 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx/pbx_dundi.c')
-rw-r--r--pbx/pbx_dundi.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 79787cd1a..338be0c5c 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -3534,8 +3534,10 @@ static int optimize_transactions(struct dundi_request *dr, int order)
}
AST_LIST_TRAVERSE(&peers, peer, list) {
- if (has_permission(&peer->include, dr->dcontext) &&
- ast_eid_cmp(&peer->eid, &trans->them_eid) &&
+ if (ast_eid_cmp(&peer->eid, &empty_eid) && /* peer's eid is not empty (in case of dynamic peers) */
+ (peer->lastms > -1) && /* peer is reachable */
+ has_permission(&peer->include, dr->dcontext) && /* peer has destination context */
+ ast_eid_cmp(&peer->eid, &trans->them_eid) && /* peer is not transaction endpoint */
(peer->order <= order)) {
/* For each other transaction, make sure we don't
ask this EID about the others if they're not
@@ -4688,7 +4690,9 @@ static void build_peer(dundi_eid *eid, struct ast_variable *v, int *globalpcmode
if (needregister) {
peer->registerid = ast_sched_add(sched, 2000, do_register, peer);
}
- qualify_peer(peer, 1);
+ if (ast_eid_cmp(&peer->eid, &empty_eid)) {
+ qualify_peer(peer, 1);
+ }
}
AST_LIST_UNLOCK(&peers);
}