-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Minor - P4
-
Affects Version/s: None
-
Component/s: Networking
-
None
-
Fully Compatible
-
None
-
0
-
None
-
None
-
None
-
None
-
None
-
None
SockAddr::operator<(SockAddr) treats AF_INET SockAddr objects incorrectly and nonportably.
It orders by the uint32_t sin_addr.s_addr, which is in network byte order. On little-endian, this is major-sorting by LSB. On big-endian it would be correct by accident.
AF_INET6 addresses have no integer equivalent are are correctly compared with network-order memcmp, MSB-first.
So currently on LE machines, we have IPv4 sorted LSB-first, and IPv6 sorted MSB-first.
The obviously correct sorting should be MSB-first, so subnet addresses are grouped together, so we should change the sin_addr.s_addr comparison to a memcmp, or a comparison of the ntohl of these addresses.
I'm not aware of any production impact of this, but that's not saying much as I've been here a month.