[Home]

Summary:ASTERISK-26988: res_pjsip_session: user_eq_phone adds double user=phone parameters to URIs
Reporter:dtryba (dtryba)Labels:fax patch pjsip
Date Opened:2017-05-08 08:31:55Date Closed:2017-10-12 07:01:58
Priority:MinorRegression?
Status:Closed/CompleteComponents:Resources/res_pjsip_session
Versions:13.14.1 Frequency of
Occurrence
Constant
Related
Issues:
is related toASTERISK-26964 res_pjsip_session: Wrong From on reinvite when request and To URI differ
Environment:Debian/stretch with repository supplied Asterisk 13.14.1~dfsg-1 There are no updates/patches for user_eq_phone either Debian specific or from 13.41.1 to 13.15 as far as I can see.Attachments:( 0) ast_sip_add_usereqphone.preventdoubles.diff
( 1) dialplan.txt
( 2) full.txt
( 3) invites.txt
( 4) pjsip.conf.txt
Description:Asterisk in a setup as proxy/sbc between customer and upstream provider, where upstream demands the use of user=phone for URIs containing phonenumbers. Only the endpoint definitions for upstream contain the "user_eq_phone = yes" option.

INVITE from upstream to Asterisk. R-URI/To/From/PAI containt the user=phone params. INVITE from Asterisk to customer, the user=phone gets stripped from all URIs. The 1xx/200OK from customer lack user=phone, but gets added by Asterisk to upstream. So far so good.

The customer endpoint is a fax, that re-INVITEs for t38. The re-INVITE lack user=phone. Asterisk adds "user=phone;user=phone" to relevant URIs
Upstream provider answers with a "400 Bad Request" and the connection is terminated (by both upstream as Asterisk).
Comments:By: Asterisk Team (asteriskteam) 2017-05-08 08:31:56.875-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: dtryba (dtryba) 2017-05-08 08:40:19.555-0500

Debug output that show the problem of the double user=phone parameters

By: dtryba (dtryba) 2017-05-08 09:08:36.589-0500

Setting "user_eq_phone = yes" for all endpoints makes no difference for the re-INVITE to upstream. The double user=phone to upstream remains even though there is already 1 user=phone in the customer re-INVITE

By: Rusty Newton (rnewton) 2017-05-08 13:00:19.397-0500

We require additional debug to continue with triage of your issue. Please follow the instructions on the wiki [1] for how to collect debugging information from Asterisk. For expediency, where possible, attach the debug with a '.txt' file extension so that the debug will be usable for further analysis.

Thanks!

[1] https://wiki.asterisk.org/wiki/display/AST/Collecting+Debug+Information



By: Rusty Newton (rnewton) 2017-05-08 13:01:16.404-0500

Can you capture the trace again, but this time along with warning,notice,error,verbose and debug messages? (make sure verbose and debug are turned up to 5 each). Instructions are linked in the previous comment.

Thanks!

By: Rusty Newton (rnewton) 2017-05-08 13:02:01.308-0500

Oh, and pjsip.conf or configuration for the endpoints involved would be helpful as well.

By: dtryba (dtryba) 2017-05-09 04:17:29.970-0500

console log wit  debug/verbose at level 5 and pjsip set logger on.

I changed something (at least user_eq_phone for all endpoints) and now the problem occurs also after a 302 redirect:

initial:
INVITE sip:+3140xxxxxxx@ims.imscore.net:5060;user=phone;transport=udp SIP/2.0
to redirector:
INVITE sip:+3140xxxxxxx@109.235.32.47;user=phone SIP/2.0
302 redirect:
Contact: <sip:+3140xxxxxxx@sip.itco.nl;user=phone>
to final target:
INVITE sip:+3140xxxxxxx@sip.itco.nl;user=phone;user=phone SIP/2.0

By: dtryba (dtryba) 2017-05-09 04:29:58.597-0500

dialplan for the incoming endpoint
pjsip.conf for defined endpoints

By: dtryba (dtryba) 2017-05-11 09:01:01.023-0500

I've been playing in ./res/res_pjsip.c with the function ast_sip_add_usereqphone. This function doesn't check if there is already a param called user present, but trying to check if it already exists in (I guessed) sip_uri->other_param reveals the param is never present.

Also when changing the case of the user and phone constants reveals that the new casing is present for both user params:
INVITE sip:+3140xxxxxxx@ims.imscore.net:5060;user=phone;transport=udp SIP/2.0
INVITE sip:+3140xxxxxxx@109.235.32.45;uSEr=pHONe SIP/2.0
INVITE sip:+3140xxxxxxx@sip.itco.nl;user=pHONe;uSEr=pHONe

So the doubles seem related to the ast_sip_add_usereqphone function. But I have no clue where to look further.


By: Joshua C. Colp (jcolp) 2017-05-11 09:05:54.613-0500

If you try the change at https://gerrit.asterisk.org/#/c/5535/ does this resolve the problem?

By: dtryba (dtryba) 2017-05-11 10:36:32.176-0500

Makes no difference. My problem also occurs before any reinvites (removed reInvite from subject).

By: dtryba (dtryba) 2017-05-12 07:07:55.161-0500

ast_sip_add_usereqphone.preventdoubles.diff solves my problem with double user=phone entries.

Tested only with 13.14.1, but in head (where I generated the diff) the function ast_sip_add_usereqphone is exactly the same, only a different offset.

This is IMHO a Q&D patch, someone with knowledge about pjsip regarding to parsing the URI could do a better job. But the idea is simple: check if the tag is already in the URI before adding it again.

By: dtryba (dtryba) 2017-05-12 09:49:56.745-0500

BTW I don't think this issue is related to ASTERISK-26964

By: Friendly Automation (friendly-automation) 2017-10-12 07:01:59.195-0500

Change 6671 merged by Joshua Colp:
res_pjsip: Prevent "user=phone" being added multiple times to header

[https://gerrit.asterisk.org/6671|https://gerrit.asterisk.org/6671]

By: Friendly Automation (friendly-automation) 2017-10-12 07:04:38.868-0500

Change 6757 merged by Jenkins2:
res_pjsip: Prevent "user=phone" being added multiple times to header

[https://gerrit.asterisk.org/6757|https://gerrit.asterisk.org/6757]

By: Friendly Automation (friendly-automation) 2017-10-12 07:04:40.409-0500

Change 6756 merged by Jenkins2:
res_pjsip: Prevent "user=phone" being added multiple times to header

[https://gerrit.asterisk.org/6756|https://gerrit.asterisk.org/6756]