Commit Graph

27659 Commits

Author SHA1 Message Date
zuul
ae8f6e996e Merge "res_odbc: Implement a connection pool." into 13 2016-06-07 12:09:19 -05:00
Joshua Colp
321a9b128f res_odbc: Implement a connection pool.
Testing has shown that our usage of UnixODBC is problematic
due to bugs within UnixODBC itself as well as the heavy weight
cost of connecting and disconnecting database connections, even
when pooling is enabled.

For users of UnixODBC 2.3.1 and earlier crashes would occur due
to insufficient protection of the disconnect operation. This was
fixed in UnixODBC 2.3.2 and above.

For users of UnixODBC 2.3.3 and higher a slow-down would occur
under heavy database use due to repeated connection establishment.
A regression is present where on each connection the database
configuration is cached again, with the cache growing out of
control.

The connection pool implementation present in this change helps
to mitigate these issues by reducing how much we connect and
disconnect database connections. We also solve the issue of
crashes under UnixODBC 2.3.1 by defaulting the maximum number of
connections to 1, returning us to the previous working behavior.
For users who may have a fixed version the maximum concurrent
connection limit can be increased helping with performance.

The connection pool works by keeping a list of active connections.
If the connection limit has not been reached a new connection is
established. If the connection limit has been reached then the
request waits until a connection becomes available before
continuing.

ASTERISK-26074 #close
ASTERISK-26054 #close

Change-Id: I6774bf4bac49a0b30242c76a09c403d2e856ecff
2016-06-07 11:58:03 -03:00
Alexander Traud
c6ee4a0f44 res_srtp: Instead of libSRTP use OpenSSL as random source.
Since libSRTP 1.5, its Random Number Generator (RNG) is not maintained anymore.
Therefore, the symbol RAND_bytes is used instead of crypto_get_random.

ASTERISK-24436 #close

Change-Id: Iea0bae4d4e3c9aa0926ea442b6484b5159789d96
2016-06-07 05:48:02 -05:00
zuul
93237209eb Merge "core/dial: New channel variable FORWARDERNAME" into 13 2016-06-06 07:27:30 -05:00
Joshua Colp
cda3385409 alembic: Fix migration.
The 81b01a191a46_pjsip_add_contact_reg_server.py script was attempting
to use UniqueConstraint and failing. It was not imported and after
importing it also continued to fail.

I've changed the script to use the explicit name of the constraint
instead.

Change-Id: I2438b0be90b7ce583b47dd27983c0c1a02cea5b9
2016-06-02 06:59:06 -03:00
Joshua Colp
4665aa89e3 Merge "pjsip_distributor.c: Use correct rdata info access method (Part 2)." into 13 2016-06-01 19:40:06 -05:00
zuul
49b1be8952 Merge "logging,cdr,cel: Fix stringfield memory leak." into 13 2016-06-01 16:11:33 -05:00
zuul
c4771ffb7c Merge "pjproject_bundled: Move to pjproject 2.5" into 13 2016-06-01 15:12:19 -05:00
Richard Mudgett
e2132dd358 logging,cdr,cel: Fix stringfield memory leak.
The stringfields refactor to allow adding stringfields to the end of a
structure (f6f4cf459f) exposed some
incomplete cleanup code by some stringfield users.

The most noticeable leaker is the logging system where there is a leak for
every log message generated.

ASTERISK-26078 #close
Reported by:  Etienne Lessard
Patches:
      jira_asterisk_26078_v13.patch (license #5621) patch uploaded
      by Richard Mudgett

Change-Id: If6a08b31336b492c3de6f9dfd07c447f8d5a8782
2016-06-01 13:57:53 -05:00
Alexei Gradinari
2de58c6d01 core/dial: New channel variable FORWARDERNAME
Added a new channel variable FORWARDERNAME which indicates which
channel was responsible for a forwarding requests received on dial attempt.

Fixed a bug in the app_queue: FORWARD_CONTEXT is not used.

ASTERISK-26059 #close

Change-Id: I34e93e8c1b5e17776a77b319703c48c8ca48e7b2
2016-05-31 18:07:40 -04:00
Richard Mudgett
b2ce0e354b pjsip_distributor.c: Use correct rdata info access method (Part 2).
The pjproject doxygen for rdata->msg_info.info says to call
pjsip_rx_data_get_info() instead of accessing the struct member directly.
You need to call the function mostly because the function will generate
the struct member value if it is not already setup.

Change-Id: I4d519385a577f3e9d9193a88125e493cf17fa799
2016-05-31 13:34:26 -05:00
zuul
acb614d5ae Merge "res_pjsip_mwi_body_generator: Re-order the body items" into 13 2016-05-31 12:39:45 -05:00
Joshua Colp
e3c9ad6382 Merge "res_pjsip: add "via_addr", "via_port", "call_id" to contact" into 13 2016-05-31 07:41:43 -05:00
zuul
eff382c72b Merge "res_pjsip: Add clarifying documentation to PJSIP_HEADER help text" into 13 2016-05-31 07:17:16 -05:00
zuul
856d6e34c3 Merge "res_pjsip: chatty verbose messages" into 13 2016-05-31 06:18:51 -05:00
George Joseph
fe305ccf01 res_pjsip_mwi_body_generator: Re-order the body items
Re-ordered the body items so Message-Account is second.

Messages-Waiting: no
Message-Account: sip:1571@<IP Removed>:5060
Voice-Message: 0/0 (0/0)

ASTERISK-26065 #close
Reported-by: Ross Beer

Change-Id: If5d35a64656eac98c2dd5e490cc0b2807bed80c3
2016-05-30 18:27:35 -06:00
George Joseph
e8abfdcdc5 pjproject_bundled: Move to pjproject 2.5
Although all the patches we had against 2.4.5 were applied by Teluu,
a new bug was introduced preventing re-use of tcp and tls transports
This patch removes all the previous patches against 2.4.5, updates
the version to 2.5, and adds a new patch to correct the transport
re-use problem.

Change-Id: I0dc6c438c3910f7887418a5832ca186aea23d068
2016-05-30 17:15:40 -06:00
Rusty Newton
37d039fdf3 res_pjsip: Add clarifying documentation to PJSIP_HEADER help text
Added notes about when you can read or write headers. Specifically
about being able to read on the inbound channel and write on an
outbound channel.

ASTERISK-26063 #close
Reported by: Private Name
Tested by: Rusty Newton

Change-Id: Ibeb64af17d1f6451028b3c29855a3f151a01d8c5
2016-05-27 12:42:40 -05:00
Joshua Colp
dc230f3b8f Merge "app_voicemail: fix bugs, imap mm_status log change to debug" into 13 2016-05-26 17:30:57 -05:00
Richard Mudgett
03d5b3ce5c pjsip_distributor.c: Use correct rdata info access method.
The pjproject doxygen for rdata->msg_info.info says to call
pjsip_rx_data_get_info() instead of accessing the struct member directly.
You need to call the function mostly because the function will generate
the struct member value if it is not already setup.

Change-Id: Iafe8b01242b7deb0ebfdc36685e21374a43936d2
2016-05-26 12:25:37 -05:00
Alexei Gradinari
859bbec09b app_voicemail: fix bugs, imap mm_status log change to debug
Fixed some bugs:
- create dirpath when save downloading message from IMAP storage.
- create IMAP folder if not exists when saving to IMAP storage
- check if file successfully opened before write to it
- some IMAP checks
- remove non-standard flag 'Unseen'
etc

Change to debug IMAP mm_status log instead of verbose.

Remove unused X-Asterisk-VM-Caller-channel message header
for security reason. The clients should not know name of peer/endpoint.

ASTERISK-26045 #close

Change-Id: I7f83d88b69b36934e2539c114b9fb612deed971b
2016-05-26 10:20:57 -04:00
Alexei Gradinari
230686f4ec res_pjsip: add "via_addr", "via_port", "call_id" to contact
As res_pjsip_nat rewrites contact's address, only the last Via header
can contain the source address of registered endpoint.
Also Call-Id header may contain the source address of registered
endpoint.

Added "via_addr", "via_port", "call_id" to contact.
Added new fields ViaAddress, CallID to AMI event ContactStatus.

ASTERISK-26011

Change-Id: I36bcc0bf422b3e0623680152d80486aeafe4c576
2016-05-25 10:56:14 -04:00
Alexei Gradinari
04c12561a7 res_pjsip: chatty verbose messages
There are a lot of verbose messages about Endpoint and Contact status
changes if there are many dynamic endpoints.
The patch sets verbose level 2 for Endpoint status changes
and verbose level 3 for Contact status changes.

ASTERISK-26055 #close

Change-Id: Ie64e261ddbbc41bfff0f0190241152cc123fe6d7
2016-05-25 09:38:01 -05:00
Corey Farrell
a42bea3314 threadpool: Fix potential data race.
worker_start checked for ZOMBIE status without holding a lock.  All
other read/write of worker status are performed with a lock, so this
check should do the same.

ASTERISK-25777 #close

Change-Id: I5e33685a5c26fdb300851989a3b82be8c4e03781
2016-05-24 16:30:18 -04:00
zuul
87fe6b1622 Merge "func_odbc: single database connection should be optional" into 13 2016-05-24 09:00:20 -05:00
zuul
06c6478ad8 Merge "Makefile: remove OSARCH check for init install" into 13 2016-05-23 16:16:14 -05:00
zuul
373e68539b Merge "func_curl: Don't trim response text on non-ASCII characters" into 13 2016-05-23 09:27:29 -05:00
zuul
80d1fc859e Merge "parking.h: Update ast_parking_park_call() doxygen to reality." into 13 2016-05-23 06:39:12 -05:00
Tzafrir Cohen
a32616d60c Makefile: remove OSARCH check for init install
There are more specific checks for the platform.

Specifically this allows installing OS/X init scripts.

ASTERISK-26038 #close

Change-Id: If08933621145b10362a0cfe73c079301d9c13f50
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2016-05-21 14:55:05 -05:00
Ivan Poddubny
9ddaab789e func_curl: Don't trim response text on non-ASCII characters
The characters 0x80-0xFF were trimmed as well as 0x00-0x20 because of
a signed comparison.

ASTERISK-25669 #close
Reported by: Jesper
patches:
  strings.curl.trim.patch submitted by Jesper (License 5518)

Change-Id: Ia51e169f24e3252a7ebbaab3728630138ec6f60a
2016-05-21 08:53:43 -05:00
Richard Mudgett
9453d1187a parking.h: Update ast_parking_park_call() doxygen to reality.
ASTERISK-26029

Change-Id: I2db14d102a48d3224010e6d1c69e856373cc1260
2016-05-20 17:55:40 -05:00
Alexei Gradinari
cd89501d48 func_odbc: single database connection should be optional
func_odbc was changed in Asterisk 13.9.0
to make func_odbc use a single database connection per DSN
because of reported bug ASTERISK-25938
with MySQL/MariaDB LAST_INSERT_ID().

This is drawback in performance when func_odbc is used
very often in dialplan.

Single database connection should be optional.

ASTERISK-26010

Change-Id: I57d990616c957dabf7597dea5d5c3148f459dfb6
2016-05-20 13:25:45 -04:00
Mark Michelson
c0b190dd9a res_pjsip: Match dialogs on responses better.
When receiving an incoming response to a dialog-starting INVITE, we were
not matching the response to the INVITE dialog. Since we had not
recorded the to-tag to the dialog structure, the PJSIP-provided method
to find the dialog did not match.

Most of the time, this was not a problem, because there is a fall-back
that makes the response get routed to the same serializer that the
request was sent on. However, in cases where an asynchronous DNS lookup
occurs in the PJSIP core, the thread that sends the INVITE is not
actually a threadpool serializer thread. This means we are unable to
record a serializer to handle the incoming response.

Now, imagine what happens when an INVITE is sent on a non-serialized
thread, and an error response (such as a 486) arrives. The 486 ends up
getting put on some random threadpool thread. Eventually, a hangup task
gets queued on the INVITE dialog serializer. Since the 486 is being
handled on a different thread, the hangup task can execute at the same
time that the 486 is being handled. The hangup task assumes that it is
the sole owner of the INVITE session and channel, so it ends up
potentially freeing the channel and NULLing the session's channel
pointer. The thread handling the 486 can crash as a result.

This change has the incoming response match the INVITE transaction, and
then get the dialog from that transaction. It's the same method we had
been using for matching incoming CANCEL requests. By doing this, we get
the INVITE dialog and can ensure that the 486 response ends up being
handled by the same thread as the hangup, ensuring that the hangup runs
after the 486 has been completely handled.

ASTERISK-25941 #close
Reported by Javier Riveros

Change-Id: I0d4cc5d07e2a8d03e9db704d34bdef2ba60794a0
2016-05-20 09:39:10 -05:00
Joshua Colp
ddcf983e39 res_sorcery_astdb: Filter fields to only the registered ones.
This change introduces the same filtering that is done in res_sorcery_realtime
to the res_sorcery_astdb module. This allows persisted sorcery objects
that may contain unknown fields to still be read in from the AstDB
and used. This is particularly useful when switching between different
versions of Asterisk that may have introduced additional fields.

ASTERISK-26014 #close

Change-Id: Ib655130485a3ccfd635b7ed5546010ca14690fb2
2016-05-19 19:47:21 -03:00
Joshua Colp
3296d2d194 Merge "res_pjsip_empty_info: Respond to empty SIP INFO packets" into 13 2016-05-19 15:12:02 -05:00
Joshua Colp
f09f923514 Merge "res_pjsip_outbound_publishing: After unloading the library won't load again" into 13 2016-05-19 13:33:08 -05:00
Joshua Colp
4e4a991d90 Merge "res_pjsip: Endpoint IP Access Controls" into 13 2016-05-19 11:54:03 -05:00
snuffy
39fedfa423 res_pjsip_empty_info: Respond to empty SIP INFO packets
Some SBCs require responses to empty SIP INFO packets
after establishing call via INVITE, if not responded to
they may drop your call after unspecified timeout of X minutes.

They are identified by having no Content-Type, check for this
and respond with 200 - OK message.

ASTERISK-24986 #close
Reported-by: Ilya Trikoz, Federico Santulli

Change-Id: Ib27e4f07151e5aef28fa587e4ead36c5b87c43e0
2016-05-19 09:06:30 -03:00
Joshua Colp
7d986ff3f6 Merge "res_pjsip_outbound_publish: Ref leak in off nominal callback paths" into 13 2016-05-19 05:56:31 -05:00
Joshua Colp
1b7ba9bb00 Merge "udptl: Don't eat sequence numbers until OK is received" into 13 2016-05-19 05:33:35 -05:00
Joshua Colp
4a04a5a3ec Merge "res/res_hep_pjsip: Fix reported local IP address when bound to 'any'" into 13 2016-05-19 05:18:32 -05:00
Joshua Colp
811a54836d Merge "res_pjsip_outbound_publish: state potential dropped on reloads/realtime fetches" into 13 2016-05-19 05:13:38 -05:00
Joshua Colp
cceccd68ad Merge "res_pjsip_outbound_publish: Potential crash due to off nominal path" into 13 2016-05-19 05:12:46 -05:00
Joshua Colp
4509aa890f Merge "res_pjsip_outbound_publish: Won't unload if condition wait times out" into 13 2016-05-18 19:17:43 -05:00
Joshua Colp
480b8cda30 Merge "chan_sip: Prevent extra Session-Expires headers from being added" into 13 2016-05-18 15:37:59 -05:00
George Joseph
935e0496c4 udptl: Don't eat sequence numbers until OK is received
Scenario:
Local fax -> Asterisk w/ firewall -> Provider -> Remote fax

* Local fax starts rtp call to remote fax
* Remote fax starts t38 call back to local fax.
* Local fax sends t38 no-signal to Asterisk before sending an OK.
* udptl processes the frame and increments the expected sequence number.
* chan_sip drops the frame because the call isn't up so nothing goes out
  the external interface to open the port for incoming packets.
* Local fax sends OK and Asterisk sends OK to the remote fax.
* Remote fax sends t38 packets which are dropped by the firewall.
* Local fax re-sends t38 no-signal with the same sequence number.
* udptl drops the frame because it thinks it's a dup.
* Still no outgoing packets to open the firewall.
* t38 negotiation fails.

The patch drops frames t38 received before udptl sequence processing
when the call hasn't been answered yet.  The second no-signal frame
is then seen as new and is relayed out the external interface which
opens the port and allows negotiation to continue.

ASTERISK-26034 #close

Change-Id: I11744b39748bd2ecbbe8ea84cdb4f3c5943c5af9
2016-05-18 14:05:47 -05:00
George Joseph
77e8ec162b chan_sip: Prevent extra Session-Expires headers from being added
When chan_sip does a re-INVITE to refresh a session and authentication
is required, the INVITE with the Authorization header containes a
second Session-Expires header without the ";refersher=" parameter.
This is causing some proxies to return a 400.  Also, when Asterisk is
the uas and the refresher, it is including the Session-Expires and
Min-SE headers in OPTIONS messages which is not allowed per RFC4028.

This patch (based on the reporter's) Checks to see if a Session-Expires
header is already in the message before adding another one.  It also
checks that the method is INVITE or UPDATE.

ASTERISK-26030 #close

Change-Id: I58a7b07bab5a3177748d8a7034fb8ad8e11ce1d9
2016-05-17 11:58:18 -05:00
George Joseph
3f6ef63099 res_pjsip_outbound_registration: Clean up state when registration is deleted
Nothing was cleaning up the registration state object when ast_sorcery_delete
was called on a registration.  So, the registration was deleted from sorcery
but the state object went right on refreshing the registration (or failing
to refresh the registration) with the peer.

* Added a 'deleted' observer on registration that removes the state object.

ASTERISK-25964 #close
Reported-by Matt Jordan

Change-Id: I2db792145cdb1f72ebbf57dd9099596dbbf12c23
2016-05-16 20:43:54 -05:00
zuul
bcb133ce93 Merge "configs/samples/pjsip.conf.sample: Fix typo" into 13 2016-05-16 13:53:02 -05:00
George Joseph
b6f9392a12 res_pjsip: Set TCP_NODELAY on TCP transports
Although it's perfectly legal to place multiple SIP messages in the same packet,
it can cause problems because the Linux default is to enable Path MTU Discovery
which sets the Don't Fragment bit on the packets. If adding a second message to
the packet causes the MTU to be exceeded, and the destination isn't equipped to
send a FRAGMENTATION NEEDED response to a large packet, the packet will just be
dropped.

We can't specifically tell the stack to send only 1 message per packet, but we
can turn on TCP_NODELAY when we create the transport. This will at least tell
the stack to send packets as soon as possible.

ASTERISK-26005 #close
Reported-by: Ross Beer

Change-Id: I820f23227183f2416ca5e393bec510e8fe1c8fbd
2016-05-15 18:05:34 -06:00