1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 09:15:14 +01:00
Commit Graph

2 Commits

Author SHA1 Message Date
David Crawshaw
a4657f996d device: move stats fields back down and add test diagnostics
This reverts the movement of fields from d49f4e9.
That commit was cherry-picked from another branch where a field
had changed and misaligned the atomic fields. After cherry-picking,
moving the fields was no longer necessary but got dragged along.

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
2020-04-07 15:55:53 +10:00
David Anderson
d49f4e9fe3 device: make Peer fields safe for atomic access on 32-bit.
All atomic access must be aligned to 64 bits, even on 32-bit
platforms. Go promises that the start of allocated structs is
aligned to 64 bits. So, place the atomically-accessed things
first in the struct so that they benefit from that alignment.

As a side bonus, it cleanly separates fields that are accessed
by atomic ops, and those that should be accessed under mu.

Also adds a test that will fail consistently on 32-bit platforms
if the struct ever changes again to violate the rules. This is
likely not needed because unaligned access crashes reliably,
but this will reliably fail even if tests accidentally pass due
to lucky alignment.

Signed-Off-By: David Anderson <danderson@tailscale.com>
2020-03-30 20:10:36 +11:00