Skip to content
  • Thomas Bellman's avatar
    b8cba609
    resolve_ipnets(): Handle order of address families better. · b8cba609
    Thomas Bellman authored
    The old implementation of the 'stable' flag to the resolve_ipnets()
    function just sorted the addresses for each host based on their
    textual representation, without regard for which address family they
    belonged to.  That meant that 192.0.2.17 would always come before
    2001:db8:17:23::99, which would always come before 203.0.113.23.  That
    is probably not the best behaviour, since you sometimes want to prefer
    one address family over the other.
    
    We improve on this by coalescing and grouping addresses by address
    family, and only sort the addresses within each family.  This may
    still break the Default Address Selection order (RFC 3484/6724)
    implemented by the getaddrinfo(3) function, but it is at least better
    than before.
    
    We now also obey the order that the 'ipv4' and 'ipv6' flags are given
    in; if 'ipv6' is specified before 'ipv4', IPv6 addresses will be
    returned before IPv4 addresses, and vice versa.  Also, if no address
    family is specified, we now pass AF_UNSPEC to getaddrinfo() instead of
    querying for IPv4 addresses and IPv6 addresses separately in whatever
    order they were stored in the RESOLVE_IPNETS__IPFAMILIES hash.  Thus,
    we will then obey the ordering returned by getaddrinfo() a little bit
    better.  (But remember that resolve_ipnets() is evaluated on the
    Puppet master, not on the node being configured, so the order may
    still not be what is wanted.)
    
    This was originally commit 4d5b4bfe3462 in nsc-puppet-utils.
    b8cba609
    resolve_ipnets(): Handle order of address families better.
    Thomas Bellman authored
    The old implementation of the 'stable' flag to the resolve_ipnets()
    function just sorted the addresses for each host based on their
    textual representation, without regard for which address family they
    belonged to.  That meant that 192.0.2.17 would always come before
    2001:db8:17:23::99, which would always come before 203.0.113.23.  That
    is probably not the best behaviour, since you sometimes want to prefer
    one address family over the other.
    
    We improve on this by coalescing and grouping addresses by address
    family, and only sort the addresses within each family.  This may
    still break the Default Address Selection order (RFC 3484/6724)
    implemented by the getaddrinfo(3) function, but it is at least better
    than before.
    
    We now also obey the order that the 'ipv4' and 'ipv6' flags are given
    in; if 'ipv6' is specified before 'ipv4', IPv6 addresses will be
    returned before IPv4 addresses, and vice versa.  Also, if no address
    family is specified, we now pass AF_UNSPEC to getaddrinfo() instead of
    querying for IPv4 addresses and IPv6 addresses separately in whatever
    order they were stored in the RESOLVE_IPNETS__IPFAMILIES hash.  Thus,
    we will then obey the ordering returned by getaddrinfo() a little bit
    better.  (But remember that resolve_ipnets() is evaluated on the
    Puppet master, not on the node being configured, so the order may
    still not be what is wanted.)
    
    This was originally commit 4d5b4bfe3462 in nsc-puppet-utils.
Loading