summaryrefslogtreecommitdiff
path: root/main
AgeCommit message (Collapse)Author
2017-04-27SDP: Misc cleanups (Mostly memory leaks)Richard Mudgett
Change-Id: I74431b385da333f2c5f5a6d7c55e70b69a4f05d2
2017-04-27Merge "channel: Add ability to request an outgoing channel with stream ↵Jenkins2
topology."
2017-04-27Merge "frame: Better handle interpolated frames."Jenkins2
2017-04-27channel: Add ability to request an outgoing channel with stream topology.Joshua Colp
This change extends the ast_request functionality by adding another function and callback to create an outgoing channel with a requested stream topology. Fallback is provided by either converting the requested stream topology into a format capabilities structure if the channel driver does not support streams or by converting the requested format capabilities into a stream topology if the channel driver does support streams. The Dial application has also been updated to request an outgoing channel with the stream topology of the calling channel. ASTERISK-26959 Change-Id: Ifa9037a672ac21d42dd7125aa09816dc879a70e6
2017-04-27Merge "sdp: Add support for T.38"Joshua Colp
2017-04-27Merge "SDP: Ensure SDPs "merge" properly."Joshua Colp
2017-04-26frame: Better handle interpolated frames.Joshua Colp
Interpolated frames are frames which contain a number of samples but have no actual data. Audiohooks did not handle this case when translating an incoming frame into signed linear. It assumed that a frame would always contain media when it may not. If this occurs audiohooks will now immediately return and not act on the frame. As well for users of ast_trans_frameout the function has been changed to be a bit more sane and ensure that the data pointer on a frame is set to NULL if no data is actually on the frame. This allows the various spots in Asterisk that check for an interpolated frame based on the presence of a data pointer to work as expected. ASTERISK-26926 Change-Id: I7fa22f631fa28d540722ed789ce28e84c7f8662b
2017-04-26Merge "res_pjsip_sdp_rtp: No rtpmap for static RTP payload IDs in SDP."Jenkins2
2017-04-25sdp: Add support for T.38Joshua Colp
This change adds a T.38 format which can be used in a stream topology to specify that a UDPTL stream needs to be created. The SDP API has been changed to understand T.38 and create the UDPTL session, add the attributes, and parse the attributes. This change does not change the boundary of the T.38 state machine. It is still up to the channel driver to implement and act on it (such as queueing control frames or reacting to them). ASTERISK-26949 Change-Id: If28956762ccb8ead562ac6c03d162d3d6014f2c7
2017-04-25SDP: Ensure SDPs "merge" properly.Mark Michelson
The gist of this work ensures that when a remote SDP is received, it is merged properly with the local capabilities. The remote SDP is converted into a stream topology. That topology is then merged with the current local topology on the SDP state. That new merged topology is then used to create an SDP. Finally, adjustments are made to RTP instances based on knowledge gained from the remote SDP. There are also a battery of tests in this commit that ensure that some basic SDP merges work as expected. While this may not sound like a big change, it has the property that it caused lots of ancillary changes. * The remote SDP is no longer stored on the SDP state. Biggest reason: there's no need for it. The remote SDP is used at the time it is being set and nowhere else. * Some new SDP APIs were added in order to find attributes and convert generic SDP attributes into rtpmap structures. * Writing tests made me realize that retrieving a value from an SDP options structure, the SDP options needs to be made const. * The SDP state machine was essentially gutted by a previous commit. Initially, I attempted to reinstate it, but I found that as it had been defined, it was not all that useful. What was more useful was knowing the role we play in SDP negotiation, so the SDP state machine has been transformed into an indicator of role. * Rather than storing separate local and joint stream state capabilities, it makes more sense to keep track of current stream state and update it as things change. Change-Id: I5938c2be3c6f0a003aa88a39a59e0880f8b2df3d
2017-04-24core: Use eventfd for alert pipes on Linux when possibleSean Bright
The primary win of switching to eventfd when possible is that it only uses a single file descriptor while pipe() will use two. This means for each bridge channel we're reducing the number of required file descriptors by 1, and - if you're using timerfd - we also now have 1 less file descriptor per Asterisk channel. The API is not ideal (passing int arrays), but this is the cleanest approach I could come up with to maintain API/ABI. I've also removed what I believe to be an erroneous code block that checked the non-blocking flag on the pipe ends for each read. If the file descriptor is 'losing' its non-blocking mode, it is because of a bug somewhere else in our code. In my testing I haven't seen any measurable difference in performance. Change-Id: Iff0fb1573e7f7a187d5211ddc60aa8f3da3edb1d
2017-04-21Merge "pbx: Use same thread if AST_OUTGOING_WAIT_COMPLETE specified"George Joseph
2017-04-19pbx: Use same thread if AST_OUTGOING_WAIT_COMPLETE specifiedSean Bright
Both ast_pbx_outgoing_app() and ast_pbx_outgoing_exten() cause the core to spawn a new thread to perform the dial. When AST_OUTGOING_WAIT_COMPLETE is passed to these functions, the calling thread will be blocked until the newly created channel has been hung up. After this patch, we run the dial on the current thread rather than spawning a new one. The only in-tree code that passes AST_OUTGOING_WAIT_COMPLETE is pbx_spool, so you should see reduced thread usage if you are using .call files. Change-Id: I512735d243f0a9da2bcc128f7a96dece71f2d913
2017-04-19rtp_engine/res_rtp_asterisk: Fix RTP struct reentrancy crashes.Richard Mudgett
The struct ast_rtp_instance has historically been indirectly protected from reentrancy issues by the channel lock because early channel drivers held the lock for really long times. Holding the channel lock for such a long time has caused many deadlock problems in the past. Along comes chan_pjsip/res_pjsip which doesn't necessarily hold the channel lock because sometimes there may not be an associated channel created yet or the channel pointer isn't available. In the case of ASTERISK-26835 a pjsip serializer thread was processing a message's SDP body while another thread was reading a RTP packet from the socket. Both threads wound up changing the rtp->rtcp->local_addr_str string and interfering with each other. The classic reentrancy problem resulted in a crash. In the case of ASTERISK-26853 a pjsip serializer thread was processing a message's SDP body while another thread was reading a RTP packet from the socket. Both threads wound up processing ICE candidates in PJPROJECT and interfering with each other. The classic reentrancy problem resulted in a crash. * rtp_engine.c: Make the ast_rtp_instance_xxx() calls lock the RTP instance struct. * rtp_engine.c: Make ICE and DTLS wrapper functions to lock the RTP instance struct for the API call. * res_rtp_asterisk.c: Lock the RTP instance to prevent a reentrancy problem with rtp->rtcp->local_addr_str in the scheduler thread running ast_rtcp_write(). * res_rtp_asterisk.c: Avoid deadlock when local RTP bridging in bridge_p2p_rtp_write() because there are two RTP instance structs involved. * res_rtp_asterisk.c: Avoid deadlock when trying to stop scheduler callbacks. We cannot hold the instance lock when trying to stop a scheduler callback. * res_rtp_asterisk.c: Remove the lock in struct dtls_details and use the struct ast_rtp_instance ao2 object lock instead. The lock was used to synchronize two threads to prevent a race condition between starting and stopping a timeout timer. The race condition is no longer present between dtls_perform_handshake() and __rtp_recvfrom() because the instance lock prevents these functions from overlapping each other with regards to the timeout timer. * res_rtp_asterisk.c: Remove the lock in struct ast_rtp and use the struct ast_rtp_instance ao2 object lock instead. The lock was used to synchronize two threads using a condition signal to know when TURN negotiations complete. * res_rtp_asterisk.c: Avoid deadlock when trying to stop the TURN ioqueue_worker_thread(). We cannot hold the instance lock when trying to create or shut down the worker thread without a risk of deadlock. This patch exposed a race condition between a PJSIP serializer thread setting up an ICE session in ice_create() and another thread reading RTP packets. * res_rtp_asterisk.c:ice_create(): Set the new rtp->ice pointer after we have re-locked the RTP instance to prevent the other thread from trying to process ICE packets on an incomplete ICE session setup. A similar race condition is between a PJSIP serializer thread resetting up an ICE session in ice_create() and the timer_worker_thread() processing the completion of the previous ICE session. * res_rtp_asterisk.c:ast_rtp_on_ice_complete(): Protect against an uninitialized/null remote_address after calling update_address_with_ice_candidate(). * res_rtp_asterisk.c: Eliminate the chance of ice_reset_session() destroying and setting the rtp->ice pointer to NULL while other threads are using it by adding an ao2 wrapper around the PJPROJECT ice pointer. Now when we have to unlock the RTP instance object to call a PJPROJECT ICE function we will hold a ref to the wrapper. Also added some rtp->ice NULL checks after we relock the RTP instance and have to do something with the ICE structure. ASTERISK-26835 #close ASTERISK-26853 #close Change-Id: I780b39ec935dcefcce880d50c1a7261744f1d1b4
2017-04-13res_pjsip_sdp_rtp: No rtpmap for static RTP payload IDs in SDP.Alexander Traud
This saves around 100 bytes when G.711, G.722, G.729, and GSM are advertised in SDP. This reduces the chance to hit the MTU bearer of 1300 bytes for SIP over UDP, if many codecs are allowed in Asterisk. This new feature is enabled together with the optional feature compact_headers=yes via the file pjsip.conf. ASTERISK-26932 #close Change-Id: Iaa556ab4c8325cd34c334387ab2847fab07b1689
2017-04-12modules: change module LOAD_FAILUREs to LOAD_DECLINESGeorge Joseph
In all non-pbx modules, AST_MODULE_LOAD_FAILURE has been changed to AST_MODULE_LOAD_DECLINE. This prevents asterisk from exiting if a module can't be loaded. If the user wishes to retain the FAILURE behavior for a specific module, they can use the "require" or "preload-require" keyword in modules.conf. A new API was added to logger: ast_is_logger_initialized(). This allows asterisk.c/check_init() to print to the error log once the logger subsystem is ready instead of just to stdout. If something does fail before the logger is initialized, we now print to stderr instead of stdout. Change-Id: I5f4b50623d9b5a6cb7c5624a8c5c1274c13b2b25
2017-04-12Merge "stun.c: Fix ast_stun_request() erratic timeout."Joshua Colp
2017-04-11Merge "sorcery.c: Speed up ast_sorcery_retrieve_by_id()"zuul
2017-04-11stun.c: Fix ast_stun_request() erratic timeout.Richard Mudgett
If ast_stun_request() receives packets other than a STUN response then we could conceivably never exit if we continue to receive packets with less than three seconds between them. * Fix poll timeout to keep track of the time when we sent the STUN request. We will now send a STUN request every three seconds regardless of how many other packets we receive while waiting for a response until we have completed three STUN request transmission cycles. Change-Id: Ib606cb08585e06eb50877f67b8d3bd385a85c266
2017-04-11sorcery.c: Speed up ast_sorcery_retrieve_by_id()Richard Mudgett
Return early if ast_sorcery_retrieve_by_id() is not passed an id to find. Also eliminated the RAII_VAR() usage in the function. Change-Id: I871dbe162a301b5ced8b4393cec27180c7c6b218
2017-04-11tcptls.c: Cleanup TCP/TLS listener thread on abnormal exit.Richard Mudgett
Temporarily running out of file descriptors should not terminate the listener thread. Otherwise, when there becomes more file descriptors available, nothing is listening. * Added EMFILE exception to abnormal thread exit. * Added an abnormal TCP/TLS listener exit error message. * Closed the TCP/TLS listener socket on abnormal exit so Asterisk does not appear dead if something tries to connect to the socket. ASTERISK-26903 #close Change-Id: I10f2f784065136277f271159f0925927194581b5
2017-04-04CDR: Protect from data overflow in ast_cdr_setuserfield.Corey Farrell
ast_cdr_setuserfield wrote to a fixed length field using strcpy. This could result in a buffer overrun when called from chan_sip or func_cdr. This patch adds a maximum bytes written to the field by using ast_copy_string instead. ASTERISK-26897 #close patches: 0001-CDR-Protect-from-data-overflow-in-ast_cdr_setuserfie.patch submitted by Corey Farrell (license #5909) Change-Id: Ib23ca77e9b9e2803a450e1206af45df2d2fdf65c
2017-04-03Merge "sdp: Add support for setting connection address and clean up state."Mark Michelson
2017-03-30build: Fix deb build issues with fakerootWalter Doekes
If DESTDIR is set, don't call ldconfig. Assume that DESTDIR is used to create a binary archive. The ldconfig call should be delegated to the archive postinst script. This fixes the case where fakeroot wraps 'make install' causing $EUID to be 0 even though it doesn't have permission to call ldconfig. The previous logic in configure.ac to detect and correct libdir has been removed as it was not completely accurate. CentOS 64-bit users should again specifiy --libdir=/usr/lib64 when configuring to prevent install to /usr/lib. Updated Makefile:check-old-libdir to check for orphans in lib64 when installing to lib as well as orphans in lib when installing to lib64. Updated Makefile and main/Makefile uninstall targets to remove the orphans using the new logic. ASTERISK-26705 Change-Id: I51739d4a03e60bff38be719b8d2ead0007afdd51
2017-03-30sdp: Add support for setting connection address and clean up state.Joshua Colp
This change cleans up state management for media streams by moving RTP instances into their own session structure and adding additional details that are not relevant to the core (such as connection address). These can live either in the local capabilities or joint capabilities. The ability to set explicit connection address information for the purposes of direct media and NAT has also been added at the global and stream specific level. ASTERISK-26900 Change-Id: If7e5307239a9534420732de11c451a2705b6b681
2017-03-30astobj2: Prevent potential deadlocks with ao2_global_obj_releaseSean Bright
The ao2_global_obj_release() function holds an exclusive lock on the global object while it is being dereferenced. Any destructors that run during this time that call ao2_global_obj_ref() will deadlock because a read lock is required. Instead, we make the global object inaccessible inside of the write lock and only dereference it once we have released the lock. This allows the affected destructors to fail gracefully. While this doesn't completely solve the referenced issue (the error message about not being able to create an IQ continues to be shown) it does solve the backtrace spew that accompanied it. ASTERISK-21009 #close Reported by: Marcello Ceschia Change-Id: Idf40ae136b5070dba22cb576ea8414fbc9939385
2017-03-29Merge "core: Remove embedded module support"George Joseph
2017-03-29Merge "channel: Remove old epoll support and fixed max number of file ↵zuul
descriptors."
2017-03-27channel: Remove old epoll support and fixed max number of file descriptors.Joshua Colp
This change removes the old epoll support which has not been used or maintained in quite some time. The fixed number of file descriptors on a channel has also been removed. File descriptors are now contained in a growable vector. This can be used like before by specifying a specific position to store a file descriptor at or using a new API call, ast_channel_fd_add, which adds a file descriptor to the channel and returns its position. Tests have been added which cover the growing behavior of the vector and the new API call. ASTERISK-26885 Change-Id: I1a754b506c009b83dfdeeb08c2d2815db30ef928
2017-03-27core: Remove embedded module supportSean Bright
This has not worked for some time and is no longer actively maintained. Change-Id: I5110b0db69c152761b58fa025cb0a53b0e544d99
2017-03-24Merge "cdr: Allow setting of user field from 'h' extension"Joshua Colp
2017-03-24Merge "rtp_engine: allocate RTP dynamic payloads per session"zuul
2017-03-24Merge "audiohook.c: Lost RTP packets lead to out-of-sync MixMonitor."Joshua Colp
2017-03-22rtp_engine: allocate RTP dynamic payloads per sessionKevin Harwell
Dynamic payload types were statically defined in Asterisk. This unfortunately limited the number of dynamic payloads that could be registered. With this patch dynamic payload type numbers are now assigned dynamically and per RTP instance. However, in order to limit any issues where some clients expect the old statically defined value this patch makes it so the value Asterisk used to pre- designate is used for the dynamic assignment if available. An option, "rtp_use_dynamic", has also been added (can be set in asterisk.conf) that turns the new dynamic behavior on or off. When off it reverts back to using statically defined payload values. This option defaults to "yes" in Asterisk 15. ASTERISK-26515 #close patches: ASTERISK-26515.diff submitted by jcolp (license 5000 Change-Id: I7653465c5ebeaf968f1a1cc8f3f4f5c4321da7fc
2017-03-22Merge "res_pjsip_messaging: Check URI type before dereferencing"zuul
2017-03-22cdr: Allow setting of user field from 'h' extensionSebastian Gutierrez
The CDR code previously did not allow the user field to be set from the 'h' extension in the dialplan. This change removes that limitation and allows it to be set. ASTERISK-26818 Change-Id: I0fed8a79b5e408bac4e30542b8f33a61c5ed9aa6
2017-03-21Merge "autochan/mixmonitor/chanspy: Fix unsafe channel locking and references."zuul
2017-03-21res_pjsip_messaging: Check URI type before dereferencingSean Bright
We aren't validating that the URI we just parsed is a SIP/SIPS one before trying to access the user, host, and port members of a possibly uninitialized structure. Also update the MessageSend documentation to indicate what 'from' formats are accepted. ASTERISK-26484 #close Reported by: Vinod Dharashive Change-Id: I476b5cc5f18a7713d0ee945374f2a1c164857d30
2017-03-20audiohook.c: Lost RTP packets lead to out-of-sync MixMonitor.Aaron An
Fixed a bug in function "ast_audiohook_write_frame" that checked the variable other_factory_samples and only flushed the factories, so they would be in sync, when other_factory_samples > 0. When there is not any rtp incoming the variable other_factory_samples will be 0, and although the result of "our_factory_ms - other_factory_ms" may be very large, this led to the record file not syncing. ASTERISK-26875 #close Reported-by: Aaron An Tested-by: Aaron An Change-Id: Ia4d890fb8fc1636a7188502bab35f555685aea22
2017-03-20thread safety: Don't use getprotobyname()Sean Bright
POSIX does not require getprotobyname() to be thread safe and some implementations use static memory which causes issues when multiple threads are used. Further, our usage of it today is just to ultimately get IPPROTO_TCP for calls to setsockopt(). So instead we just use IPPROTO_TCP directly. Change-Id: I2e14e58674808f7ce99b2f5e900d0f90d0d8da48
2017-03-16Merge "RFC sdp: Initial SDP creation"Joshua Colp
2017-03-15Merge "pbx.c: Fix crash from malformed exten pattern."zuul
2017-03-15autochan/mixmonitor/chanspy: Fix unsafe channel locking and references.Richard Mudgett
Dereferencing struct ast_autochan.chan without first calling ast_autochan_channel_lock() is unsafe because the pointer could change at any time due to a masquerade. Unfortunately, ast_autochan_channel_lock() itself uses struct ast_autochan.chan unsafely and can result in a deadlock if the original channel happens to get destroyed after a masquerade in addition to the pointer getting changed. The problem is more likely to happen with v11 and earlier because masquerades are used to optimize out local channels on those versions. However, it could still happen on newer versions if the channel is executing a dialplan application when the channel is transferred or redirected. In this situation a masquerade still must be used. * Added a lock to struct ast_autochan to safely be able to use ast_autochan.chan while trying to get the channel lock in ast_autochan_channel_lock(). The locking order is the channel lock then the autochan lock. Locking in the other direction requires deadlock avoidance. * Fix unsafe ast_autochan.chan usages in app_mixmonitor.c. * Fix unsafe ast_autochan.chan usages in app_chanspy.c. * app_chanspy.c: Removed unused autochan parameter from next_channel(). ASTERISK-26867 Change-Id: Id29dd22bc0f369b44e23ca423d2f3657187cc592
2017-03-15Merge "core: Add stream topology changing primitives with tests."zuul
2017-03-14pbx.c: Fix crash from malformed exten pattern.Richard Mudgett
Forgetting to indicate an exten is a pattern can cause a crash if the "pattern" has a character set range. e.g., "9999[3-5]" The crash is due to a buffer overwrite because the '-' exten eye-candy wasn't removed as expected and overran the allocated space. The buffer overwrite is fixed two ways in this patch. 1) Fix ext_strncpy() to distinguish between pattern and non-pattern extens. Now '-' characters are removed when they are eye-candy and not when they are part of a pattern character set. Since the function is private to pbx.c, the return value now returns the number of bytes written to the destination buffer instead of the strlen() of the final buffer so the callers that care don't need to add one. 2) Fix callers to ext_strncpy() to supply the correct available buffer size of the destination buffer. ASTERISK-26668 Change-Id: I555d97411140e47e0522684062d174fbe32aa84a
2017-03-14RFC sdp: Initial SDP creationGeorge Joseph
* Added additional fields to ast_sdp_options. * Re-organized ast_sdp. * Updated field names to correspond to RFC4566 terminology. * Created allocs/frees for SDP children. * Created getters/setters for SDP children where appropriate. * Added ast_sdp_create_from_state. * Refactored res_sdp_translator_pjmedia for changes. Change-Id: Iefbd877af7f5a4d3c74deead1bff8802661b0d48
2017-03-14main/stasis_cache: Demote the ERROR message when removing a nonexistent itemMatt Jordan
This patch demotes the ERROR message that is displayed when a nonexistent item is removed from the Stasis cache. The genesis of this demotion is due to chan_sip's realtime peers and their interaction with Asterisk's core ast_endpoint code, but ostensibly it could happen from other channel drivers as well. Since Mark Michelson already did an excellent job of explaining on this issue, it is quoted here for posterity: "Internally, when a realtime peer is retrieved, Asterisk creates an ast_endpoint structure. When that peer is destroyed, the ast_endpoint is destroyed as well. Part of the destruction of the ast_endpoint involves clearing the Stasis cache of all information about that endpoint. The problem here is that the act of creating the ast_endpoint is not enough to actually put any information in the Stasis cache. Instead, something has to happen, such as a state change, in order for the Stasis cache to have any information about that endpoint. When a device registers, chan_sip creates an ast_endpoint structure, processes the REGISTER, and then destroys the ast_endpoint. When the ast_endpoint is destroyed, there is nothing to destroy in the Stasis cache, so an error message is emitted. When you use rtcachefriends, ast_endpoint structures persist for the lifetime of the module and so you do not see this error message." ASTERISK-25237 #close Change-Id: I53cebc6b4a897a1ab9564182b75c177780feff70
2017-03-08media_cache: Prefer ast_file_is_readable() over access()Sean Bright
Change-Id: Icc0dc6e61b2e68d5cdcb74b016b2726a388c7def
2017-03-07core: Add stream topology changing primitives with tests.Joshua Colp
This change adds a few things to facilitate stream topology changing: 1. Control frame types have been added for use by the channel driver to notify the application that the channel wants to change the stream topology or that a stream topology change has been accepted. They are also used by the indicate interface to the channel that the application uses to indicate it wants to do the same. 2. Legacy behavior has been adopted in ast_read() such that if a channel requests a stream topology change it is denied automatically and the current stream topology is preserved if the application is not capable of handling streams. Tests have also been written which confirm the multistream and non-multistream behavior. ASTERISK-26839 Change-Id: Ia68ef22bca8e8457265ca4f0f9de600cbcc10bc9
2017-03-06Saynumber is trying to get "and" from "digits/" subfolderDaniel Journo
* say.c Changed 'digits/and' to 'vm-and' for en_GB ASTERISK-26598 #close Change-Id: If1b713e5daea6f952b339f139178d292a6c4fcfe