Skip to content

Commit f9f770b

Browse files
cixtorbradfitz
authored andcommitted
[release-branch.go1.11] 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. Updates golang/go#31221 Change-Id: Ie71cc7dfb842c66225f96d1fb0e8cc5de7c47015 Reviewed-on: https://go-review.googlesource.com/c/139577 Reviewed-by: Brad Fitzpatrick <[email protected]> (cherry picked from commit 68fc911) Reviewed-on: https://go-review.googlesource.com/c/net/+/170617 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent a463015 commit f9f770b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

route/sys_freebsd.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (m *InterfaceMessage) Sys() []Sys {
5757
func probeRoutingStack() (int, map[int]*wireFormat) {
5858
var p uintptr
5959
wordSize := int(unsafe.Sizeof(p))
60-
align := int(unsafe.Sizeof(p))
60+
align := wordSize
6161
// In the case of kern.supported_archs="amd64 i386", we need
6262
// to know the underlying kernel's architecture because the
6363
// alignment for routing facilities are set at the build time
@@ -129,6 +129,9 @@ func probeRoutingStack() (int, map[int]*wireFormat) {
129129
} else {
130130
ifm.bodyOff = sizeofIfMsghdrFreeBSD11
131131
}
132+
if rel >= 1102000 { // see https://github.com/freebsd/freebsd/commit/027c7f4d66ff8d8c4a46c3665a5ee7d6d8462034#diff-ad4e5b7f1449ea3fc87bc97280de145b
133+
align = wordSize
134+
}
132135
}
133136
rtm.parse = rtm.parseRouteMessage
134137
ifm.parse = ifm.parseInterfaceMessage

0 commit comments

Comments
 (0)