[sr-dev] Inconsistent branch numbering between REQUEST_ROUTE and REPLY_ROUTE

Daniel-Constantin Mierla miconda at gmail.com
Thu Oct 11 22:26:04 CEST 2012


Hello,

On 10/11/12 2:19 PM, Alex Hermann wrote:
> Hello,
>
>
> i found that $T_barnch_idx returns inconsistent numbers for the same branch.
> If printed in REQUEST_ROUTE, the value is alwasy 1 more that in REPLY_ROUTE.

do you actually mean BRANCH_ROUTE instead of REQUEST_ROUTE?

> The branch index is set using tm_ctx_set_branch_index(branch) in a lot of
> places, but only in t_fwd.c it is set with tm_ctx_set_branch_index(branch+1).
>
> If i change that to the same as elsewhere, the numbering is consistent. I'd
> like to get an ACK from a tm guru before i commit this fix, because i have
> no idea what side-effects this might have.

Indeed it should be same value. Probably when was added first time for 
branch_route was more like:
- if 0, then is like unset or before transaction is created
- if >0, then is branch index + 1

To bring proper coherence, I see two options:
- keep 0 for unset and return branch index + 1 otherwise
- use -1 for unset and return branch index otherwise

In either way, the patch has to updated.

Cheers,
Daniel
>
> --- a/modules/tm/t_fwd.c
> +++ b/modules/tm/t_fwd.c
> @@ -317,7 +317,7 @@ static int prepare_new_uac( struct cell *t, struct sip_msg *i_req,
>                          /* run branch_route actions if provided */
>                          backup_route_type = get_route_type();
>                          set_route_type(BRANCH_ROUTE);
> -                       tm_ctx_set_branch_index(branch+1);
> +                       tm_ctx_set_branch_index(branch);
>                          /* no need to backup/set avp lists: the on_branch route is run
>                             only in the main route context (e.g. t_relay() in the main
>                             route) or in the failure route context (e.g. append_branch &
>

-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - http://asipto.com/u/kat
Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 - http://asipto.com/u/katu




More information about the sr-dev mailing list