From 3b0461eec859c4b73bb64fdc8285971fd33e3938 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 20 Jun 2019 21:42:36 +0200 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Matt Layher --- internal/socket/sys_posix.go | 6 +++--- ipv4/multicast_test.go | 10 +++++----- ipv4/unicast_test.go | 4 ++-- ipv6/multicast_test.go | 6 +++--- ipv6/unicast_test.go | 8 +++++--- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/internal/socket/sys_posix.go b/internal/socket/sys_posix.go index 24fbb6967..22eae809c 100644 --- a/internal/socket/sys_posix.go +++ b/internal/socket/sys_posix.go @@ -33,7 +33,7 @@ func marshalSockaddr(ip net.IP, port int, zone string) []byte { 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 @@ func marshalSockaddr(ip net.IP, port int, zone string) []byte { 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 @@ func parseInetAddr(b []byte, network string) (net.Addr, error) { } 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 150e21aa8..332a1da8e 100644 --- a/ipv4/multicast_test.go +++ b/ipv4/multicast_test.go @@ -29,7 +29,7 @@ var packetConnReadWriteMulticastUDPTests = []struct { 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 @@ var packetConnReadWriteMulticastICMPTests = []struct { 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 @@ func TestPacketConnReadWriteMulticastICMP(t *testing.T) { 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 @@ var rawConnReadWriteMulticastICMPTests = []struct { 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 1c105c704..629542bc2 100644 --- a/ipv4/unicast_test.go +++ b/ipv4/unicast_test.go @@ -93,8 +93,8 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) { 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 0bf432266..d291c1f8c 100644 --- a/ipv6/multicast_test.go +++ b/ipv6/multicast_test.go @@ -205,9 +205,9 @@ func TestPacketConnReadWriteMulticastICMP(t *testing.T) { 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 bb353eea4..50cb2ae94 100644 --- a/ipv6/unicast_test.go +++ b/ipv6/unicast_test.go @@ -124,9 +124,11 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) { 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) } }