Re: [bug] PJSIP 2.5.5 with PJ_HAS_IPV6=1: pjsip_endpt_create_resolver failed on system without IPv6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alexei,

Thank you for the report. The bug sounds valid, unfortunately I could not reproduce the issue on Windows 10 and Linux, have tried to manually disable IPv6 but still init_sock() did not fail (perhaps IPv6 loopback interface is still up). So I am afraid we'd need some more help to test the attached patch, thanks again in advance.

BR,
nanang


On Wed, Aug 10, 2016 at 4:20 AM, Alexei Gradinari <alex2grad@xxxxxxxxx> wrote:
Hello,

The function init_sock at pjlib-util/src/pjlib-util/resolver.c
should check if the IPv6 is available instead of return an error.

Regards,
Alexei


_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Index: pjlib/include/pj/compat/socket.h
===================================================================
--- pjlib/include/pj/compat/socket.h	(revision 5417)
+++ pjlib/include/pj/compat/socket.h	(working copy)
@@ -158,16 +158,19 @@
 #  define OSERR_EINPROGRESS    WSAEINPROGRESS
 #  define OSERR_ECONNRESET     WSAECONNRESET
 #  define OSERR_ENOTCONN       WSAENOTCONN
+#  define OSERR_EAFNOSUPPORT   WSAEAFNOSUPPORT
 #elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
 #  define OSERR_EWOULDBLOCK    -1
 #  define OSERR_EINPROGRESS    -1
 #  define OSERR_ECONNRESET     -1
 #  define OSERR_ENOTCONN       -1
+#  define OSERR_EAFNOSUPPORT   -1
 #else
 #  define OSERR_EWOULDBLOCK    EWOULDBLOCK
 #  define OSERR_EINPROGRESS    EINPROGRESS
 #  define OSERR_ECONNRESET     ECONNRESET
 #  define OSERR_ENOTCONN       ENOTCONN
+#  define OSERR_EAFNOSUPPORT   EAFNOSUPPORT
 #endif
 
 
Index: pjlib-util/src/pjlib-util/resolver.c
===================================================================
--- pjlib-util/src/pjlib-util/resolver.c	(revision 5417)
+++ pjlib-util/src/pjlib-util/resolver.c	(working copy)
@@ -19,6 +19,7 @@
  */
 #include <pjlib-util/resolver.h>
 #include <pjlib-util/errno.h>
+#include <pj/compat/socket.h>
 #include <pj/assert.h>
 #include <pj/ctype.h>
 #include <pj/except.h>
@@ -309,8 +310,15 @@
     /* Create the UDP socket */
     status = pj_sock_socket(pj_AF_INET6(), pj_SOCK_DGRAM(), 0,
 			    &resv->udp6_sock);
-    if (status != PJ_SUCCESS)
+    if (status != PJ_SUCCESS) {
+	/* Don't return error if the system doesn't support IPv6 */
+	if (status == PJ_STATUS_FROM_OS(OSERR_EAFNOSUPPORT)) {
+	    PJ_LOG(3,(resv->name.ptr,
+		      "Warning: failed to create IPv6 socket"));
+	    return PJ_SUCCESS;
+	}
 	return status;
+    }
 
     /* Bind to any address/port */
     pj_sockaddr_init(pj_AF_INET6(), &bound_addr, NULL, 0);
@@ -685,8 +693,9 @@
     /* Check if the socket is available for sending */
     if (pj_ioqueue_is_pending(resolver->udp_key, &resolver->udp_op_tx_key)
 #if PJ_HAS_IPV6
-	|| pj_ioqueue_is_pending(resolver->udp6_key,
-				 &resolver->udp6_op_tx_key)
+	|| (resolver->udp6_key &&
+	    pj_ioqueue_is_pending(resolver->udp6_key,
+				  &resolver->udp6_op_tx_key))
 #endif
 	)
     {
@@ -727,12 +736,14 @@
 				       pj_sockaddr_get_len(&ns->addr));
 	}
 #if PJ_HAS_IPV6
-	else {
+	else if (resolver->udp6_key) {
 	    status = pj_ioqueue_sendto(resolver->udp6_key,
 				       &resolver->udp6_op_tx_key,
 				       resolver->udp_tx_pkt, &sent, 0,
 				       &ns->addr,
 				       pj_sockaddr_get_len(&ns->addr));
+	} else {
+	    continue;
 	}
 #endif
 
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux