Commit d375fa34 authored by Mikio Hara's avatar Mikio Hara

ipv6: fix multicast socket options on freebsd/386 on amd64

Change-Id: Ifdd525f27a8ed35bda240c08f379014d03fd2201
Reviewed-on: https://go-review.googlesource.com/11226Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 4d302b6b
......@@ -12,13 +12,28 @@ import (
"unsafe"
)
var freebsd32o64 bool
func setsockoptGroupReq(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error {
var gr sysGroupReq
if ifi != nil {
gr.Interface = uint32(ifi.Index)
}
gr.setGroup(grp)
return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&gr), sysSizeofGroupReq))
var p unsafe.Pointer
var l sysSockoptLen
if freebsd32o64 {
var d [sysSizeofGroupReq + 4]byte
s := (*[sysSizeofGroupReq]byte)(unsafe.Pointer(&gr))
copy(d[:4], s[:4])
copy(d[8:], s[4:])
p = unsafe.Pointer(&d[0])
l = sysSizeofGroupReq + 4
} else {
p = unsafe.Pointer(&gr)
l = sysSizeofGroupReq
}
return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, p, l))
}
func setsockoptGroupSourceReq(fd int, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error {
......@@ -27,5 +42,18 @@ func setsockoptGroupSourceReq(fd int, opt *sockOpt, ifi *net.Interface, grp, src
gsr.Interface = uint32(ifi.Index)
}
gsr.setSourceGroup(grp, src)
return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&gsr), sysSizeofGroupSourceReq))
var p unsafe.Pointer
var l sysSockoptLen
if freebsd32o64 {
var d [sysSizeofGroupSourceReq + 4]byte
s := (*[sysSizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr))
copy(d[:4], s[:4])
copy(d[8:], s[4:])
p = unsafe.Pointer(&d[0])
l = sysSizeofGroupSourceReq + 4
} else {
p = unsafe.Pointer(&gsr)
l = sysSizeofGroupSourceReq
}
return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, p, l))
}
......@@ -6,6 +6,8 @@ package ipv6
import (
"net"
"runtime"
"strings"
"syscall"
"unsafe"
......@@ -45,6 +47,18 @@ var (
}
)
func init() {
if runtime.GOOS == "freebsd" && runtime.GOARCH == "386" {
archs, _ := syscall.Sysctl("kern.supported_archs")
for _, s := range strings.Split(archs, " ") {
if strings.TrimSpace(s) == "amd64" {
freebsd32o64 = true
break
}
}
}
}
func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) {
sa.Len = sysSizeofSockaddrInet6
sa.Family = syscall.AF_INET6
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment