As suggested by jtl counter(9) objects are overkill for this variable and atomic makes more sense.
This patch replaces the counter_u64_t with a uint8_t and uses atomic(9) to handle the value.
I decided to use an 8 bit value since the counter is not expected to reach any high values.
Since the counter is now smaller, I modified the related stableaddr_maxretries sysctl to be a SYSCTL_U8 value, this avoids the risk of the sysctl being set to a value higher than the counter can count.
While here I also moved includes I added to respect style(9).
The atomic(9) man page has a warning about using the variants with size <= 16 bits in portable code, but I noticed there are instances of this usage in the kernel (for example in tmpfs, ena driver, and other instances), so I guess it is allowed.