[OpenSIPS-Devel] Strange behavior for SIP over TCP

Emmanuel BUU emmanuel.buu at ives.fr
Fri Jan 13 00:15:27 CET 2012


Hello,

We are using opensips 1.5.3 on a multi-homed system. This system has 
three IP address"z

1- one public IP address on the Internet
2- one private IP address provided by a client open vpn connection.
3- another private IP address as open vpn server.

When using SIP over TCP to reach another SIP system on the Internet, 
fails to open new outbound TCP connections.
For instance,

UAC ----> opensips proxy ----> other SIP system

if we setup a static route (using t_relay('tcp:othersystem') to the 
other system, it fails to relay the INVITE packet from opensips proxy to 
the outside sysem

A wireshark capture shows that the source address of the TCP packet SYN 
using is in fact a _private address_.

I looked at the code of

struct tcp_connection* tcpconn_connect(struct socket_info* send_sock, 
union sockaddr_union* server, int type) in tcp_main.c

and I wonder why we bind the socket to the selected out_socket rather 
than let the operating system select the proper IP address?

         my_name_len = sockaddru_len(send_sock->su);
         memcpy( &my_name, &send_sock->su, my_name_len);
         su_setport( &my_name, 0);
         if (bind(s, &my_name.s, my_name_len )!=0) {
                 LM_ERR("bind failed (%d) %s\n", errno,strerror(errno));
                 goto error;
         }

I looked at the code of get_send_socket() in foward.c and in case of 
tcp, it seems that we select the "main IP address" which value is 
determined at startup in main.c
In case of multihomed system, the value of this "main Ip address" seems 
not to be deterministc.

As a conclution:  would it  hurt if we would remove the bind() call from 
tcpconn_connect() ?

Emmanuel BUU
IVèS
http://www.ives.fr/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20120113/da390889/attachment.htm>


More information about the Devel mailing list