Commit 68fc9115 authored by Mikio Hara's avatar Mikio Hara

route: re-adjust routing message alignment for FreeBSD 386 emulation

On 11.2-RELEASE or above FreeBSD kernels, the breakage of routing
message alignment for 386 emulation (see COMPAT_FREEBSD32 in
sys/net/rtsock.c) is fixed. This change makes packages in the x/net
repository work regardless of the kernel fix.

Change-Id: Ie71cc7dfb842c66225f96d1fb0e8cc5de7c47015
Reviewed-on: https://go-review.googlesource.com/c/139577Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent f5e5bdd7
......@@ -57,7 +57,7 @@ func (m *InterfaceMessage) Sys() []Sys {
func probeRoutingStack() (int, map[int]*wireFormat) {
var p uintptr
wordSize := int(unsafe.Sizeof(p))
align := int(unsafe.Sizeof(p))
align := wordSize
// In the case of kern.supported_archs="amd64 i386", we need
// to know the underlying kernel's architecture because the
// alignment for routing facilities are set at the build time
......@@ -129,6 +129,9 @@ func probeRoutingStack() (int, map[int]*wireFormat) {
} else {
ifm.bodyOff = sizeofIfMsghdrFreeBSD11
}
if rel >= 1102000 { // see https://github.com/freebsd/freebsd/commit/027c7f4d66ff8d8c4a46c3665a5ee7d6d8462034#diff-ad4e5b7f1449ea3fc87bc97280de145b
align = wordSize
}
}
rtm.parse = rtm.parseRouteMessage
ifm.parse = ifm.parseInterfaceMessage
......
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