Hello,
quickly checking the code it seems that the dst_ip is holding the local address always, even for outbound connection.
Not being the author of the code, my guess is that the lookup of connection is done always on src_ip matching the remote peer address. Also, the structure used there is the one specific for holding received info for sip packets.
The output is somehow misleading, maybe the fields should be renamed to local_ip/port and remote_ip/port in the output of the rpc commands.
Cheers, Daniel
On 03/06/15 20:27, Mikko Lehto wrote:
Hi, I noticed thath command core.tcp_list in kamcmd gives output that does not make sense to me:
kamcmd> core.tcp_list { id: 1 type: TLS state: CONN_OK timeout: 3599 ref_count: 1 src_ip: 192.168.47.132 src_port: 5061 dst_ip: 10.10.235.9 dst_port: 54769 } { id: 2 type: TLS state: CONN_OK timeout: 3599 ref_count: 1 src_ip: 192.168.47.132 src_port: 32854 dst_ip: 10.10.235.9 dst_port: 5041 }
In my scenario I am connecting via TLS to host 192.168.47.132:5061. And host 192.168.47.132 is connecting to my proxy host 10.10.235.9:5041. pcap verifies this. Also tls.list gives similar output.
Values regarding incoming connection (id=2) makes total sense. It seems that values regarding outgoing connection (id=1) have dst_* values swapped with src_* values.
To debug, I placed this logging to tcp_main.c:
$ git diff tcp_main.c diff --git a/tcp_main.c b/tcp_main.c index 5830c8e..3717cf6 100644 --- a/tcp_main.c +++ b/tcp_main.c @@ -1207,6 +1207,7 @@ again: } from=&my_name; /* update from with the real "from" address */ su2ip_addr(&ip, &my_name);
su2a(&my_name, sizeof(my_name)), su2a(server, sizeof(*server)), ip_addr2a(&ip));LM_WARN("after getsockname() my_name=%s server=%s ip=%s\n",
find_socket: #ifdef USE_TLS if (unlikely(type==PROTO_TLS)) @@ -1223,6 +1224,7 @@ find_socket: else *res_si=sendipv6_tcp; } *res_local_addr=*from;
su2a(&my_name, sizeof(my_name)), su2a(server, sizeof(*server)), ip_addr2a(&ip)); return s;LM_WARN("before return my_name=%s server=%s ip=%s\n",
error: if (s!=-1) tcp_safe_close(s);
This gives following output: WARNING: <core> [tcp_main.c:1210]: tcp_do_connect(): after getsockname() my_name=192.168.47.132:5061 server=192.168.47.132:5061 ip=10.10.235.9 WARNING: <core> [tcp_main.c:1227]: tcp_do_connect(): before return my_name=192.168.47.132:5061 server=192.168.47.132:5061 ip=10.10.235.9
Are tcp endpoint values really wrong way around or did I undertand something wrong about their meaning?
I am running Kamailio 4.2.5 (x86_64/linux) 61d84c-dirty from git.