<p>Joshua Colp has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17544">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bridge: Deny full Local channel pair in bridge.<br><br>Local channels are made up of two pairs - the 1 and 2<br>sides. When a frame goes in one side, it comes out the<br>other. Back and forth. When both halves are in a<br>bridge this creates an infinite loop of frames.<br><br>This change makes it so that bridging no longer<br>allows both of these sides to exist in the same<br>bridge.<br><br>ASTERISK-29748<br><br>Change-Id: I29928b6de87cd9be996a77daccefd7c360fef651<br>---<br>M main/bridge_channel.c<br>1 file changed, 25 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/44/17544/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/bridge_channel.c b/main/bridge_channel.c</span><br><span>index 608db61..fa757e4 100644</span><br><span>--- a/main/bridge_channel.c</span><br><span>+++ b/main/bridge_channel.c</span><br><span>@@ -57,6 +57,7 @@</span><br><span> #include "asterisk/sem.h"</span><br><span> #include "asterisk/stream.h"</span><br><span> #include "asterisk/message.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk/core_local.h"</span><br><span> </span><br><span> /*!</span><br><span> * \brief Used to queue an action frame onto a bridge channel and write an action frame into a bridge.</span><br><span>@@ -2904,6 +2905,7 @@</span><br><span> int res = 0;</span><br><span> uint8_t indicate_src_change = 0;</span><br><span> struct ast_bridge_features *channel_features;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_channel *peer;</span><br><span> struct ast_channel *swap;</span><br><span> </span><br><span> ast_debug(1, "Bridge %s: %p(%s) is joining\n",</span><br><span>@@ -2918,6 +2920,29 @@</span><br><span> </span><br><span> ast_channel_lock(bridge_channel->chan);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ peer = ast_local_get_peer(bridge_channel->chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (peer) {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_bridge *peer_bridge;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_lock(peer);</span><br><span style="color: hsl(120, 100%, 40%);">+ peer_bridge = ast_channel_internal_bridge(peer);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_unlock(peer);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_unref(peer);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* As we are only doing a pointer comparison we don't need the peer_bridge</span><br><span style="color: hsl(120, 100%, 40%);">+ * to be reference counted or locked.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (peer_bridge == bridge_channel->bridge) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_unlock(bridge_channel->chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_bridge_unlock(bridge_channel->bridge);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "Bridge %s: %p(%s) denying Bridge join to prevent Local channel loop\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ bridge_channel->bridge->uniqueid,</span><br><span style="color: hsl(120, 100%, 40%);">+ bridge_channel,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_name(bridge_channel->chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> bridge_channel->read_format = ao2_bump(ast_channel_readformat(bridge_channel->chan));</span><br><span> bridge_channel->write_format = ao2_bump(ast_channel_writeformat(bridge_channel->chan));</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17544">change 17544</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/17544"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I29928b6de87cd9be996a77daccefd7c360fef651 </div>
<div style="display:none"> Gerrit-Change-Number: 17544 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>