Skip to content

Commit

Permalink
internal/socket, ipv4, ipv6: add support for GOOS=illumos
Browse files Browse the repository at this point in the history
Treat it like GOOS=solaris for now.

Change-Id: I2b99427e80058f6c7308fe3752de21610457a3ba
Reviewed-on: https://go-review.googlesource.com/c/net/+/183277
Run-TryBot: Tobias Klauser <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Matt Layher <[email protected]>
  • Loading branch information
tklauser committed Jun 20, 2019
1 parent b5b0513 commit 3b0461e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions internal/socket/sys_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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])
Expand Down
10 changes: 5 additions & 5 deletions ipv4/multicast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions ipv4/unicast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions ipv6/multicast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
8 changes: 5 additions & 3 deletions ipv6/unicast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 3b0461e

Please sign in to comment.