public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW
@ 2013-01-12 23:25 pablo at gnumonks dot org
  2013-01-12 23:29 ` [Bug libc/15015] " pablo at gnumonks dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: pablo at gnumonks dot org @ 2013-01-12 23:25 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15015

             Bug #: 15015
           Summary: getaddrinfo returns EAI_SERVICE with SOCK_RAW
           Product: glibc
           Version: 2.16
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: pablo@gnumonks.org
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


Hi,

getaddrinfo returns EAI_SERVICE with SOCK_RAW. That's consistent with what you
can read at sysdeps/posix/getaddrinfo.c, line 125:

  { SOCK_RAW, 0, GAI_PROTO_PROTOANY|GAI_PROTO_NOSERVICE, true, "raw" }
                                    ^-----------------^

That function returns that error if the GAI_PROTO_NOSERVICE flag is set.

However, strace shows that, when getaddrinfo is called with SOCK_RAW, the
address information is retrieves from the kernel via netlink as this trace
below shows:

$ strace ./fr
[...]
socket(PF_NETLINK, SOCK_RAW, 0)         = 3
bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
getsockname(3, {sa_family=AF_NETLINK, pid=5936, groups=00000000}, [12]) = 0
sendto(3, "\24\0\0\0\26\0\1\3+\230\256P\0\0\0\0\0\0\0\0", 20, 0,
{sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000},
msg_iov(1)=[{"0\0\0\0\24\0\2\0+\230\256P0\27\0\0\2\10\200\376\1\0\0\0\10\0\1\0\177\0\0\1"...,
4096}], msg_controllen=0, msg_flags=0}, 0) = 108
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000},
msg_iov(1)=[{"@\0\0\0\24\0\2\0+\230\256P0\27\0\0\n\200\200\376\1\0\0\0\24\0\1\0\0\0\0\0"...,
4096}], msg_controllen=0, msg_flags=0}, 0) = 128
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000},
msg_iov(1)=[{"\24\0\0\0\3\0\2\0+\230\256P0\27\0\0\0\0\0\0\1\0\0\0\24\0\1\0\0\0\0\0"...,
4096}], msg_controllen=0, msg_flags=0}, 0) = 20

Let me decipher that netlink trace:

1) bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
                                                           ^^
   bind this socket to rtnetlink

2) Send the request message to ask for the address information.

sendto(3, "\24\0\0\0\26\0\1\3+\230\256P\0\0\0\0\0\0\0\0", 20, 0,
{sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20

3) This gets the multipart message with the information that we
requested:

recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000},
msg_iov(1)=[{"0\0\0\0\24\0\2\0+\230\256P0\27\0\0\2\10\200\376\1\0\0\0\10\0\1\0\177\0\0\1"...,
4096}], msg_controllen=0, msg_flags=0}, 0) = 108
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000},
msg_iov(1)=[{"@\0\0\0\24\0\2\0+\230\256P0\27\0\0\n\200\200\376\1\0\0\0\24\0\1\0\0\0\0\0"...,
4096}], msg_controllen=0, msg_flags=0}, 0) = 128
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000},

But, even if the information is successfully retrieved, it is later on
discarded because of using SOCK_RAW.

Is there any reason for that behaviour? It seems inconsistent to me, ie.
retrieve address records from the kernel correctly but, later on, discard them
because that flag is set.

Thank you!

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libc/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
@ 2013-01-12 23:29 ` pablo at gnumonks dot org
  2013-01-14 13:36 ` schwab@linux-m68k.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pablo at gnumonks dot org @ 2013-01-12 23:29 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15015

pablo at gnumonks dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pablo at gnumonks dot org
              Flags|                            |review?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libc/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
  2013-01-12 23:29 ` [Bug libc/15015] " pablo at gnumonks dot org
@ 2013-01-14 13:36 ` schwab@linux-m68k.org
  2013-01-14 23:44 ` pablo at gnumonks dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: schwab@linux-m68k.org @ 2013-01-14 13:36 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15015

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> 2013-01-14 13:35:51 UTC ---
getaddrinfo shouldn't be optimized for the error case.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libc/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
  2013-01-12 23:29 ` [Bug libc/15015] " pablo at gnumonks dot org
  2013-01-14 13:36 ` schwab@linux-m68k.org
@ 2013-01-14 23:44 ` pablo at gnumonks dot org
  2013-01-14 23:48 ` schwab@linux-m68k.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pablo at gnumonks dot org @ 2013-01-14 23:44 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15015

--- Comment #2 from pablo at gnumonks dot org 2013-01-14 23:43:13 UTC ---
The address base is correctly obtained from the kernel, but later on discarded,
why not allow SOCK_RAW to be used with getaddrinfo?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libc/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
                   ` (2 preceding siblings ...)
  2013-01-14 23:44 ` pablo at gnumonks dot org
@ 2013-01-14 23:48 ` schwab@linux-m68k.org
  2013-10-20 20:28 ` neleai at seznam dot cz
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: schwab@linux-m68k.org @ 2013-01-14 23:48 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15015

--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> 2013-01-14 23:47:37 UTC ---
You can certainly use SOCK_RAW with getaddrinfo.  You just cannot resolve a
service with it.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libc/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
                   ` (3 preceding siblings ...)
  2013-01-14 23:48 ` schwab@linux-m68k.org
@ 2013-10-20 20:28 ` neleai at seznam dot cz
  2014-02-07  2:52 ` [Bug network/15015] " jsm28 at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: neleai at seznam dot cz @ 2013-10-20 20:28 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15015

Ondrej Bilka <neleai at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |neleai at seznam dot cz

--- Comment #4 from Ondrej Bilka <neleai at seznam dot cz> ---
> You can certainly use SOCK_RAW with getaddrinfo. 
> You just cannot resolve a service with it.

Could you be bit more specific where is problem. I am not sure if this bug is
valid or not.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug network/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
                   ` (4 preceding siblings ...)
  2013-10-20 20:28 ` neleai at seznam dot cz
@ 2014-02-07  2:52 ` jsm28 at gcc dot gnu.org
  2014-02-07  9:55 ` pablo at gnumonks dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2014-02-07  2:52 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15015

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libc                        |network

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug network/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
                   ` (5 preceding siblings ...)
  2014-02-07  2:52 ` [Bug network/15015] " jsm28 at gcc dot gnu.org
@ 2014-02-07  9:55 ` pablo at gnumonks dot org
  2014-02-13 15:59 ` asn at cryptomilk dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pablo at gnumonks dot org @ 2014-02-07  9:55 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15015

--- Comment #5 from pablo at gnumonks dot org ---
The question is, what's the reason for not allowing SOCK_RAW with getaddrinfo?

The Linux kernel is providing that information via Netlink, so why should it
artificially reject (through the GAI_PROTO_NOSERVICE flag) the request when it
is indeed obtaining the information that we have requested?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug network/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
                   ` (6 preceding siblings ...)
  2014-02-07  9:55 ` pablo at gnumonks dot org
@ 2014-02-13 15:59 ` asn at cryptomilk dot org
  2014-02-13 16:00 ` asn at cryptomilk dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: asn at cryptomilk dot org @ 2014-02-13 15:59 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15015

Andreas Schneider <asn at cryptomilk dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |asn at cryptomilk dot org

--- Comment #6 from Andreas Schneider <asn at cryptomilk dot org> ---
Created attachment 7411
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7411&action=edit
test_addrinfo.c

Andreas, I think I run into this problem too. I've created a test which works
perfectly on my box. If I strace it I can see it opening /etc/services and
returning the correct information. The same test case, doesn't work in the
openSUSE build service cause it uses a AF_NETLINK socket to get the info and
then fails.

See the build logs of:
https://build.opensuse.org/package/show/home:gladiac/test_getaddrinfo

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug network/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
                   ` (7 preceding siblings ...)
  2014-02-13 15:59 ` asn at cryptomilk dot org
@ 2014-02-13 16:00 ` asn at cryptomilk dot org
  2014-06-13 19:04 ` fweimer at redhat dot com
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: asn at cryptomilk dot org @ 2014-02-13 16:00 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15015

--- Comment #7 from Andreas Schneider <asn at cryptomilk dot org> ---
Created attachment 7412
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7412&action=edit
working test_getaddrinfo strace

This is with glibc-2.18-4.11.1.x86_64

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug network/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
                   ` (8 preceding siblings ...)
  2014-02-13 16:00 ` asn at cryptomilk dot org
@ 2014-06-13 19:04 ` fweimer at redhat dot com
  2014-06-14  5:24 ` fweimer at redhat dot com
  2014-09-27  6:28 ` aoliva at sourceware dot org
  11 siblings, 0 replies; 13+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 19:04 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15015

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |review-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug network/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
                   ` (9 preceding siblings ...)
  2014-06-13 19:04 ` fweimer at redhat dot com
@ 2014-06-14  5:24 ` fweimer at redhat dot com
  2014-09-27  6:28 ` aoliva at sourceware dot org
  11 siblings, 0 replies; 13+ messages in thread
From: fweimer at redhat dot com @ 2014-06-14  5:24 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15015

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|review-                     |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug network/15015] getaddrinfo returns EAI_SERVICE with SOCK_RAW
  2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
                   ` (10 preceding siblings ...)
  2014-06-14  5:24 ` fweimer at redhat dot com
@ 2014-09-27  6:28 ` aoliva at sourceware dot org
  11 siblings, 0 replies; 13+ messages in thread
From: aoliva at sourceware dot org @ 2014-09-27  6:28 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15015

Alexandre Oliva <aoliva at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |aoliva at sourceware dot org
         Resolution|---                         |INVALID

--- Comment #8 from Alexandre Oliva <aoliva at sourceware dot org> ---
Pablo,

The interaction with the netlink raw socket is what getaddrinfo uses to
implement AI_ADDRCONFIG: it has to query the kernel about what address families
are enabled so that it can narrow the search to them, as requested.

You can ask getaddrinfo for SOCK_RAW addresses, for sure, but then servname has
to be NULL, because raw sockets, not being transport level sockets, don't
support port numbers (thus no services).

It is true that getaddrinfo could check that the caller supplied conflicting
parameters earlier, avoiding the netlink query, but the query is cached and
will likely remain valid at the next AI_ADDRCONFIG query, so it's not worth the
additional complexity in getaddrinfo.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-09-27  6:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-12 23:25 [Bug libc/15015] New: getaddrinfo returns EAI_SERVICE with SOCK_RAW pablo at gnumonks dot org
2013-01-12 23:29 ` [Bug libc/15015] " pablo at gnumonks dot org
2013-01-14 13:36 ` schwab@linux-m68k.org
2013-01-14 23:44 ` pablo at gnumonks dot org
2013-01-14 23:48 ` schwab@linux-m68k.org
2013-10-20 20:28 ` neleai at seznam dot cz
2014-02-07  2:52 ` [Bug network/15015] " jsm28 at gcc dot gnu.org
2014-02-07  9:55 ` pablo at gnumonks dot org
2014-02-13 15:59 ` asn at cryptomilk dot org
2014-02-13 16:00 ` asn at cryptomilk dot org
2014-06-13 19:04 ` fweimer at redhat dot com
2014-06-14  5:24 ` fweimer at redhat dot com
2014-09-27  6:28 ` aoliva at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).