[asterisk-dev] [Code Review] Properly route responses according to the Via headers in the request

Klaus Darilion klaus.mailinglists at pernau.at
Wed Dec 22 15:24:15 UTC 2010

Am 22.12.2010 14:57, schrieb Kevin P. Fleming:
> On 12/22/2010 05:32 AM, Klaus Darilion wrote:
>> Am 16.12.2010 18:29, schrieb Matthew Nicholson:
>>> This is an automatically generated e-mail. To reply, visit:
>>> https://reviewboard.asterisk.org/r/1059/
>>> Review request for Asterisk Developers. By Matthew Nicholson.
>>> Description
>>> This patch makes asterisk respect the Via headers in a request when
>>> responding to it. This is necessary in the even that a stateless
>>> proxy is in between asterisk and the requester.
>> Sorry for jumping in that late. It would be good if the description
>> would be useful - thus, describing what the current (broken?) behavior
>> is and how the new (fixed) behavior work.
>> I really wonder what is the problem with the current behavior.
>> > Without this patch,
>> > the response is simply routed back to the address we received the
>> > initial request from.
>> Really? I often use proxies between Asterisk and the SIP clients and
>> never had any issues - responses were always routed correctly
>> Please describe in more detail the problem with the old and new behavior.
> The problem report that caused Matt to be working on this is a scenario
> where an INVITE is received from a UAC through a proxy; Asterisk
> properly responds to the INVITE through the proxy. However, later the
> same UAC sends in-dialog INFO requests directly to Asterisk, bypassing
> the proxy, and Asterisk replies to the proxy instead of to the UAC.

OK, I understand.

> Based on my not-quite-complete understanding of SIP, my impression is
> that this UAC is behaving improperly; since it sent the dialog-creating
> request through the proxy, all subsequent requests should be sent
> through the proxy as well. However, that could be completely wrong, and
> Matt's analysis up to this point determined that it may have been wrong,
> and that we should be able to respond to the UAC directly for subsequent
> in-dialog requests.

AFAIK the response routing is always based on Via headers. Thus, if the 
in-dialog request bypasses the proxy, also the response should bypass 
the proxy.

If the proxy does not add a Record-Route header, then the UAC is fine 
and Asterisk behaves wrong.

If the proxy adds a Record-Route header, then the UAC is buggy. In this 
case Asterisk is buggy too, as it should send the response directly to 
the UAC.

I think the rule for implementation is simple. Route every response 
according to the respective request - don't use any information received 
in previous transactions. The rule for response routing is described in 
Alex's email.

An the other side - this could be sees as a security feature of Asterisk 
- to learn routing data only on session setup.


More information about the asterisk-dev mailing list