diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-06-02 17:10:17 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-06-06 12:26:10 +1000 |
commit | 74a7e68925c27b0bce26a4f6775b3d08ba1767e0 (patch) | |
tree | a15f88be8029b9c3362279ebbbaa1788cf008e24 /lib | |
parent | 7d59e9c549933c33182fbb0a7227be0eb69b4892 (diff) | |
download | samba-74a7e68925c27b0bce26a4f6775b3d08ba1767e0.tar.gz samba-74a7e68925c27b0bce26a4f6775b3d08ba1767e0.tar.bz2 samba-74a7e68925c27b0bce26a4f6775b3d08ba1767e0.zip |
ipv6: always try to convert as a numeric address first
This avoids unnecessary name lookups, plus it fixes a problem with
using interpret_string_addr*() with the wildcard IPv6 address
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/util_net.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/util/util_net.c b/lib/util/util_net.c index 98eef3bd8b..57a0b1e40c 100644 --- a/lib/util/util_net.c +++ b/lib/util/util_net.c @@ -54,6 +54,15 @@ bool interpret_string_addr_internal(struct addrinfo **ppres, /* By default make sure it supports TCP. */ hints.ai_socktype = SOCK_STREAM; + + /* always try as a numeric host first. This prevents unnecessary name + * lookups, and also ensures we accept IPv6 addresses */ + hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; + ret = getaddrinfo(str, NULL, &hints, ppres); + if (ret == 0) { + return true; + } + hints.ai_flags = flags; /* Linux man page on getaddrinfo() says port will be |