Module: sip-router
Branch: ser_core_cvs
Commit: f9437a7d00b7eb8fcfa7facec9a3c90555fc7901
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f9437a7…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu May 21 15:24:57 2009 +0000
sctp: fix partial delivery point setting on linux
To disable partial delivery, the partial delivery point should be
set to the socket receive buffer size. However on linux SO_RCVBUF
will return twice the value (the "real" value, which is twice the
value used when setting SO_RCVBUF) and SCTP_PARTIAL_DELIVERY_POINT
expects value/2.
---
sctp_server.c | 33 ++++++++++++++++++++++++++++-----
1 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/sctp_server.c b/sctp_server.c
index 077947d..424def8 100644
--- a/sctp_server.c
+++ b/sctp_server.c
@@ -195,6 +195,8 @@ static int sctp_init_sock_opt_common(int s)
{
struct sctp_event_subscribe es;
int optval;
+ int pd_point;
+ int saved_errno;
socklen_t optlen;
int sctp_err;
@@ -267,13 +269,34 @@ static int sctp_init_sock_opt_common(int s)
/* try to continue */
optval=0;
}
- if (setsockopt(s, IPPROTO_SCTP, SCTP_PARTIAL_DELIVERY_POINT,
- (void*)&optval, sizeof(optval)) ==-1){
- LOG(L_ERR, "ERROR: sctp_init_sock_opt_common: setsockopt: "
+#ifdef __OS_linux
+ optval/=2; /* in linux getsockopt() returns twice the set value */
+#endif
+ pd_point=optval;
+ saved_errno=0;
+ while(pd_point &&
+ setsockopt(s, IPPROTO_SCTP, SCTP_PARTIAL_DELIVERY_POINT,
+ (void*)&pd_point, sizeof(pd_point)) ==-1){
+ if (!saved_errno)
+ saved_errno=errno;
+ pd_point--;
+ }
+
+ if (pd_point!=optval){
+ if (pd_point==0){
+ /* all attempts failed */
+ LOG(L_ERR, "ERROR: sctp_init_sock_opt_common: setsockopt: "
"SCTP_PARTIAL_DELIVERY_POINT (%d): %s\n",
optval, strerror(errno));
- sctp_err++;
- /* try to continue */
+ sctp_err++;
+ /* try to continue */
+ }else{
+ /* success but to a lower value (might not be disabled) */
+ LOG(L_WARN, "setsockopt SCTP_PARTIAL_DELIVERY_POINT set to %d, but"
+ " the socket rcvbuf is %d (higher values fail with"
+ " \"%s\" [%d])\n",
+ pd_point, optval, strerror(saved_errno), saved_errno);
+ }
}
#else
#warning no sctp lib support for SCTP_PARTIAL_DELIVERY_POINT, consider upgrading
Module: sip-router
Branch: ser_core_cvs
Commit: 71eae780d57f486e27fa946ff603da1e89fb2839
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=71eae78…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu May 21 15:24:15 2009 +0000
tcp: typo fixes when blacklisting on error
- because of a '=' instead of a '==' a tcp connection that failed
after some time was always blacklisted with BLST_ERR_CONNECT
(even in cases when BLST_ERR_SEND should have been used).
- same thing for blacklisting on read failure.
Reported-by: Libor Chocholaty <libor(a)iptel.org>
---
tcp_main.c | 2 +-
tcp_read.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tcp_main.c b/tcp_main.c
index 21c4c80..7a9b52e 100644
--- a/tcp_main.c
+++ b/tcp_main.c
@@ -3498,7 +3498,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
tcpconn);
}
if (unlikely(ev & POLLERR)){
- if (unlikely(tcpconn->state=S_CONN_CONNECT)){
+ if (unlikely(tcpconn->state==S_CONN_CONNECT)){
#ifdef USE_DST_BLACKLIST
if (cfg_get(core, core_cfg, use_dst_blacklist))
dst_blacklist_su(BLST_ERR_CONNECT, tcpconn->rcv.proto,
diff --git a/tcp_read.c b/tcp_read.c
index ab69242..7d45d53 100644
--- a/tcp_read.c
+++ b/tcp_read.c
@@ -149,7 +149,7 @@ again:
bytes_read=0; /* nothing has been read */
}else if (errno == EINTR) goto again;
else{
- if (unlikely(c->state=S_CONN_CONNECT)){
+ if (unlikely(c->state==S_CONN_CONNECT)){
switch(errno){
case ECONNRESET:
#ifdef USE_DST_BLACKLIST
Hi,
while testing TLS at SIPit 24 I encoutered the following problem:
Two UAs were successfully registered via TLS connections and they had
Contacts with just IP addresses and the transport parameter set to TLS.
If one UA tried to call the other the INVITE was rejected by the TM
module with the following log message:
ERROR: uri2dst: bad transport for sips uri: 3
So when I looked up which is transport 3 I was surprised to see the 3 is
actually TLS. Which is absolutely the right transport for a SIPS URI.
The if condition before this error message checks if the transport is
equal to TCP. This makes no sense to me.
Thus I assume that this if condition was just a typo and created the
attached patch which fixes this issue in 3 places in ut.h.
Please let me know if I can commit the attached patch.
Cheers
Nils
Index: ut.h
===================================================================
RCS file: /cvsroot/ser/sip_router/modules/tm/ut.h,v
retrieving revision 1.26
diff -a -u -r1.26 ut.h
--- ut.h 11 Aug 2008 17:41:16 -0000 1.26
+++ ut.h 21 May 2009 08:13:24 -0000
@@ -123,7 +123,7 @@
}
if (parsed_uri.type==SIPS_URI_T){
- if ((parsed_uri.proto!=PROTO_TCP) && (parsed_uri.proto!=PROTO_NONE)){
+ if ((parsed_uri.proto!=PROTO_TLS) && (parsed_uri.proto!=PROTO_NONE)){
LOG(L_ERR, "ERROR: uri2proxy: bad transport for sips uri: %d\n",
parsed_uri.proto);
return 0;
@@ -181,7 +181,7 @@
}
if (parsed_uri.type==SIPS_URI_T){
- if ((parsed_uri.proto!=PROTO_TCP) && (parsed_uri.proto!=PROTO_NONE)){
+ if ((parsed_uri.proto!=PROTO_TLS) && (parsed_uri.proto!=PROTO_NONE)){
LOG(L_ERR, "ERROR: get_uri_send_info: bad transport for"
" sips uri: %d\n", parsed_uri.proto);
return -1;
@@ -254,7 +254,7 @@
}
if (parsed_uri.type==SIPS_URI_T){
- if ((parsed_uri.proto!=PROTO_TCP) && (parsed_uri.proto!=PROTO_NONE)){
+ if ((parsed_uri.proto!=PROTO_TLS) && (parsed_uri.proto!=PROTO_NONE)){
LOG(L_ERR, "ERROR: uri2dst: bad transport for sips uri: %d\n",
parsed_uri.proto);
return 0;
Hi all,
during my tests for the cr module i noticed some differences in the reply
matching in sr tm and kamailio tm. My test "26" basically test the (cr)
failure_route functionality with a simple sipp scenario.
On kamailio 1.5 branch my test is successful, the 503 reply is matched against
the first INVITE and the failure_route is entered. On sip-router its not
matched, a local 408 is generated after some time. I've attached the sip trace
and the debug logs from both tests runs.
Perhaps the sip-router tm is more strict in the matching, so because of some
problem in the sipp scenario it don't match? Would be cool if somebody with
more experiences with sr tm could take a look to this. The scenario,
configuration and test is test/unit/failure_route.xml, 26.cfg and 26.sh (same
directory).
Thanks,
Henning
Hello,
I just introduced support for a new type of route in configuration file
- event_route. The prototype for it is:
event_route[groupid:eventid] {
[actions]
}
The main purpose for it is to allow modules (and core) to be able to
execute code written in configuration file when a specific event
happens, without altering the config grammar. Also, in short term, the
modules that fire events should be able to impose what type of actions
can be used in the respective event_route - now functions allowed in
request route can be used.
First module that uses this feature is htable, executing an event route
only once, when all modules were initialized. A typical use case is to
initialize some items in a hash table. Example:
modparam("htable", "htable", "a=>size=4;")
event_route[htable:mod-init] {
$sht(a=>calls-to::10.10.10.10) = 0;
$sht(a=>max-calls-to::10.10.10.10) = 100;
}
route {
if(is_method("INVITE") && !has_totag())
{
switch($rd) {
case "10.10.10.10":
lock("calls-to::10.10.10.10");
$sht(a=>calls-to::10.10.10.10) =
$sht(a=>calls-to::10.10.10.10) + 1;
unlock("calls-to::10.10.10.10");
if($sht(a=>calls-to::10.10.10.10)>$sht(a=>max-calls-to::10.10.10.10))
{
sl_send_reply("500", "To many calls to .10");
exit;
}
break;
...
}
}
}
This system will be used to get kamailio's error_route and local_route
functionalities. Other cases I have in mind now are:
- auto-expired dialog route introduced in kamailio 1.5.0 to become
event_route[dialog:auto-expired]
- call event route when a location record has expired on timer:
event_route[usrloc:auto-expired] making available via PV details of
expired contact
- rtimer module routes to become event routes
Cheers,
Daniel
--
Daniel-Constantin Mierla
http://www.asipto.com/