Summary: | AI_V4MAPPED is useless with AI_UNSPEC but they're used together as defaults when hints=NULL | ||
---|---|---|---|
Product: | glibc | Reporter: | Pavel Šimerda <psimerda> |
Component: | network | Assignee: | Pavel Šimerda <psimerda> |
Status: | WAITING --- | ||
Severity: | minor | CC: | carlos, neleai, tore |
Priority: | P2 | Flags: | fweimer:
security-
|
Version: | 2.15 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: |
patch to remove useless AI_V4MAPPED from default with AF_UNSPEC
getaddrinfo: use zero ai_flags by default |
Description
Pavel Šimerda
2012-07-28 09:38:50 UTC
My understanding is that because the default uses AF_UNSPEC that the caller accepts *any* address family thus AI_V4MAPPED is not useless because AF_UNSPEC can be treated as anything including AF_INET6. Does that clarify why we would set AI_V4MAPPED in the default? Please note that the man pages are maintained by man-pages project here: http://www.kernel.org/doc/man-pages/ Would a clarification on the man page about the uses of AF_UNSPEC help? > My understanding is that because the default uses AF_UNSPEC that the caller > accepts *any* address family thus AI_V4MAPPED is not useless because AF_UNSPEC > can be treated as anything including AF_INET6. This is not the case. My tests say that AF_UNSPEC with AI_V4MAPPED returns regular IPv4 addresses, regular IPv6 addresses but *no* IPv4-mapped IPv6 addresses. So it actually behaves exactly like AF_UNSPEC without AI_V4MAPPED. > Does that clarify why we would set AI_V4MAPPED in the default? Unfortunately not. Created attachment 6649 [details]
patch to remove useless AI_V4MAPPED from default with AF_UNSPEC
Created attachment 6794 [details]
getaddrinfo: use zero ai_flags by default
According to POSIX1-2008, AI_V4MAPPED flag shall be ignored unless ai_family
equals AF_INET6. In the default hints, ai_family is AF_UNSPEC. Therefore
AI_V4MAPPED is redundant.
AI_ADDRCONFIG can potentially be beneficial to applications that use
getaddrinfo() results to immediately call connect(), sendto() and
similar functions to avoid querying redundant DNS records according
to the current address configuration.
Those applications will also need to specify ai_socktype and/or
ai_protocol and therefore will not use hints=NULL. As AI_DEFAULT is not
a part of the public API, such applications will not be able to use the
default flags at all.
Please note that POSIX1-2008 doesn't define any default flags at all.
Resolves: #14415, #14965
Could you send these patches to libc-alpha? In second one wouldn't be defining AI_DEFAULT as 0 more reasonable? |