Implement simplest variant of /etc/gai.conf to control
getaddrinfo
IPv6/IPv4 addresses sorting. Keep the default sort order - IPv6 first,
IPv4 second. To invert it, create /etc/gai.conf containing single line:
precedence ::ffff:0:0/96 100
Example before:
$ nslookup
security.debian.org 8.8.8.8
Server: 8.8.8.8
Address 1: 8.8.8.8
google-public-dns-a.google.com
Name:
security.debian.org
Address 1: 2001:a78:5:0:216:35ff:fe7f:be4f
villa.debian.org
Address 2: 2001:a78:5:1:216:35ff:fe7f:6ceb
lobos.debian.org
Address 3: 195.20.242.89
wieck.debian.org
Address 4: 212.211.132.250
lobos.debian.org
Address 5: 212.211.132.32
villa.debian.org
After patch & precedence set in /etc/gai.conf:
$ nslookup
security.debian.org 8.8.8.8
Server: 8.8.8.8
Address 1: 8.8.8.8
google-public-dns-a.google.com
Name:
security.debian.org
Address 1: 195.20.242.89
wieck.debian.org
Address 2: 212.211.132.250
lobos.debian.org
Address 3: 212.211.132.32
villa.debian.org
Address 4: 2001:a78:5:0:216:35ff:fe7f:be4f
villa.debian.org
Address 5: 2001:a78:5:1:216:35ff:fe7f:6ceb
lobos.debian.org
bloat-o-meter report:
function old new delta
getaddrinfo 726 1138 +412
gaih_inet 2660 2692 +32
.rodata 16618 16643 +25
__gai_precedence - 1 +1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 882/0) Total: 470 bytes
Signed-off-by: Leonid Lisovskiy <lly.dev(a)gmail.com>