Hello,
what would be the drawback of having sip_msg being all the time in
shared memory? Would pkg vs shm operations have relevant impact?
From personal observations, most of the requests (over 95%) end in TM
module (to absorb retransmission or to forward) where the sip_msg s
moved to shm. It would make things simpler for tm callbacks and related
routes (no need to move back/forward from/to pkg/shm). Parsing will
happen always once, as now cloning to shm in tm discards some parsed
headers, which may be needed in failure route or callbacks.
Cheers,
Daniel
--
Daniel-Constantin Mierla
http://www.asipto.com/
Module: sip-router
Branch: master
Commit: 241112547835aef3f95f0bfeefcbaa6f22ddd3bc
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2411125…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri May 22 13:51:34 2009 +0200
makefile: fix new libs compilation on Mac OS X
Some of the new libraries (e.g. srdb*) use symbols from ser and on
Mac OS X / Darwin some special linker options are needed for this
to work.
Reported-by: Nils Ohlmeier <nils(a)iptel.org>
---
Makefile.defs | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index 1bead07..2c2f057 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -1614,7 +1614,9 @@ ifeq ($(OS), darwin)
# the modules uses symbols from ser => either
# -flat_namespace -undefined_suppress or -bundle_loader ../../$(MAIN_NAME)
MOD_LDFLAGS:= -bundle -flat_namespace -undefined suppress
- LIB_LDFLAGS:= -dynamiclib
+ # for libs using symbols from ser (e.g srdb2, kcore a.s.o) we
+ # need -flat_namespace -undefined suppress
+ LIB_LDFLAGS:= -dynamiclib -flat_namespace -undefined suppress
LIB_SUFFIX:=.dylib
# on darwin soname should include the full path
# (it kind of combines rpath & soname)
Module: sip-router
Branch: master
Commit: 97ce716082af99f49ba68bbfc97a8d8c17fbef56
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=97ce716…
Author: Andrei <andrei(a)eagain.office.iptelorg.de>
Committer: Andrei <andrei(a)eagain.office.iptelorg.de>
Date: Fri May 22 12:50:40 2009 +0200
runtime cfg: fix sanity check on 64 bits
The sanity check for registered cfg_group_* structures and
cfg_defs was wrong on 64 bits systems when the structures
contained pointers (the possible structure padding was not taken
into account).
Fix: if the structure contains strings (CFG_VAR_STR or
CFG_VAR_STRING) or pointers (CFG_VAR_POINTER), round-up the
computed size to sizeof(pointer), before performing the sanity
check.
---
cfg/cfg.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/cfg/cfg.c b/cfg/cfg.c
index d6b803b..acc0ea3 100644
--- a/cfg/cfg.c
+++ b/cfg/cfg.c
@@ -47,6 +47,7 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
{
int i, num, size, group_name_len;
cfg_mapping_t *mapping = NULL;
+ int types;
/* check the number of the variables */
for (num=0; def[num].name; num++);
@@ -57,13 +58,15 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
goto error;
}
memset(mapping, 0, sizeof(cfg_mapping_t)*num);
-
+ types=0;
/* calculate the size of the memory block that has to
be allocated for the cfg variables, and set the content of the
cfg_mapping array the same time */
for (i=0, size=0; i<num; i++) {
mapping[i].def = &(def[i]);
mapping[i].name_len = strlen(def[i].name);
+ /* record all the types for sanity checks */
+ types|=CFG_VAR_MASK(def[i].type);
/* padding depends on the type of the next variable */
switch (CFG_VAR_MASK(def[i].type)) {
@@ -128,6 +131,10 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
}
}
+ /* fix the computed size (char*, str or pointer members will force
+ structure padding to multiple of sizeof(pointer)) */
+ if (types & (CFG_VAR_STRING|CFG_VAR_STR|CFG_VAR_POINTER))
+ size=ROUND_POINTER(size);
/* minor validation */
if (size != def_size) {
LOG(L_ERR, "ERROR: register_cfg_def(): the specified size (%i) of the config "
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
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: e5064a814654a71dc2aa28c5fe2bd6fbba76e62c
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e5064a8…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu May 21 15:41:16 2009 +0000
sctp: compatibility with older linux kernels
- try hard to workaround compatibility problems between lksctp
userspace (sctp.h) and kernel side: older kernelsi (<2.6.26)
expect a certain size for the sctp_event_subscribe structure
(SCTP_EVENTS sock. opt), leading to problems when using newer
lksctp userspace (>=1.0.9) which adds an additional member to
the structure => if the SCTP_EVENTS setsockopt() fails, try with
different sizes (since we don't care about authentication events
anyway).
- failure to enable SCTP_EVENTS upgraded to critical: ser will not
start.
---
sctp_server.c | 62 +++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 49 insertions(+), 13 deletions(-)
diff --git a/sctp_server.c b/sctp_server.c
index 424def8..d559ce3 100644
--- a/sctp_server.c
+++ b/sctp_server.c
@@ -193,14 +193,27 @@ error:
WARNING: please keep it sync'ed w/ sctp_check_compiled_sockopts() */
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;
+#ifdef __OS_linux
+ union {
+ struct sctp_event_subscribe s;
+ char padding[sizeof(struct sctp_event_subscribe)+sizeof(__u8)];
+ } es;
+#else
+ struct sctp_event_subscribe es;
+#endif
+ struct sctp_event_subscribe* ev_s;
sctp_err=0;
+#ifdef __OS_linux
+ ev_s=&es.s;
+#else
+ ev_s=&es;
+#endif
/* set tos */
optval = tos;
if (setsockopt(s, IPPROTO_IP, IP_TOS, (void*)&optval,sizeof(optval)) ==-1){
@@ -349,27 +362,50 @@ static int sctp_init_sock_opt_common(int s)
memset(&es, 0, sizeof(es));
/* SCTP_EVENTS for SCTP_SNDRCV (sctp_data_io_event) -> per message
* information in sctp_sndrcvinfo */
- es.sctp_data_io_event=1;
+ ev_s->sctp_data_io_event=1;
/* enable association event notifications */
- es.sctp_association_event=1; /* SCTP_ASSOC_CHANGE */
- es.sctp_address_event=1; /* enable address events notifications */
- es.sctp_send_failure_event=1; /* SCTP_SEND_FAILED */
- es.sctp_peer_error_event=1; /* SCTP_REMOTE_ERROR */
- es.sctp_shutdown_event=1; /* SCTP_SHUTDOWN_EVENT */
- es.sctp_partial_delivery_event=1; /* SCTP_PARTIAL_DELIVERY_EVENT */
- /* es.sctp_adaptation_layer_event=1; - not supported by lksctp<=1.0.6*/
- /* es.sctp_authentication_event=1; -- not supported on linux 2.6.25 */
+ ev_s->sctp_association_event=1; /* SCTP_ASSOC_CHANGE */
+ ev_s->sctp_address_event=1; /* enable address events notifications */
+ ev_s->sctp_send_failure_event=1; /* SCTP_SEND_FAILED */
+ ev_s->sctp_peer_error_event=1; /* SCTP_REMOTE_ERROR */
+ ev_s->sctp_shutdown_event=1; /* SCTP_SHUTDOWN_EVENT */
+ ev_s->sctp_partial_delivery_event=1; /* SCTP_PARTIAL_DELIVERY_EVENT */
+ /* ev_s->sctp_adaptation_layer_event=1; - not supported by lksctp<=1.0.6*/
+ /* ev_s->sctp_authentication_event=1; -- not supported on linux 2.6.25 */
/* enable the SCTP_EVENTS */
#ifdef SCTP_EVENTS
- if (setsockopt(s, IPPROTO_SCTP, SCTP_EVENTS, &es, sizeof(es))==-1){
+ if (setsockopt(s, IPPROTO_SCTP, SCTP_EVENTS, ev_s, sizeof(*ev_s))==-1){
+ /* on linux the checks for the struct sctp_event_subscribe size
+ are too strict, making certain lksctp/kernel combination
+ unworkable => since we don't use the extra information
+ (sctp_authentication_event) added in newer version, we can
+ try with different sizes) */
+#ifdef __OS_linux
+ /* 1. lksctp 1.0.9 with kernel < 2.6.26 -> kernel expects
+ the structure without the authentication event member */
+ if (setsockopt(s, IPPROTO_SCTP, SCTP_EVENTS, ev_s, sizeof(*ev_s)-1)==0)
+ goto ev_success;
+ /* 2. lksctp < 1.0.9? with kernel >= 2.6.26: the sctp.h structure
+ does not have the authentication member, but the newer kernels
+ check only for optlen > sizeof(...) => we should never reach
+ this point. */
+ /* 3. just to be foolproof if we reached this point, try
+ with a bigger size before giving up (out of desperation) */
+ if (setsockopt(s, IPPROTO_SCTP, SCTP_EVENTS, ev_s, sizeof(es))==0)
+ goto ev_success;
+
+#endif
LOG(L_ERR, "ERROR: sctp_init_sock_opt_common: setsockopt: "
"SCTP_EVENTS: %s\n", strerror(errno));
sctp_err++;
- /* non critical, try to continue */
+ goto error; /* critical */
}
+#ifdef __OS_linux
+ev_success:
+#endif
#else
-#warning no sctp lib support for SCTP_EVENTS, consider upgrading
+#error no sctp lib support for SCTP_EVENTS, consider upgrading
#endif /* SCTP_EVENTS */
if (sctp_err){
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;