diff --git a/netlink/netlink_linux.go b/netlink/netlink_linux.go index 39630c3ec..92accd4aa 100644 --- a/netlink/netlink_linux.go +++ b/netlink/netlink_linux.go @@ -3,7 +3,6 @@ package netlink import ( "encoding/binary" "fmt" - "math/rand" "net" "sync/atomic" "syscall" @@ -949,7 +948,7 @@ func setBridgeMacAddress(s int, name string) error { copy(ifr.IfrnName[:], name) for i := 0; i < 6; i++ { - ifr.IfruHwaddr.Data[i] = int8(rand.Intn(255)) + ifr.IfruHwaddr.Data[i] = randIfrDataByte() } ifr.IfruHwaddr.Data[0] &^= 0x1 // clear multicast bit diff --git a/netlink/netlink_linux_arm.go b/netlink/netlink_linux_arm.go new file mode 100644 index 000000000..7789ae275 --- /dev/null +++ b/netlink/netlink_linux_arm.go @@ -0,0 +1,9 @@ +package netlink + +import ( + "math/rand" +) + +func randIfrDataByte() uint8 { + return uint8(rand.Intn(255)) +} diff --git a/netlink/netlink_linux_notarm.go b/netlink/netlink_linux_notarm.go new file mode 100644 index 000000000..23c4a9271 --- /dev/null +++ b/netlink/netlink_linux_notarm.go @@ -0,0 +1,11 @@ +// +build !arm + +package netlink + +import ( + "math/rand" +) + +func randIfrDataByte() int8 { + return int8(rand.Intn(255)) +} diff --git a/system/sysconfig.go b/system/sysconfig.go index dcbe6c9cd..3e2f43b1e 100644 --- a/system/sysconfig.go +++ b/system/sysconfig.go @@ -4,10 +4,9 @@ package system /* #include -int get_hz(void) { return sysconf(_SC_CLK_TCK); } */ import "C" func GetClockTicks() int { - return int(C.get_hz()) + return int(C.sysconf(C._SC_CLK_TCK)) } diff --git a/system/sysconfig_notcgo.go b/system/sysconfig_notcgo.go new file mode 100644 index 000000000..4bbb69896 --- /dev/null +++ b/system/sysconfig_notcgo.go @@ -0,0 +1,8 @@ +// +build linux,!cgo + +package system + +func GetClockTicks() int { + // TODO figure out a better alternative for platforms where we're missing cgo + return 100 +}