Commit Graph

26704 Commits

Author SHA1 Message Date
Joshua Colp
a9f721303d Merge "chan_vpb.cc: Fix compiler warning Jenkins found." into 13 2015-07-02 09:47:49 -05:00
Walter Doekes
e0f565663b chan_sip: Fix early call pickup channel leak.
When handle_invite_replaces() was called, and either ast_bridge_impart()
failed or there was no bridge (because the channel we're picking up was
still ringing), chan_sip would leak a channel.

Thanks Matt and Corey for checking the bridge path.

ASTERISK-25226 #close

Change-Id: Ie736bb182170a73eef5bcef0ab0376f645c260c8
2015-07-02 16:12:32 +02:00
Matt Jordan
de3678c92e Merge "sorcery/realtime: Add a bit of debug and warning messages for bad configs" into 13 2015-07-02 08:02:01 -05:00
Joshua Colp
ffde1073bb Merge "res_timing: Don't close FD 0 when out of open files." into 13 2015-07-02 07:53:35 -05:00
Joshua Colp
43926568c3 Merge "rtp_engine: Skip useless self-assignment in ast_rtp_engine_unload_format." into 13 2015-07-02 07:52:29 -05:00
Joshua Colp
c2f4bf142f Merge "astfd: Fix buffer overflow in DEBUG_FD_LEAKS." into 13 2015-07-02 07:51:44 -05:00
Joshua Colp
c5c5c2a4ae Merge "chan_mgcp: Don't call close on fd -1." into 13 2015-07-02 07:50:41 -05:00
Walter Doekes
a5a262be78 chan_mgcp: Don't call close on fd -1.
ASTERISK-25220 #close

Change-Id: Ic48f3a82f51ada87f2fb0e016c9efe0ad56f1ee3
2015-07-02 06:22:13 -05:00
Walter Doekes
b835312b4c rtp_engine: Skip useless self-assignment in ast_rtp_engine_unload_format.
When running valgrind on Asterisk, it complained about:

    ==32423== Source and destination overlap in memcpy(0x85a920, 0x85a920, 304)
    ==32423==    at 0x4C2F71C: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/...)
    ==32423==    by 0x55BA91: ast_rtp_engine_unload_format (rtp_engine.c:2292)
    ==32423==    by 0x4EEFB7: ast_format_attr_unreg_interface (format.c:1437)

The code in question is a struct assignment, which may be performed by
memcpy as a compiler optimization. It is changed to only copy the struct
contents if source and destination are different.

ASTERISK-25219 #close

Change-Id: I6d3546c326b03378ca8e9b8cefd41c16e0088b9a
2015-07-02 06:18:58 -05:00
Walter Doekes
6551e16e03 astfd: Fix buffer overflow in DEBUG_FD_LEAKS.
If DEBUG_FD_LEAKS was used and more file descriptors than the default of
1024 were available, some DEBUG_FD_LEAKS-patched functions would
overwrite memory past the fixed-size (1024) fdleaks buffer.

This change:
- adds bounds checks to __ast_fdleak_fopen and __ast_fdleak_pipe
- consistently uses ARRAY_LEN() instead of sizeof() or 1023 or 1024
- stores pointers to constants instead of copying the contents
- reorders the fdleaks struct for possibly tighter packing
- adds a tiny bit of documentation

ASTERISK-25212 #close

Change-Id: Iacb69e7701c0f0a113786bd946cea5b6335a85e5
2015-07-02 05:24:33 -05:00
Walter Doekes
f4dd9560cf res_timing: Don't close FD 0 when out of open files.
This fixes so a failure to get a timer file descriptor does not cascade
to closing FD 0.

On error, both res_timing_kqueue and res_timing_timerfd would call the
destructor before setting the file handle. The file handle had been
initialized to 0, causing FD 0 to be closed. This in turn, resulted in
floods of "CLI>" messages and an unusable terminal.

ASTERISK-19277 #close
Reported by: Barry Chern

For the 13 branch, this was already fixed. This patch only ensures that
we do not attempt to close a negative file descriptor.

Change-Id: I147d7e33726c6e5a2751928d56561494f5800350
2015-07-02 12:10:22 +02:00
Richard Mudgett
78a1f4aa46 chan_vpb.cc: Fix compiler warning Jenkins found.
Change-Id: I0ec7fd10d56d90d5a60b12b5a7d6807f265ac5e0
2015-07-01 17:28:08 -05:00
Scott Griepentrog
6b16fbfc22 Channel alert pipe: improve diagnostic error return
When a frame is queued on a channel, any failure in
ast_channel_alert_write is logged along with errno.

This change improves the diagnostic message through
aligning the errno value with actual failure cases.

ASTERISK-25224
Reported by: Andrey Biglari

Change-Id: I1bf7b3337ad392789a9f02c650589cd065d20b5b
2015-07-01 16:55:50 -05:00
Matt Jordan
8e07ab145d sorcery/realtime: Add a bit of debug and warning messages for bad configs
When a mapping does not exist between a sorcery.conf defined object and
a realtime mapping in extconf, currently, the user will receive a slew
of ERROR messages that don't really tell what is happening. Some ERROR
messages may even be misleading, as they occur after the sorcery API has
already given up on the attempt to load and create the sorcery object.

This patch adds a bit of debug and a useful WARNING message for when a
wizard's open callback fails for a particular object type. In the bad
configurations that resulted in this patch, this provided a 'root cause'
WARNING message that pointed in the right direction of the configuration
problem.

Change-Id: I1cc7344f2b015b8b9c85a7e6ebc8cb4753a8f80b
2015-07-01 16:33:53 -05:00
Joshua Colp
69bfa518a0 Merge "res_sorcery_realtime: Fix leak of sorcery object type." into 13 2015-06-30 07:32:03 -05:00
Matt Jordan
4c0b26b9e8 Merge "channel: Remove ignore of answer on non-outgoing channels." into 13 2015-06-30 07:07:13 -05:00
Mark Michelson
156395e743 res_sorcery_realtime: Fix leak of sorcery object type.
This prevents a leak of a sorcery object type when realtime sorcery
objects are retrieved by fields or when multiple objects are retrieved.

The extent of this leak is that sorcery object types would be leaked.
These are allocated whenever an object type is registered with sorcery,
meaning that on module shutdown, these objects would be leaked. This
could be problematic if many reloads were performed, but it is not as
severe as if every sorcery object retrieved from realtime were being
leaked.

ASTERISK-25165 #close
Reported by Corey Farrell

Change-Id: I625c3b50eee4576670b7eeb013c81ad043b4b4f8
2015-06-29 14:35:08 -05:00
Matt Jordan
bfa5d38a1b Merge "res_pjsip_nat: Adjust when contact should be rewritten." into 13 2015-06-29 11:57:00 -05:00
Matt Jordan
d84247a481 Merge "res/res_corosync: Always decline module load, instead of failing" into 13 2015-06-29 11:16:01 -05:00
Matt Jordan
a5e9c4e9b2 res/res_corosync: Always decline module load, instead of failing
Returns a 'failure' from the module load routine indicates to Asterisk
that it should abort loading completely. This is rarely - in fact,
really, never - a good option. Aborting load of Asterisk from a dynamic
module implies that the core, and the rest of the dynamic modules, don't
matter: we should abandon all processing.

res_corosync is really not that important.

This patch updates the module such that, if it fails to load, it
politely declines (emitting ERROR messages along the way), and allows
Asterisk to continue to function.

Note that this issue was keeping Asterisk unit tests from running on
certain build agents.

Change-Id: I252249e81fb9b1a68e0da873f54f47e21d648f0f
2015-06-26 22:02:42 -05:00
Matt Jordan
399cd8bcd9 main/pbx: Resolve case sensitivity regression in PBX hints
When 8297136f was merged for ASTERISK-25040, a regression was introduced
surrounding the case sensitivity of device names within hints.
Previously, device names - such as 'sip/foo' - were compared in a case
insensitive fashion. Thus, 'sip/foo' was equivalent to 'SIP/foo'. After
that patch, only the case sensitive name would match, i.e., 'SIP/foo'.
As a result, some dialplan hints stopped working.

This patch re-introduces case insensitive matching for device names in
hints.

ASTERISK-25040

ASTERISK-25202 #close

Change-Id: If5046a7d14097e1e3c12b63092b9584bb1e9cb4c
(cherry picked from commit 96bbcf495a)
2015-06-26 21:03:40 -05:00
Mark Michelson
24eec5a10b res_pjsip_nat: Adjust when contact should be rewritten.
A previous change made the contact only get rewritten if the dialog's
route set was not marked frozen. Unfortunately, while the intent of this
is correct, the dialog's route set actually gets marked as frozen
earlier than expected, especially for UAS dialogs.

Instead, the idea is that the contact needs to not be rewritten if there
is a pre-existing route set on the dialog. This is now accomplished by
checking the dialog's route set list instead of checking if the route
set is frozen.

Doing this causes some broken tests to begin passing again.

ASTERISK-25196
Reported by Mark Michelson

Change-Id: I525ab251fd40a52ede327a52a2810a56deb0529e
2015-06-26 16:17:35 -05:00
Richard Mudgett
0ec461a637 res_pjsip_outbound_registration.c: Add a serializer shutdown group.
The client_state objects contain a serializer used to send the outbound
REGISTER messages.  Once all those message transactions are complete then
the module can shutdown.

ASTERISK-24907 #close
Reported by: Kevin Harwell

Change-Id: Ibb2fe558f98190f2a06da830e0fadfa25516f547
2015-06-26 13:44:20 -05:00
Matt Jordan
0a1700d286 Merge "threadpool, res_pjsip: Add serializer group shutdown API calls." into 13 2015-06-26 13:35:07 -05:00
Matt Jordan
d8e61c04a4 Merge "res_pjsip_outbound_registration.c: Fix handle_client_state_destruction() refs" into 13 2015-06-26 13:35:01 -05:00
Matt Jordan
9b70a078f6 Merge "res_pjsip_outbound_registration.c: Use ast_sorcery_object_unregister() API" into 13 2015-06-26 13:34:38 -05:00
Matt Jordan
c69c8d4e80 Merge "res_pjsip_refer: Prevent sending duplicate headers." into 13 2015-06-26 11:27:00 -05:00
Matt Jordan
e5499c3233 Merge "sorcery: Add ast_sorcery_object_unregister() API call." into 13 2015-06-26 11:26:06 -05:00
Matt Jordan
dc067e585f Merge "res_pjsip_outbound_registration.c: Reorder load_module() and unload_module()." into 13 2015-06-26 11:25:38 -05:00
Mark Michelson
05a2cc1293 res_pjsip_refer: Prevent sending duplicate headers.
res_pjsip_refer will attempt to add Referred-By or Replaces headers to
outbound INVITEs at times. If the INVITE gets challenged for
authentication, then we will resend the INVITE. Prior to this patch, the
Referred-By or Replaces header would be re-added to the outbound INVITE,
resulting in duplicated headers.

ASTERISK-25204 #close
Reported by Mark Michelson

Change-Id: I59fb5c08b4d253c0dba9ee3d3950b5025358222d
2015-06-26 11:02:13 -05:00
Matt Jordan
71c1c559cf Merge "AMI: Add Linkedid to the standard channel snapshot AMI event headers." into 13 2015-06-26 10:59:04 -05:00
Mark Michelson
028fa54620 res_pjsip_nat: Rewrite route set when required.
When performing some provider testing, the rewrite_contact option was
interfering with proper construction of a route set when sending an ACK
after receiving a 200 OK response to an INVITE.

The initial INVITE was sent to address sip:foo. The 200 OK had a Contact
header with URI sip:bar. In addition, the 200 OK had Record-Route
headers for sip:baz and sip:foo, in that order. Since the Record-Route
headers had the lr parameter, the result should have been:

* Set R-URI of the ACK to sip:bar.
* Add Route headers for sip:foo and sip:baz, in that order.

However, the rewrite_contact option resulted in our rewriting the
Contact header on the 200 OK to sip:foo. The result was:

* R-URI remained sip:foo.
* We added Route headers for sip:foo and sip:baz, in that order.

The result was that sip:bar was not indicated in the ACK at all, so the
far end never received our ACK. The call eventually dropped.

The intention of rewrite_contact is to rewrite the most immediate
destination of our SIP request to be the same address on which we
received a request or response. In the case of processing a SIP response
with Record-Route headers, this means that instead of rewriting the
Contact header, we should instead rewrite the bottom-most Record-Route
header. In the case of processing a SIP request with Record-Route
headers, this means we rewrite the top-most Record-route header.
Like when we rewrite the Contact header, we also ensure to update
the dialog's route set if it exists.

ASTERISK-25196 #close
Reported by Mark Michelson

Change-Id: I9702157c3603a2d0bd8a8215ac27564d366b666f
2015-06-26 09:54:02 -05:00
Richard Mudgett
84c12f9e0c threadpool, res_pjsip: Add serializer group shutdown API calls.
A module trying to unload needs to wait for all serializers it creates and
uses to complete processing before unloading.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I8c80b90f2f82754e8dbb02ddf3c9121e5e966059
2015-06-25 14:37:08 -05:00
Richard Mudgett
602c4b74b5 res_pjsip_outbound_registration.c: Fix handle_client_state_destruction() refs
* handle_client_state_destruction() must always be passed a ref to
client_state because it will always unref client_state.
handle_registration_response() was not passing a client_state ref.

* Made the final un-REGISTER message get sent normally using the pjproject
register control structure in handle_client_state_destruction().  The
previous code attempted to short circuit the response handling for the
module to unload.  That doesn't work for a couple reasons.  One,
pjsip_regc_send() may call the registered callback before it returns and
unbalance the client_state ref count.  Two, the registered callback
handles any authentication for the un-REGISTER message.

* Made the distinction between internal registration state and external
registration status with sip_outbound_registration_status_str().  This is
necessary to avoid altering documented AMI messages with internal
changes.

* Removed references to client_state->client outside of the serializer
thread.  When handle_client_state_destruction() destroys the pjproject
register control structure that memory is freed and cannot be referenced
anymore.  These accesses were to provide information for debug and
off-nominal warning messages.

* In sip_outbound_registration_timer_cb() you should not access entry->id
after unrefing client_state because the passed in entry is normally
pointing to the timer entry in the client_state object.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: Ia7b446d8644b6b4550ef5bea49527671de65183f
2015-06-25 14:37:08 -05:00
Richard Mudgett
8c6a95a9ac res_pjsip_outbound_registration.c: Use ast_sorcery_object_unregister() API
The sorcery pjsip 'registration' config object needs to be destroyed on
module unload.  Otherwise, a reload of res_pjsip could try to use
callbacks for a previously unloaded instance of the module provided by
ast_sorcery_object_register() or one of the variants.  Also, if
res_pjsip_outbound_registration were subsequently reloaded, the sorcery
config field objects would be registered in sorcery twice.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I304fad13dece2604af48353f6c6d9d5c7b064697
2015-06-25 14:36:12 -05:00
Joshua Colp
e4a2ef9e4e channel: Remove ignore of answer on non-outgoing channels.
Due to the way that channels can now be moved around inside of
Asterisk it is possible for the outgoing flag of a channel to get
cleared before it has been answered. This results in the bridge
not receiving notification that the outgoing leg has been answered.

This most easily exhibits itself with DTMF based blond transfers.
Since the answer of the outgoing leg is ignored the other party
continues to receive both a locally generated ringing and the
media stream of the outgoing leg upon its answer. This results
in no media being heard.

This change removes the ignore of the answer and allows it
to pass through.

ASTERISK-25171 #close

Change-Id: I82aedcec4f89f34a2e5472086dfc9a6c775bca8e
2015-06-25 15:16:24 -03:00
Richard Mudgett
20f3d77ab9 sorcery: Add ast_sorcery_object_unregister() API call.
Find and unlink the specified sorcery object type to complement
ast_sorcery_object_register().  Without this function you cannot
completely unload individual modules that use sorcery for configuration.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I1c04634fe9a90921bf676725c7d6bb2aeaab1c88
2015-06-25 11:33:41 -05:00
Richard Mudgett
4313f32969 res_pjsip_outbound_registration.c: Reorder load_module() and unload_module().
It is best if the loading code creates and initializes the module's
infrastructure before letting the system know of its existence.  The
unloading code needs to reverse the actions of the loading code and in the
reverse order.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I5d151383e9787b5b60aa5e1627b10f040acdded4
2015-06-25 11:33:41 -05:00
Richard Mudgett
890c923786 AMI: Add Linkedid to the standard channel snapshot AMI event headers.
* The AMI version is bumped to 2.8.0.

ASTERISK-25189 #close
Reported by: John Hardin

Change-Id: I2b1778c3fdc1dca0ed55db4e3a639eddfb16c2ac
2015-06-25 11:17:09 -05:00
Mark Michelson
db0521f905 Merge "res_pjsip_mwi: Set up unsolicited MWI upon registration." into 13 2015-06-25 09:52:04 -05:00
Joshua Colp
61658dd219 Merge "test.c: Add unit test registration checks for summary and description." into 13 2015-06-25 04:51:37 -05:00
Joshua Colp
282b5f3c85 Merge "Unit tests: Fix unit test description strings." into 13 2015-06-25 04:50:22 -05:00
Richard Mudgett
2602a7484b test.c: Add unit test registration checks for summary and description.
Added checks when a unit test is registered to see that the summary and
description strings do not end with a new-line '\n' for consistency.

The check generates a warning message and will cause the
/main/test/registrations unit test to fail.

* Updated struct ast_test_info member doxygen comments.

Change-Id: I295909b6bc013ed9b6882e85c05287082497534d
2015-06-24 17:12:19 -05:00
Richard Mudgett
2b0482d699 Unit tests: Fix unit test description strings.
Analyzing the code shows that the unit test summary and description
strings should not end with a new-line character.  Where these strings are
used in the code a new-line is provided for output.

Change-Id: I129284f5e7ca93d82532334076da4c462d3d9fba
2015-06-24 17:11:56 -05:00
Matt Jordan
f31fb5d54e Merge "app_dial: Hold reference to calling channel formats when dialing outbound." into 13 2015-06-24 17:07:00 -05:00
Joshua Colp
e99e654d75 app_dial: Hold reference to calling channel formats when dialing outbound.
Currently when requesting a channel the native formats of the
calling channel are provided to the core for usage when dialing
the outbound channel. This occurs without holding the channel lock
or keeping a reference to the formats. This is problematic as
the channel driver may end up changing the formats during this time.
In the case of chan_sip this happens when an SDP negotiation
completes.

This change makes it so app_dial keeps a reference to the native
formats of the calling channel which guarantees that they will
remain valid for the period of time needed.

ASTERISK-25172 #close

Change-Id: I2f0a67bd0d5d14c3bdbaae552b4b1613a283f0db
2015-06-24 13:50:55 -05:00
Matt Jordan
6264dbf02d Merge "res_pjsip_outbound_registration.c: Add missing line endings to CLI commands" into 13 2015-06-24 08:38:52 -05:00
Matt Jordan
b240c3fa63 Merge "res_pjsip_outbound_registration.c: Eliminate simple RAII_VAR() usage." into 13 2015-06-24 08:38:36 -05:00
Matt Jordan
d75d96f57d Merge "res_pjsip_outbound_registration.c: Misc code cleanups." into 13 2015-06-24 08:37:45 -05:00
Matt Jordan
681790ef01 Merge "bridge.c: Hangup attended transfer target if bridged" into 13 2015-06-23 11:36:35 -05:00