summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikio Hara <mikioh.public.networking@gmail.com>2019-04-20 07:22:38 +0900
committerTobias Klauser <tobias.klauser@gmail.com>2019-11-05 08:49:25 +0000
commita882066a44e04a21d46e51451c71e131344e830e (patch)
tree3596f58664b94ffc7f2deab29870da0f8fee58fb
parent0deb6923b6d97481cb43bc1043fe5b72a0143032 (diff)
downloadnet-a882066a44e04a21d46e51451c71e131344e830e.tar.xz
nettest: use unixStrmDgramEnabled on AIX
Also makes parsing the output of oslevel safe. Change-Id: I72dda3e5f49f40413563ad40396961c3c794c63d Reviewed-on: https://go-review.googlesource.com/c/net/+/173078 Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Clément Chigot <clement.chigot%atos.net@gtempaccount.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
-rw-r--r--nettest/nettest.go36
1 files changed, 19 insertions, 17 deletions
diff --git a/nettest/nettest.go b/nettest/nettest.go
index 717bbb0..a402a46 100644
--- a/nettest/nettest.go
+++ b/nettest/nettest.go
@@ -20,11 +20,11 @@ import (
)
var (
- stackOnce sync.Once
- ipv4Enabled bool
- ipv6Enabled bool
- rawSocketSess bool
- aixTechLvl int
+ stackOnce sync.Once
+ ipv4Enabled bool
+ ipv6Enabled bool
+ unStrmDgramEnabled bool
+ rawSocketSess bool
aLongTimeAgo = time.Unix(233431200, 0)
neverTimeout = time.Time{}
@@ -43,17 +43,24 @@ func probeStack() {
ipv6Enabled = true
}
rawSocketSess = supportsRawSocket()
- if runtime.GOOS == "aix" {
- out, err := exec.Command("oslevel", "-s").Output()
- if err == nil {
- aixTechLvl, _ = strconv.Atoi(string(out[5:7]))
+ switch runtime.GOOS {
+ case "aix":
+ // Unix network isn't properly working on AIX 7.2 with
+ // Technical Level < 2.
+ out, _ := exec.Command("oslevel", "-s").Output()
+ if len(out) >= len("7200-XX-ZZ-YYMM") { // AIX 7.2, Tech Level XX, Service Pack ZZ, date YYMM
+ ver := string(out[:4])
+ tl, _ := strconv.Atoi(string(out[5:7]))
+ unStrmDgramEnabled = ver > "7200" || (ver == "7200" && tl >= 2)
}
+ default:
+ unStrmDgramEnabled = true
}
}
-func aixTechLevel() int {
+func unixStrmDgramEnabled() bool {
stackOnce.Do(probeStack)
- return aixTechLvl
+ return unStrmDgramEnabled
}
// SupportsIPv4 reports whether the platform supports IPv4 networking
@@ -110,12 +117,7 @@ func TestableNetwork(network string) bool {
case "android", "fuchsia", "hurd", "js", "nacl", "plan9", "windows":
return false
case "aix":
- // Unix network isn't properly working on AIX
- // 7.2 with Technical Level < 2.
- if aixTechLevel() < 2 {
- return false
- }
- return true
+ return unixStrmDgramEnabled()
case "darwin":
// iOS does not support unix, unixgram.
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {