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>
The sticky socket code stays in the device package for now,
as it reaches deeply into the peer list.
This is the first step in an effort to split some code out of
the very busy device package.
Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
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>