mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2024-11-25 00:33:08 +01:00
device: fix alignment on 32-bit machines and test for it
The test previously checked the offset within a substruct, not the offset within the allocated struct, so this adds the two together. It then fixes an alignment crash on 32-bit machines. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
d6e76fdbd6
commit
d7bc7508e5
@ -61,6 +61,5 @@ func TestDeviceAlignment(t *testing.T) {
|
|||||||
field.Type.Align(),
|
field.Type.Align(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
checkAlignment(t, "Device.rate.underLoadUntil", unsafe.Offsetof(d.rate)+unsafe.Offsetof(d.rate.underLoadUntil))
|
||||||
checkAlignment(t, "Device.rate.underLoadUntil", unsafe.Offsetof(d.rate.underLoadUntil))
|
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Device struct {
|
type Device struct {
|
||||||
log *Logger
|
|
||||||
|
|
||||||
// synchronized resources (locks acquired in order)
|
|
||||||
|
|
||||||
state struct {
|
state struct {
|
||||||
// state holds the device's state. It is accessed atomically.
|
// state holds the device's state. It is accessed atomically.
|
||||||
// Use the device.deviceState method to read it.
|
// Use the device.deviceState method to read it.
|
||||||
@ -64,8 +60,6 @@ type Device struct {
|
|||||||
keyMap map[NoisePublicKey]*Peer
|
keyMap map[NoisePublicKey]*Peer
|
||||||
}
|
}
|
||||||
|
|
||||||
// unprotected / "self-synchronising resources"
|
|
||||||
|
|
||||||
allowedips AllowedIPs
|
allowedips AllowedIPs
|
||||||
indexTable IndexTable
|
indexTable IndexTable
|
||||||
cookieChecker CookieChecker
|
cookieChecker CookieChecker
|
||||||
@ -94,6 +88,7 @@ type Device struct {
|
|||||||
|
|
||||||
ipcMutex sync.RWMutex
|
ipcMutex sync.RWMutex
|
||||||
closed chan struct{}
|
closed chan struct{}
|
||||||
|
log *Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// deviceState represents the state of a Device.
|
// deviceState represents the state of a Device.
|
||||||
|
Loading…
Reference in New Issue
Block a user