# HG changeset patch
# User fw@deneb.enyo.de
# Date 1282471319 -7200
# Node ID d68478aa6899b45b119c044ed8f819fe5cb8bd30
# Parent  c6b2f56925705655af802e6093072b63bbf86486
Allow IPv4 on IPv6 sockets

--- a/src/pkg/net/sock.go
+++ b/src/pkg/net/sock.go
@@ -30,6 +30,15 @@ func socket(net string, f, t, p int, la,
 
 	setDefaultSockopts(s, f, t)
 
+	// Allow IPv4 on IPv6 sockets.
+	if f == syscall.AF_INET6 {
+		err = syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0)
+		if err != nil {
+			closesocket(s)
+			return nil, err
+		}
+	}
+
 	if la != nil {
 		err = syscall.Bind(s, la)
 		if err != nil {
