res_pjsip_registrar: Remove unavailable contacts if exceeds max_contacts

The behavior of max_contacts and remove_existing are connected.  If
remove_existing is enabled, the soonest expiring contacts are removed.
This may occur when there is an unavailable contact.  Similarly,
when remove_existing is not enabled, registrations from good
endpoints are rejected in favor of retaining unavailable contacts.

This commit adds a new AOR option remove_unavailable, and the effect
of this setting will depend on remove_existing.  If remove_existing
is set to no, we will still remove unavailable contacts when they
exceed max_contacts, if there are any. If remove_existing is set to
yes, we will prioritize the removal of unavailable contacts before
those that are expiring soonest.

ASTERISK-29525

Change-Id: Ia2711b08f2b4d1177411b1be23e970d7fdff5784
This commit is contained in:
Joseph Nadiv
2021-07-21 17:36:03 -04:00
committed by Friendly Automation
parent ea36473c45
commit 4368764032
7 changed files with 187 additions and 9 deletions

View File

@@ -1997,8 +1997,9 @@
TLS. Unfortunately, refreshing a registration may register a
different contact address and exceed
<replaceable>max_contacts</replaceable>. The
<replaceable>remove_existing</replaceable> option can help by
removing the soonest to expire contact(s) over
<replaceable>remove_existing</replaceable> and
<replaceable>remove_unavailable</replaceable> options can help by
removing either the soonest to expire or unavailable contact(s) over
<replaceable>max_contacts</replaceable> which is likely the
old <replaceable>rewrite_contact</replaceable> contact source
address being refreshed.
@@ -2041,6 +2042,26 @@
</para></note>
</description>
</configOption>
<configOption name="remove_unavailable" default="no">
<synopsis>Determines whether new contacts should replace unavailable ones.</synopsis>
<description><para>
The effect of this setting depends on the setting of
<replaceable>remove_existing</replaceable>.</para>
<para>If <replaceable>remove_existing</replaceable> is set to
<literal>no</literal> (default), setting remove_unavailable to
<literal>yes</literal> will remove only unavailable contacts that exceed
<replaceable>max_contacts</replaceable> to allow an incoming
REGISTER to complete sucessfully.</para>
<para>If <replaceable>remove_existing</replaceable> is set to
<literal>yes</literal>, setting remove_unavailable to
<literal>yes</literal> will prioritize unavailable contacts for removal
instead of just removing the contact that expires the soonest.</para>
<note><para>See <replaceable>remove_existing</replaceable> and
<replaceable>max_contacts</replaceable> for further information about how
these 3 settings interact.
</para></note>
</description>
</configOption>
<configOption name="type">
<synopsis>Must be of type 'aor'.</synopsis>
</configOption>
@@ -2444,6 +2465,9 @@
<parameter name="RemoveExisting">
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='remove_existing']/synopsis/node())"/></para>
</parameter>
<parameter name="RemoveUnavailable">
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='remove_unavailable']/synopsis/node())"/></para>
</parameter>
<parameter name="Mailboxes">
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='mailboxes']/synopsis/node())"/></para>
</parameter>
@@ -2904,6 +2928,9 @@
<parameter name="RemoveExisting">
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='remove_existing']/synopsis/node())"/></para>
</parameter>
<parameter name="RemoveUnavailable">
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='remove_unavailable']/synopsis/node())"/></para>
</parameter>
<parameter name="Mailboxes">
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='mailboxes']/synopsis/node())"/></para>
</parameter>