public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12907] New: getaddrinfo() takes long time when lots of IP addresses are configured
@ 2011-06-17 12:52 david.hanisch at nsn dot com
  2011-06-18 13:36 ` [Bug libc/12907] " ppluzhnikov at google dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: david.hanisch at nsn dot com @ 2011-06-17 12:52 UTC (permalink / raw)
  To: glibc-bugs

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

           Summary: getaddrinfo() takes long time when lots of IP
                    addresses are configured
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: david.hanisch@nsn.com


Created attachment 5800
  --> http://sourceware.org/bugzilla/attachment.cgi?id=5800
Suggested patch

function getaddrinfo() retrieves all configured IP addresses using function
__check_pf() what takes ages when lots of addresses are configured (60000).
This is done even if not needed, e.g. when the address is given as literal
"1.2.3.4".

How to reproduce:

- configure lots of addresses
#!/usr/bin/perl
my $addrCount = 64000;
for (my $i=1; $i < $addrCount; $i++) {
  my $w1 = ($i % 254) + 1;
  my $w2 = ($i / 254) + 1;
  my $s = sprintf("ip addr add 10.5.%d.%d dev eth0", $w2, $w1);
  print "$s\n";
  system ($s)
} 
- resolve a literal address
  struct addrinfo ai;
  struct addrinfo *ailist = NULL;
  memset(&ai, 0, sizeof(ai));
  ai.ai_family = af;
  ai.ai_flags = AI_PASSIVE;
  getaddrinfo("10.5.1.1", "0", &ai, &ailist);
  freeaddrinfo(ailist);

Suggested solution:
call __check_pf() only if needed, a patch for glibc 2.11.2 is attached.

-- 
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] 7+ messages in thread

* [Bug libc/12907] getaddrinfo() takes long time when lots of IP addresses are configured
  2011-06-17 12:52 [Bug libc/12907] New: getaddrinfo() takes long time when lots of IP addresses are configured david.hanisch at nsn dot com
@ 2011-06-18 13:36 ` ppluzhnikov at google dot com
  2011-06-21 16:39 ` drepper.fsp at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ppluzhnikov at google dot com @ 2011-06-18 13:36 UTC (permalink / raw)
  To: glibc-bugs

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

Paul Pluzhnikov <ppluzhnikov at google dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppluzhnikov at google dot
                   |                            |com

-- 
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] 7+ messages in thread

* [Bug libc/12907] getaddrinfo() takes long time when lots of IP addresses are configured
  2011-06-17 12:52 [Bug libc/12907] New: getaddrinfo() takes long time when lots of IP addresses are configured david.hanisch at nsn dot com
  2011-06-18 13:36 ` [Bug libc/12907] " ppluzhnikov at google dot com
@ 2011-06-21 16:39 ` drepper.fsp at gmail dot com
  2011-06-22  5:54 ` david.hanisch at nsn dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: drepper.fsp at gmail dot com @ 2011-06-21 16:39 UTC (permalink / raw)
  To: glibc-bugs

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

Ulrich Drepper <drepper.fsp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |SUSPENDED

--- Comment #1 from Ulrich Drepper <drepper.fsp at gmail dot com> 2011-06-21 16:39:19 UTC ---
This patch is wrong.  The configuration might have changed since the last call.
 The kernel is missing support to request information whether anything changed
to avoid the costly operation.  This has been raised several times, nothing
happened so far.  Get an extension added to the kernel and then you can submit
a patch to use it.  Until then I suspend the bug.

-- 
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] 7+ messages in thread

* [Bug libc/12907] getaddrinfo() takes long time when lots of IP addresses are configured
  2011-06-17 12:52 [Bug libc/12907] New: getaddrinfo() takes long time when lots of IP addresses are configured david.hanisch at nsn dot com
  2011-06-18 13:36 ` [Bug libc/12907] " ppluzhnikov at google dot com
  2011-06-21 16:39 ` drepper.fsp at gmail dot com
@ 2011-06-22  5:54 ` david.hanisch at nsn dot com
  2011-06-22 18:45 ` drepper.fsp at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: david.hanisch at nsn dot com @ 2011-06-22  5:54 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #2 from david.hanisch at nsn dot com 2011-06-22 05:53:24 UTC ---
(In reply to comment #1)
Hello Ulrich,
Thanks for the reply, but from your comment I fear you might have got me wrong.
I will explain a bit more detailed and kindly ask you to check again.

The objective of the patch is not at all to keep or cache any data retrieved
from kernel between two calls to the function getaddrinfo().

The costly function in question is __check_pf(). It is currently called right
at the beginning of getaddrinfo(). The results are used in two conditions:
a) when flag AI_ADDRCONFIG is set 
b) when the number of found addresses is > 1

The patch just moves the call to __check_pf() from the beginning to the places
where the results are needed. Since there are two places the variable
"check_pf_called" is used as a flag to not call __check_pf() twice within one
call to getaddrinfo() in case a) and b) are true.

When converting a literal address like "1.2.3.4" neither a) nor b) is true, so
the call the __check_pf() is avoided.

-- 
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] 7+ messages in thread

* [Bug libc/12907] getaddrinfo() takes long time when lots of IP addresses are configured
  2011-06-17 12:52 [Bug libc/12907] New: getaddrinfo() takes long time when lots of IP addresses are configured david.hanisch at nsn dot com
                   ` (2 preceding siblings ...)
  2011-06-22  5:54 ` david.hanisch at nsn dot com
@ 2011-06-22 18:45 ` drepper.fsp at gmail dot com
  2011-06-22 19:03 ` drepper.fsp at gmail dot com
  2014-06-27 13:05 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: drepper.fsp at gmail dot com @ 2011-06-22 18:45 UTC (permalink / raw)
  To: glibc-bugs

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

Ulrich Drepper <drepper.fsp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #5800|0                           |1
           is patch|                            |
   Attachment #5800|application/octet-stream    |text/plain
          mime type|                            |

-- 
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] 7+ messages in thread

* [Bug libc/12907] getaddrinfo() takes long time when lots of IP addresses are configured
  2011-06-17 12:52 [Bug libc/12907] New: getaddrinfo() takes long time when lots of IP addresses are configured david.hanisch at nsn dot com
                   ` (3 preceding siblings ...)
  2011-06-22 18:45 ` drepper.fsp at gmail dot com
@ 2011-06-22 19:03 ` drepper.fsp at gmail dot com
  2014-06-27 13:05 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: drepper.fsp at gmail dot com @ 2011-06-22 19:03 UTC (permalink / raw)
  To: glibc-bugs

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

Ulrich Drepper <drepper.fsp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|SUSPENDED                   |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Ulrich Drepper <drepper.fsp at gmail dot com> 2011-06-22 19:02:49 UTC ---
(In reply to comment #2)
> The objective of the patch is not at all to keep or cache any data retrieved
> from kernel between two calls to the function getaddrinfo().

I was confused by your patch since in its few lines it contains a lot of
pointless code and the only way to make sense of it was thinking the static for
the state variable was missing.  I applied a cleaned up patch.

-- 
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] 7+ messages in thread

* [Bug libc/12907] getaddrinfo() takes long time when lots of IP addresses are configured
  2011-06-17 12:52 [Bug libc/12907] New: getaddrinfo() takes long time when lots of IP addresses are configured david.hanisch at nsn dot com
                   ` (4 preceding siblings ...)
  2011-06-22 19:03 ` drepper.fsp at gmail dot com
@ 2014-06-27 13:05 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27 13:05 UTC (permalink / raw)
  To: glibc-bugs

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

Florian Weimer <fweimer at redhat dot com> changed:

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

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


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

end of thread, other threads:[~2014-06-27 13:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-17 12:52 [Bug libc/12907] New: getaddrinfo() takes long time when lots of IP addresses are configured david.hanisch at nsn dot com
2011-06-18 13:36 ` [Bug libc/12907] " ppluzhnikov at google dot com
2011-06-21 16:39 ` drepper.fsp at gmail dot com
2011-06-22  5:54 ` david.hanisch at nsn dot com
2011-06-22 18:45 ` drepper.fsp at gmail dot com
2011-06-22 19:03 ` drepper.fsp at gmail dot com
2014-06-27 13:05 ` fweimer at redhat dot com

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).