Module: sip-router
Branch: sr_3.0
Commit: b577291770fbae2d9df294529dd852acd760c4d6
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b577291…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Dec 10 18:35:17 2009 +0100
tm: onreply_route executed under lock to protect the avps
Quick fix for the onreply_route possible avp corruption: execute
the onreply route under lock.
---
modules/tm/t_reply.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 28e635e..8dbd1d6 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -89,7 +89,9 @@
* 2008-03-12 use cancel_b_method on 6xx (andrei)
* 2008-05-30 make sure the wait timer is started after we don't need t
* anymore to allow safe calls from fr_timer (andrei)
- * 2009-06-01 Pre- and post-script callbacks of branch route are executed (Miklos)
+ * 2009-06-01 Pre- and post-script callbacks of branch route are
+ * executed (Miklos)
+ * 2009-12-10 reply route is executed under lock to protect the avps (andrei)
*
*/
@@ -1834,6 +1836,7 @@ int reply_received( struct sip_msg *p_msg )
avp_list_t* backup_user_from, *backup_user_to;
avp_list_t* backup_domain_from, *backup_domain_to;
avp_list_t* backup_uri_from, *backup_uri_to;
+ int replies_locked;
#ifdef USE_DNS_FAILOVER
int branch_ret;
int prev_branch;
@@ -1860,6 +1863,7 @@ int reply_received( struct sip_msg *p_msg )
tm_ctx_set_branch_index(branch);
cancel_bitmap=0;
msg_status=p_msg->REPLY_STATUS;
+ replies_locked=0;
uac=&t->uac[branch];
DBG("DEBUG: reply_received: org. status uas=%d, "
@@ -1984,6 +1988,9 @@ int reply_received( struct sip_msg *p_msg )
/* Pre- and post-script callbacks have already
* been executed by the core. (Miklos)
*/
+ /* lock onreply_route, for safe avp usage */
+ LOCK_REPLIES( t );
+ replies_locked=1;
if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg, 0)<0)
LOG(L_ERR, "ERROR: on_reply processing failed\n");
/* transfer current message context back to t */
@@ -2035,15 +2042,22 @@ int reply_received( struct sip_msg *p_msg )
* reply lock is held (the lock won't be held while sending the
* message)*/
if (cfg_get(core, core_cfg, use_dns_failover) && (msg_status==503)) {
- branch_ret=add_uac_dns_fallback(t, t->uas.request, uac, 1);
+ branch_ret=add_uac_dns_fallback(t, t->uas.request,
+ uac, !replies_locked);
prev_branch=-1;
+ /* unlock replies to avoid sending() while holding a lock */
+ if (unlikely(replies_locked)) {
+ UNLOCK_REPLIES( t );
+ replies_locked = 0;
+ }
while((branch_ret>=0) &&(branch_ret!=prev_branch)){
prev_branch=branch_ret;
branch_ret=t_send_branch(t, branch_ret, t->uas.request , 0, 1);
}
}
#endif
- LOCK_REPLIES( t );
+ if (unlikely(!replies_locked))
+ LOCK_REPLIES( t );
if ( is_local(t) ) {
reply_status=local_reply( t, p_msg, branch, msg_status, &cancel_bitmap );
if (reply_status == RPS_COMPLETED) {
Hi!
K's tm module can be configured to have transaction AVPs or message AVPs:
http://kamailio.org/docs/modules/1.5.x/tm#id2530480
What is the behaviour of ser's tm module? I need AVPs in reply route -
is it supported?
regards
klaus
Bugs item #2911707, was opened at 2009-12-10 00:11
Message generated for change (Comment added) made by henningw
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2911707&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: ver 1.5.x
>Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: Asgaroth (asgaroth000)
>Assigned to: Henning Westerholt (henningw)
Summary: usrloc stores username in lowercase in "location" table
Initial Comment:
I am trying to integrate Kamailio (1.5.3-notls) into our existing
database structure using a view for the subscriber table and using the
location table to store the registration information.
I am successfully able to register a phone using this method.
One of our requirements is to set an "outboundproxy" and
"outboundproxyport" parameter in the location table for a particular sip
account (username). I am trying to do this with the sqlops module.
What I have come across though is that when the registration information
is saved to the location table the username is stored in lower case. So
when my sqlops query is run against the username it does not match.
For example, in the subscriber table I have view defined that for my
user account returns the following information:
-------------
select * from subscriber where username = 'BruceNW9440';
username | domain | password | ha1
| ha1b
-------------+---------------+------------+----------------------------------+----------------------------------
BruceNW9440 | 10.10.10.10 | 00minger00 |
1f2d688f65be04a61cab36a1fb3f426a | 6529d45f5c418daf35be7b3dd4a858cb
(1 row)
-------------
Now, if I check the above against the location table:
--------------
select * from location where username = 'BruceNW9440';
0 rows returned
--------------
If I run the same query using "brucenw9440" as the username (lowercase)
then the correct information is returned.
I have the following log line in my kamailio configuration script:
xlog("L_INFO","Username: $au, OutboundProxy: $Ri, OutboundProxyPort: $Rp");
The details of this log appear correct when it is logged:
Dec 9 14:21:03 ibis /opt/kamailio/sbin/kamailio[16972]: [ID 197553
local0.info] Username: BruceNW9440, OutboundProxy: 10.10.10.10,
OutboundProxyPort: 5060
However, when my sqlopt query is run it does not find a match because of
the incorrect case:
sql_query("bfl", "UPDATE location SET outboundproxy = '$Ri',
outboundproxyport = '$Rp' WHERE username = '$au'", "res");
I've had a read through the usrloc module documentation and I cannot
seem to find a reference to any options that will preserve the case. I
also cannot find if there is a parameter to save('location') that will
preserve the case. I cant seem to find a reference to the save()
function on the wiki. I must be missing something small.
----------------------------------------------------------------------
>Comment By: Henning Westerholt (henningw)
Date: 2009-12-10 13:56
Message:
I can confirm that setting the mentioned parameter fixes the usrloc
insertion.
>From the location table, parameter set to 0:
| testaccount.33 | 2009-12-10 16:47:21 | sip:Testaccount.33@XXXXX:5060
| sipp running on XXXXX
with parameter set to 1:
| Testaccount.33 | 2009-12-10 16:48:10 | sip:Testaccount.33@XXXXXX:5060
| sipp running on XXXXX
Therefore i think its not a bug in the module, only a configuration and
database issue.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2009-12-10 09:03
Message:
There is a parameter to control case sensitivity:
http://kamailio.org/docs/modules/1.5.x/registrar.html#id2491689
----------------------------------------------------------------------
Comment By: Henning Westerholt (henningw)
Date: 2009-12-10 08:54
Message:
I can confirm that usrloc stores the name in lowercase, even if its in
upper case in the subscriber table. This is probably a bug.
For the other thing, the reported case sensitivity in the query against
the location table, this is defined from the database that is used. So if
you would e.g. switch to mysql, all your queries would be case insensitive.
So i changed the bug title to be mirror this.
----------------------------------------------------------------------
Comment By: Asgaroth (asgaroth000)
Date: 2009-12-10 00:38
Message:
Just for further information, here is the logic in the main route of the
kamailio script that is causing the problem, I thought I would add it in so
you can see where I am trying to execute the update. The actual
authentication is processed prior to this section.
if (is_method("REGISTER"))
{
if (!save("location")) {
sl_reply_error();
} else {
xlog("L_INFO","Username: $au, FromUser: $fu,
OutboundProxy: $Ri, OutboundProxyPort: $Rp");
sql_query("bfl", "UPDATE location SET outboundproxy =
'$Ri', outboundproxyport = '$Rp' WHERE username = '$au'", "res");
}
exit;
}
----------------------------------------------------------------------
Comment By: Iñaki Baz Castillo (ibc_sf)
Date: 2009-12-10 00:19
Message:
According to RFC 3261 BNF grammar, the username part of a SIP URI is case
sensitive, this is:
sip:alice@domain.org != sip:Alice@domain.org
but domain part is case insensitive so:
sip:alice@domain.org == sip:alice@DOMain.ORG
So if 'usrloc' forces lowcase that's not correct (IMHO).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2911707&group_…
Module: sip-router
Branch: kamailio_3.0
Commit: 9d1f0c69a0ac832c00245ec92c2ec431c1241e97
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9d1f0c6…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Nov 16 19:41:02 2009 +0100
script engine: verbose conversion-to-int errors
- more verbose errors (all of them contain now the config file
position for the error).
- integer conversion errors will now by default log a warning
message. Like before they won't cause the expression evaluation
to fail, they'll just evaluate the failed conversion to 0.
The behaviour can be changed using the defines at the top of
rvalue.c. To restore the old behaviour (no int conversion error
message and error ignored), comment out the following defines:
RV_STR2INT_VERBOSE_ERR, RV_STRINT_ERR, EVAL_GET_INT_ERR_WARN,
RVAL_GET_INT_ERR_IGN. For more info see the comments in the
file.
(cherry picked from commit c744f71c858f34d41741d90e0d5cb05e48cf8016)
---
lvalue.c | 4 +-
rvalue.c | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 193 insertions(+), 41 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=9d1…