[Home]

Summary:ASTERISK-20638: SIP dialog matching is incorrect when multiple provisional responses are received with pedantic SIP checking
Reporter:Eelco Brolman (eelcob)Labels:
Date Opened:2012-10-31 11:08:07Date Closed:2013-02-27 10:20:18.000-0600
Priority:MajorRegression?
Status:Closed/CompleteComponents:Channels/chan_sip/Interoperability
Versions:1.8.17.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Attachments:( 0) pedantic-call-pickup-from-tag.patch
Description:When an external call pickup (INVITE with Replaces: header) is sent to asterisk, asterisk tries to find the call ({{get_sip_pvt_byid_locked}}) based on the {{callid}}, {{fromtag}} and {{totag}} in pedantic mode.

The match will fail in certain situations since the fromtag is not definite (final) as long as only Provisional responses have been received.
When asterisk dials a SIP proxy which does ring group dialing for instance, multiple {{180 Ringing}} responses will be received, and the dialog within asterisk cannot be matched against a single fromtag.

So as long as only provisional responses are received (i.e. when flag {{SIP_PAGE2_DIALOG_ESTABLISHED}} is not set), asterisk should not reject the match based on the fromtag.

The patch for this specific situation is easy of course, you need to test if the dialog is established when checking the fromtag:
{code}
if ((frommismatch && ast_test_flag(&sip_pvt_ptr->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED)) || tomismatch) {
{code}
but I don't know if this breaks other checks.
Comments:By: Rusty Newton (rnewton) 2012-10-31 16:23:46.386-0500

Eelco,

If possible, can you provide a patch for the issue in unified diff format ?

https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines#AsteriskIssueGuidelines-PatchandCodesubmission

By: Eelco Brolman (eelcob) 2012-11-01 04:42:05.700-0500

Ofcourse, I have applied the following patch to make this work in our setup. Patch made against the 1.8.17.0 version of asterisk.

By: Joshua C. Colp (jcolp) 2012-11-17 10:15:30.138-0600

While not proper according to the RFC this *should* be okay on 1.8. With a normal SIP stack there would be multiple SIP dialogs and stuff would match properly, unlike chan_sip where there is only one and it doesn't.

Where I think this will fall apart is on Asterisk 10 and higher, where additional stuff was put in to more properly handle forking. I've done reading of the code there but am rather uncertain as to what will actually happen. Would it be possible for you to quickly lab that up in your setup to tell me and provide the logs? If not - no worries, I'll spend time to put together everything needed next week.

By: Eelco Brolman (eelcob) 2012-11-22 03:46:40.834-0600

I have tested the following scenario with asterisk 1.8, and it *does* fail. Look at the following scheme:

|| Action || Asterisk callid || Asterisk fromtag || Asterisk totag ||
| Asterisk dials SIP proxy | callid001 | fromtag001 | _(none)_ |
| SIP proxy dials phone A  | callid001 | fromtag001 | _(none)_ |
| phone A is ringing and sends 180 (totagA)  | callid001 | fromtag001 | totagA |
| SIP proxy stops dialing phone A and dials phone B  | callid001 | fromtag001 | totagA |
| phone B is ringing and sends 180 (totagB)  | callid001 | fromtag001 | *totagA* |
| phone C does callpickup of ringing phone B (callid001, fromtag001, totagB)  | callid001 | fromtag001 |  *totagA* |
| Since asterisk has not updated the totag againg, call pickup fails in pedantic mode  | callid001 | fromtag001 |  *totagA* |

Things get worse and not solvable for asterisk when the proxy decides to simultaneously dial multiple phones. Asterisk receives multiple totags (via the 180 response), and has no means to store them all. So a callpickup for a phone is likely to fail (wrong totag).



By: Joshua C. Colp (jcolp) 2012-11-22 07:00:06.097-0600

I meant the patch should be okay on 1.8. I also think it *should* be okay on Asterisk 10 and higher but I don't yet have stuff set up to test.

By: Eelco Brolman (eelcob) 2012-11-22 10:26:24.592-0600

Ah, ok :), I get it ;). It is ofcourse better when asterisk collects all the 180 Responses in an array, and looks up the match. If that's the case in Asterisk 10 and up, then no patch is required. I have unfortunately no asterisk 10 in my lab. Maybe in the next couple of weeks...

Will this patch be applied against the 1.8 series?

By: Joshua C. Colp (jcolp) 2012-11-30 10:18:20.488-0600

With the limitations that chan_sip has this is something that I feel would be fine going in, it's not something that can easily be worked around short of redoing how chan_sip does things.

By: Joshua C. Colp (jcolp) 2013-01-04 07:18:32.235-0600

Are you still willing to test this on a later version? If not I'll work on labbing things up.

By: Eelco Brolman (eelcob) 2013-01-21 05:32:34.156-0600

Sorry for the late reply, holidays... I have not been able to setup Asterisk 10 in our lab due to lack of resources, and will probably not be able to for some time (at least not for a couple of months). So if you can test it, please!