internal/socket, ipv4, ipv6: add support for GOOS=illumos

Treat it like GOOS=solaris for now.

Change-Id: I2b99427e80058f6c7308fe3752de21610457a3ba
Reviewed-on: https://go-review.googlesource.com/c/net/+/183277
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
diff --git a/internal/socket/sys_posix.go b/internal/socket/sys_posix.go
index 24fbb69..22eae80 100644
--- a/internal/socket/sys_posix.go
+++ b/internal/socket/sys_posix.go
@@ -33,7 +33,7 @@
 	if ip4 := ip.To4(); ip4 != nil {
 		b := make([]byte, sizeofSockaddrInet)
 		switch runtime.GOOS {
-		case "android", "linux", "solaris", "windows":
+		case "android", "illumos", "linux", "solaris", "windows":
 			NativeEndian.PutUint16(b[:2], uint16(sysAF_INET))
 		default:
 			b[0] = sizeofSockaddrInet
@@ -46,7 +46,7 @@
 	if ip6 := ip.To16(); ip6 != nil && ip.To4() == nil {
 		b := make([]byte, sizeofSockaddrInet6)
 		switch runtime.GOOS {
-		case "android", "linux", "solaris", "windows":
+		case "android", "illumos", "linux", "solaris", "windows":
 			NativeEndian.PutUint16(b[:2], uint16(sysAF_INET6))
 		default:
 			b[0] = sizeofSockaddrInet6
@@ -68,7 +68,7 @@
 	}
 	var af int
 	switch runtime.GOOS {
-	case "android", "linux", "solaris", "windows":
+	case "android", "illumos", "linux", "solaris", "windows":
 		af = int(NativeEndian.Uint16(b[:2]))
 	default:
 		af = int(b[1])
diff --git a/ipv4/multicast_test.go b/ipv4/multicast_test.go
index 150e21a..332a1da 100644
--- a/ipv4/multicast_test.go
+++ b/ipv4/multicast_test.go
@@ -29,7 +29,7 @@
 
 func TestPacketConnReadWriteMulticastUDP(t *testing.T) {
 	switch runtime.GOOS {
-	case "fuchsia", "hurd", "js", "nacl", "plan9", "solaris", "windows":
+	case "fuchsia", "hurd", "illumos", "js", "nacl", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %s", runtime.GOOS)
 	}
 	ifi, err := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback)
@@ -117,7 +117,7 @@
 
 func TestPacketConnReadWriteMulticastICMP(t *testing.T) {
 	switch runtime.GOOS {
-	case "fuchsia", "hurd", "js", "nacl", "plan9", "solaris", "windows":
+	case "fuchsia", "hurd", "illumos", "js", "nacl", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %s", runtime.GOOS)
 	}
 	if !nettest.SupportsRawSocket() {
@@ -167,8 +167,8 @@
 			t.Fatal(err)
 		}
 		cf := ipv4.FlagDst | ipv4.FlagInterface
-		if runtime.GOOS != "solaris" {
-			// Solaris never allows to modify ICMP properties.
+		if runtime.GOOS != "illumos" && runtime.GOOS != "solaris" {
+			// Illumos and Solaris never allow modification of ICMP properties.
 			cf |= ipv4.FlagTTL
 		}
 
@@ -228,7 +228,7 @@
 
 func TestRawConnReadWriteMulticastICMP(t *testing.T) {
 	switch runtime.GOOS {
-	case "fuchsia", "hurd", "js", "nacl", "plan9", "solaris", "windows":
+	case "fuchsia", "hurd", "illumos", "js", "nacl", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %s", runtime.GOOS)
 	}
 	if testing.Short() {
diff --git a/ipv4/unicast_test.go b/ipv4/unicast_test.go
index 1c105c7..629542b 100644
--- a/ipv4/unicast_test.go
+++ b/ipv4/unicast_test.go
@@ -93,8 +93,8 @@
 	p := ipv4.NewPacketConn(c)
 	defer p.Close()
 	cf := ipv4.FlagDst | ipv4.FlagInterface
-	if runtime.GOOS != "solaris" {
-		// Solaris never allows to modify ICMP properties.
+	if runtime.GOOS != "illumos" && runtime.GOOS != "solaris" {
+		// Illumos and Solaris never allow modification of ICMP properties.
 		cf |= ipv4.FlagTTL
 	}
 
diff --git a/ipv6/multicast_test.go b/ipv6/multicast_test.go
index 0bf4322..d291c1f 100644
--- a/ipv6/multicast_test.go
+++ b/ipv6/multicast_test.go
@@ -205,9 +205,9 @@
 			if toggle {
 				psh = nil
 				if err := p.SetChecksum(true, 2); err != nil {
-					// Solaris never allows to
-					// modify ICMP properties.
-					if runtime.GOOS != "solaris" {
+					// Illumos and Solaris never allow
+					// modification of ICMP properties.
+					if runtime.GOOS != "illumos" && runtime.GOOS != "solaris" {
 						t.Fatal(err)
 					}
 				}
diff --git a/ipv6/unicast_test.go b/ipv6/unicast_test.go
index bb353ee..50cb2ae 100644
--- a/ipv6/unicast_test.go
+++ b/ipv6/unicast_test.go
@@ -124,9 +124,11 @@
 		if toggle {
 			psh = nil
 			if err := p.SetChecksum(true, 2); err != nil {
-				// AIX and Solaris never allow to modify
-				// ICMP properties.
-				if runtime.GOOS != "aix" && runtime.GOOS != "solaris" {
+				// AIX, Illumos and Solaris never allow
+				// modification of ICMP properties.
+				switch runtime.GOOS {
+				case "aix", "illumos", "solaris":
+				default:
 					t.Fatal(err)
 				}
 			}