Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-32017

SockAddr incorrect sort order for IPv4

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.7.1
    • Affects Version/s: None
    • Component/s: Networking
    • Labels:
      None
    • Fully Compatible

      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.

            Assignee:
            billy.donahue@mongodb.com Billy Donahue
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: