<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19822">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span></span><br></pre><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  N A: Looks good to me, but someone else must approve
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_phoneprov.c: Multihomed SERVER cache prevention<br><br>Phones moving between subnets on multi-homed server have their<br>initially connected interface IP cached in the SERVER variable,<br>even when it is not specified in the configuration files. This<br>prevents phones from obtaining the correct SERVER variable value<br>when they move to another subnet.<br><br>ASTERISK-30388 #close<br>Reported-by: cmaj<br><br>Change-Id: I1d18987a9d58e85556b4c4a6814ce7006524cc92<br>---<br>A doc/CHANGES-staging/res_phoneprov_multihomed_server.txt<br>M res/res_phoneprov.c<br>2 files changed, 41 insertions(+), 2 deletions(-)<br><br></pre>
<pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/res_phoneprov_multihomed_server.txt b/doc/CHANGES-staging/res_phoneprov_multihomed_server.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..ff68014</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_phoneprov_multihomed_server.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_phoneprov</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+On multihomed Asterisk servers with dynamic SERVER template variables,</span><br><span style="color: hsl(120, 100%, 40%);">+reloading this module is no longer required when re-provisioning your</span><br><span style="color: hsl(120, 100%, 40%);">+phone to another interface address (e.g. when moving between VLANs.)</span><br><span>diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c</span><br><span>index 5a4efa0..ec3f387 100644</span><br><span>--- a/res/res_phoneprov.c</span><br><span>+++ b/res/res_phoneprov.c</span><br><span>@@ -874,6 +874,8 @@</span><br><span>     char path[PATH_MAX];</span><br><span>         char *file = NULL;</span><br><span>   char *server;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *newserver = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+       struct extension *exten_iter;</span><br><span>        int len;</span><br><span>     int fd;</span><br><span>      struct ast_str *http_header;</span><br><span>@@ -955,8 +957,7 @@</span><br><span>                   if ((res = getsockname(ast_iostream_get_fd(ser->stream), &name.sa, &namelen))) {</span><br><span>                          ast_log(LOG_WARNING, "Could not get server IP, breakage likely.\n");</span><br><span>                       } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                                struct extension *exten_iter;</span><br><span style="color: hsl(0, 100%, 40%);">-                           const char *newserver = ast_inet_ntoa(name.sa_in.sin_addr);</span><br><span style="color: hsl(120, 100%, 40%);">+                           newserver = ast_strdupa(ast_inet_ntoa(name.sa_in.sin_addr));</span><br><span> </span><br><span>                             AST_LIST_TRAVERSE(&route->user->extensions, exten_iter, entry) {</span><br><span>                                   AST_VAR_LIST_INSERT_TAIL(exten_iter->headp,</span><br><span>@@ -967,6 +968,21 @@</span><br><span> </span><br><span>            ast_str_substitute_variables_varshead(&tmp, 0, AST_LIST_FIRST(&route->user->extensions)->headp, file);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+           /* Do not retain dynamic SERVER address because next request from the phone might arrive on</span><br><span style="color: hsl(120, 100%, 40%);">+            * different interface IP address eg. if this is a multi-homed server on multiple subnets */</span><br><span style="color: hsl(120, 100%, 40%);">+          if (newserver) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      struct ast_var_t *varns;</span><br><span style="color: hsl(120, 100%, 40%);">+                      AST_LIST_TRAVERSE(&route->user->extensions, exten_iter, entry) {</span><br><span style="color: hsl(120, 100%, 40%);">+                            AST_LIST_TRAVERSE_SAFE_BEGIN(exten_iter->headp, varns, entries) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                  if (!strcmp(variable_lookup[AST_PHONEPROV_STD_SERVER], ast_var_name(varns))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                                AST_LIST_REMOVE_CURRENT(entries);</span><br><span style="color: hsl(120, 100%, 40%);">+                                             ast_var_delete(varns);</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%);">+                             AST_LIST_TRAVERSE_SAFE_END</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>          ast_free(file);</span><br><span> </span><br><span>          http_header = ast_str_create(80);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19822">change 19822</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/+/19822"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I1d18987a9d58e85556b4c4a6814ce7006524cc92 </div>
<div style="display:none"> Gerrit-Change-Number: 19822 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: cmaj <chris@penguinpbx.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: N A <asterisk@phreaknet.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>