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/139577
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/route/sys_freebsd.go b/route/sys_freebsd.go
index 89ba1c4..a1a0d79 100644
--- a/route/sys_freebsd.go
+++ b/route/sys_freebsd.go
@@ -57,7 +57,7 @@
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 @@
} 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