core: don't force a socket if the dst af is different
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Wed, 15 Oct 2008 14:13:56 +0000 (14:13 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Wed, 15 Oct 2008 14:13:56 +0000 (14:13 +0000)
- get_send_socket() will now ignore a forced send socket if the destination
 address family is different from the forced socket (e.g. force ipv6 but
 attempt to send to ipv4). A non-obvious example of a scenario triggering
 this bug is registering over ipv4 an ipv6 contact.
 Reported by: Nils Ohlmeier <nils@iptel.org>

forward.c

index 7b60358..9055347 100644 (file)
--- a/forward.c
+++ b/forward.c
@@ -175,6 +175,12 @@ struct socket_info* get_send_socket(struct sip_msg *msg,
                                goto not_forced;
                        }
                }
+               if (unlikely(msg->force_send_socket->address.af!=to->s.sa_family)){
+                       DBG("get_send_socket: force_send_socket of different af (dst %d,"
+                                       " forced %d)\n",
+                                       to->s.sa_family, msg->force_send_socket->address.af);
+                       goto not_forced;
+               }
                if (likely((msg->force_send_socket->socket!=-1) &&
                                        !(msg->force_send_socket->flags & SI_IS_MCAST)))
                                return msg->force_send_socket;