Module Name:    src
Committed By:   elad
Date:           Wed Apr 22 18:35:02 UTC 2009

Modified Files:
        src/sys/netinet6: in6_pcb.c

Log Message:
Only check if the port is used if it was specified.

Should fix problem reported in

    http://mail-index.netbsd.org/current-users/2009/04/22/msg009130.html


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/netinet6/in6_pcb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet6/in6_pcb.c
diff -u src/sys/netinet6/in6_pcb.c:1.105 src/sys/netinet6/in6_pcb.c:1.106
--- src/sys/netinet6/in6_pcb.c:1.105	Mon Apr 20 19:57:18 2009
+++ src/sys/netinet6/in6_pcb.c	Wed Apr 22 18:35:01 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_pcb.c,v 1.105 2009/04/20 19:57:18 elad Exp $	*/
+/*	$NetBSD: in6_pcb.c,v 1.106 2009/04/22 18:35:01 elad Exp $	*/
 /*	$KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.105 2009/04/20 19:57:18 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.106 2009/04/22 18:35:01 elad Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -298,27 +298,29 @@
 			reuseport = SO_REUSEADDR|SO_REUSEPORT;
 	}
 
-	if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
+	if (sin6->sin6_port != 0) {
+		if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
 #ifdef INET
-		struct inpcb *t;
+			struct inpcb *t;
 
-		t = in_pcblookup_port(table,
-		    *(struct in_addr *)&sin6->sin6_addr.s6_addr32[3],
-		    sin6->sin6_port, wild);
-		if (t && (reuseport & t->inp_socket->so_options) == 0)
-			return (EADDRINUSE);
+			t = in_pcblookup_port(table,
+			    *(struct in_addr *)&sin6->sin6_addr.s6_addr32[3],
+			    sin6->sin6_port, wild);
+			if (t && (reuseport & t->inp_socket->so_options) == 0)
+				return (EADDRINUSE);
 #else
-		return (EADDRNOTAVAIL);
+			return (EADDRNOTAVAIL);
 #endif
-	}
+		}
 
-	{
-		struct in6pcb *t;
+		{
+			struct in6pcb *t;
 
-		t = in6_pcblookup_port(table, &sin6->sin6_addr,
-		    sin6->sin6_port, wild);
-		if (t && (reuseport & t->in6p_socket->so_options) == 0)
-			return (EADDRINUSE);
+			t = in6_pcblookup_port(table, &sin6->sin6_addr,
+			    sin6->sin6_port, wild);
+			if (t && (reuseport & t->in6p_socket->so_options) == 0)
+				return (EADDRINUSE);
+		}
 	}
 
 	if (sin6->sin6_port == 0) {

Reply via email to