tcp: fix connection alias replacing
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Wed, 10 Oct 2012 08:02:00 +0000 (10:02 +0200)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Wed, 10 Oct 2012 08:18:32 +0000 (10:18 +0200)
When the TCP_ALIAS_REPLACE is set and an alias has to be added to
a connection that had 0 aliases (it can happen due to
TCP_ALIAS_REPLACE flag), the connection aliases count was wrongly
forced to 1.
For more details see:
http://lists.sip-router.org/pipermail/sr-users/2012-October/074932.html

Patch-by Jijo

tcp_main.c

index 2c4bf82..9d3359e 100644 (file)
@@ -1339,11 +1339,14 @@ int tcpconn_finish_connect( struct tcp_connection* c,
                        /* remove all the aliases except the first one and re-add them
                         * (there shouldn't be more then the 3 default aliases at this 
                         * stage) */
-                       for (r=1; r<c->aliases; r++){
-                               a=&c->con_aliases[r];
-                               tcpconn_listrm(tcpconn_aliases_hash[a->hash], a, next, prev);
+                       if (c->aliases > 1) {
+                               for (r=1; r<c->aliases; r++){
+                                       a=&c->con_aliases[r];
+                                       tcpconn_listrm(tcpconn_aliases_hash[a->hash],
+                                                                       a, next, prev);
+                               }
+                               c->aliases=1;
                        }
-                       c->aliases=1;
                        /* add the local_ip:0 and local_ip:local_port aliases */
                        _tcpconn_add_alias_unsafe(c, c->rcv.src_port, &c->rcv.dst_ip,
                                                                                                0, new_conn_alias_flags);