* ipset restore behavior with newer glibc @ 2012-10-31 16:27 Josh Hunt 2012-10-31 16:41 ` Jan Engelhardt 0 siblings, 1 reply; 8+ messages in thread From: Josh Hunt @ 2012-10-31 16:27 UTC (permalink / raw) To: netfilter-devel When doing an ipset restore with newer versions of glibc I'm seeing some extra syscall overhead that I was not seeing with glibc 2.4. I was wondering if anyone has seen such behavior and could help me understand what is going on? Here is a snippet of strace during the restore with glibc 2.4: http://pastebin.com/qxkPF7FB and one with glibc 2.7: http://pastebin.com/wga9SN0E I've also seen similar behavior with glibc 2.11. You'll notice that with the newer version a second netlink socket is created and it appears some data is sent and info received back from the kernel and that socket is closed. This creating and closing of sockets continues until the restore operation completes. This causes the restore to grow from taking ~1 second to ~5 seconds. This is not a huge deal, but I'm more curious as to why this behavior has changed. These runs were done with ipset v6.11 and kernel 3.2. It appears to me this is a glibc change b/c if I swap out only that component I see this change in behavior. Thanks Josh ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ipset restore behavior with newer glibc 2012-10-31 16:27 ipset restore behavior with newer glibc Josh Hunt @ 2012-10-31 16:41 ` Jan Engelhardt 2012-10-31 18:49 ` Jozsef Kadlecsik 0 siblings, 1 reply; 8+ messages in thread From: Jan Engelhardt @ 2012-10-31 16:41 UTC (permalink / raw) To: Josh Hunt; +Cc: netfilter-devel On Wednesday 2012-10-31 17:27, Josh Hunt wrote: > When doing an ipset restore with newer versions of glibc I'm seeing some extra > syscall overhead that I was not seeing with glibc 2.4. I was wondering if > anyone has seen such behavior and could help me understand what is going on? > > Here is a snippet of strace during the restore with glibc 2.4: > http://pastebin.com/qxkPF7FB and one with glibc 2.7: > http://pastebin.com/wga9SN0E > I've also seen similar behavior with glibc 2.11. > > You'll notice that with the newer version a second netlink socket is created > and it appears some data is sent and info received back from the kernel I have observed such as well in other programs as well. Without looking into this too deeply, I suspect that a program, or a library on its behalf, is using the interface name<->index resolution functions if_nametoindex(3) et al, for which netlink is used in sufficiently new glibc where socket ioctls were (probably) used previously. Could this be it? ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ipset restore behavior with newer glibc 2012-10-31 16:41 ` Jan Engelhardt @ 2012-10-31 18:49 ` Jozsef Kadlecsik 2012-10-31 19:07 ` Jozsef Kadlecsik 2012-10-31 19:30 ` Josh Hunt 0 siblings, 2 replies; 8+ messages in thread From: Jozsef Kadlecsik @ 2012-10-31 18:49 UTC (permalink / raw) To: Jan Engelhardt; +Cc: Josh Hunt, netfilter-devel On Wed, 31 Oct 2012, Jan Engelhardt wrote: > On Wednesday 2012-10-31 17:27, Josh Hunt wrote: > > > When doing an ipset restore with newer versions of glibc I'm seeing > > some extra syscall overhead that I was not seeing with glibc 2.4. I > > was wondering if anyone has seen such behavior and could help me > > understand what is going on? > > > > Here is a snippet of strace during the restore with glibc 2.4: > > http://pastebin.com/qxkPF7FB and one with glibc 2.7: > > http://pastebin.com/wga9SN0E > > I've also seen similar behavior with glibc 2.11. > > > > You'll notice that with the newer version a second netlink socket is created > > and it appears some data is sent and info received back from the kernel > > I have observed such as well in other programs as well. Without > looking into this too deeply, I suspect that a program, or a library > on its behalf, is using the interface name<->index resolution > functions if_nametoindex(3) et al, for which netlink is used in > sufficiently new glibc where socket ioctls were (probably) used > previously. Could this be it? ipset does not check interface names (except the length of the string), so does not call if_nametoindex. The extra syscalls come from "getaddrinfo", which is used by ipset to parse every IP address. In eglibc 2.11 the implementation of "getaddrinfo" contains the comment and the uncoditional call: /* We might need information about what interfaces are available. Also determine whether we have IPv4 or IPv6 interfaces or both. We cannot cache the results since new interfaces could be added at any time. */ __check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen); And indeed, __check_pf opens up a netlink socket, makes a request then closes it. I haven't checked the source code of glibc itself but I suppose it works the same way. Best regards, Jozsef - E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences H-1525 Budapest 114, POB. 49, Hungary ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ipset restore behavior with newer glibc 2012-10-31 18:49 ` Jozsef Kadlecsik @ 2012-10-31 19:07 ` Jozsef Kadlecsik 2012-11-27 19:18 ` Josh Hunt 2012-10-31 19:30 ` Josh Hunt 1 sibling, 1 reply; 8+ messages in thread From: Jozsef Kadlecsik @ 2012-10-31 19:07 UTC (permalink / raw) To: Jan Engelhardt; +Cc: Josh Hunt, netfilter-devel On Wed, 31 Oct 2012, Jozsef Kadlecsik wrote: > On Wed, 31 Oct 2012, Jan Engelhardt wrote: > > > On Wednesday 2012-10-31 17:27, Josh Hunt wrote: > > > > > When doing an ipset restore with newer versions of glibc I'm seeing > > > some extra syscall overhead that I was not seeing with glibc 2.4. I > > > was wondering if anyone has seen such behavior and could help me > > > understand what is going on? > > > > > > Here is a snippet of strace during the restore with glibc 2.4: > > > http://pastebin.com/qxkPF7FB and one with glibc 2.7: > > > http://pastebin.com/wga9SN0E > > > I've also seen similar behavior with glibc 2.11. > > > > > > You'll notice that with the newer version a second netlink socket is created > > > and it appears some data is sent and info received back from the kernel > > > > I have observed such as well in other programs as well. Without > > looking into this too deeply, I suspect that a program, or a library > > on its behalf, is using the interface name<->index resolution > > functions if_nametoindex(3) et al, for which netlink is used in > > sufficiently new glibc where socket ioctls were (probably) used > > previously. Could this be it? > > ipset does not check interface names (except the length of the string), so > does not call if_nametoindex. > > The extra syscalls come from "getaddrinfo", which is used by ipset to > parse every IP address. In eglibc 2.11 the implementation of "getaddrinfo" > contains the comment and the uncoditional call: > > /* We might need information about what interfaces are available. > Also determine whether we have IPv4 or IPv6 interfaces or both. We > cannot cache the results since new interfaces could be added at > any time. */ > __check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen); > > And indeed, __check_pf opens up a netlink socket, makes a request then > closes it. > > I haven't checked the source code of glibc itself but I suppose it works > the same way. It seems to me, the best is to add a stripped down version of "getaddrinfo" to ipset itself. That'll be the first library workaround... Best regards, Jozsef - E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences H-1525 Budapest 114, POB. 49, Hungary ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ipset restore behavior with newer glibc 2012-10-31 19:07 ` Jozsef Kadlecsik @ 2012-11-27 19:18 ` Josh Hunt 2012-11-27 19:51 ` Jozsef Kadlecsik 0 siblings, 1 reply; 8+ messages in thread From: Josh Hunt @ 2012-11-27 19:18 UTC (permalink / raw) To: Jozsef Kadlecsik; +Cc: Jan Engelhardt, netfilter-devel@vger.kernel.org On 10/31/2012 02:07 PM, Jozsef Kadlecsik wrote: > > It seems to me, the best is to add a stripped down version of > "getaddrinfo" to ipset itself. That'll be the first library workaround... > Is this something that would be an acceptable solution? If so I can try my hand at it unless someone else is eager to do it. Josh ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ipset restore behavior with newer glibc 2012-11-27 19:18 ` Josh Hunt @ 2012-11-27 19:51 ` Jozsef Kadlecsik 2012-11-27 19:53 ` Josh Hunt 0 siblings, 1 reply; 8+ messages in thread From: Jozsef Kadlecsik @ 2012-11-27 19:51 UTC (permalink / raw) To: Josh Hunt; +Cc: Jan Engelhardt, netfilter-devel@vger.kernel.org On Tue, 27 Nov 2012, Josh Hunt wrote: > On 10/31/2012 02:07 PM, Jozsef Kadlecsik wrote: > > > > It seems to me, the best is to add a stripped down version of > > "getaddrinfo" to ipset itself. That'll be the first library workaround... > > Is this something that would be an acceptable solution? If so I can try my > hand at it unless someone else is eager to do it. In ipset 6.15 getaddrinfo was replaced by gethostbyname2 (where it's available in libc). Best regards, Jozsef - E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences H-1525 Budapest 114, POB. 49, Hungary ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ipset restore behavior with newer glibc 2012-11-27 19:51 ` Jozsef Kadlecsik @ 2012-11-27 19:53 ` Josh Hunt 0 siblings, 0 replies; 8+ messages in thread From: Josh Hunt @ 2012-11-27 19:53 UTC (permalink / raw) To: Jozsef Kadlecsik; +Cc: Jan Engelhardt, netfilter-devel@vger.kernel.org On 11/27/2012 01:51 PM, Jozsef Kadlecsik wrote: > On Tue, 27 Nov 2012, Josh Hunt wrote: > >> On 10/31/2012 02:07 PM, Jozsef Kadlecsik wrote: >>> >>> It seems to me, the best is to add a stripped down version of >>> "getaddrinfo" to ipset itself. That'll be the first library workaround... >> >> Is this something that would be an acceptable solution? If so I can try my >> hand at it unless someone else is eager to do it. > > In ipset 6.15 getaddrinfo was replaced by gethostbyname2 (where it's > available in libc). Sweet! :D ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ipset restore behavior with newer glibc 2012-10-31 18:49 ` Jozsef Kadlecsik 2012-10-31 19:07 ` Jozsef Kadlecsik @ 2012-10-31 19:30 ` Josh Hunt 1 sibling, 0 replies; 8+ messages in thread From: Josh Hunt @ 2012-10-31 19:30 UTC (permalink / raw) To: Jozsef Kadlecsik; +Cc: Jan Engelhardt, netfilter-devel@vger.kernel.org On 10/31/2012 01:49 PM, Jozsef Kadlecsik wrote: > On Wed, 31 Oct 2012, Jan Engelhardt wrote: > >> On Wednesday 2012-10-31 17:27, Josh Hunt wrote: >> >>> When doing an ipset restore with newer versions of glibc I'm seeing >>> some extra syscall overhead that I was not seeing with glibc 2.4. I >>> was wondering if anyone has seen such behavior and could help me >>> understand what is going on? >>> >>> Here is a snippet of strace during the restore with glibc 2.4: >>> http://pastebin.com/qxkPF7FB and one with glibc 2.7: >>> http://pastebin.com/wga9SN0E >>> I've also seen similar behavior with glibc 2.11. >>> >>> You'll notice that with the newer version a second netlink socket is created >>> and it appears some data is sent and info received back from the kernel >> >> I have observed such as well in other programs as well. Without >> looking into this too deeply, I suspect that a program, or a library >> on its behalf, is using the interface name<->index resolution >> functions if_nametoindex(3) et al, for which netlink is used in >> sufficiently new glibc where socket ioctls were (probably) used >> previously. Could this be it? > > ipset does not check interface names (except the length of the string), so > does not call if_nametoindex. > > The extra syscalls come from "getaddrinfo", which is used by ipset to > parse every IP address. In eglibc 2.11 the implementation of "getaddrinfo" > contains the comment and the uncoditional call: > > /* We might need information about what interfaces are available. > Also determine whether we have IPv4 or IPv6 interfaces or both. We > cannot cache the results since new interfaces could be added at > any time. */ > __check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen); > > And indeed, __check_pf opens up a netlink socket, makes a request then > closes it. > > I haven't checked the source code of glibc itself but I suppose it works > the same way. > > Best regards, > Jozsef > - > E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu > PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt > Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences > H-1525 Budapest 114, POB. 49, Hungary > Jozsef It looks like you're right. glibc doesn't do the socket in __check_pf, but does add a socket call inside of getaddrinfo. Josh ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-11-27 19:53 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-10-31 16:27 ipset restore behavior with newer glibc Josh Hunt 2012-10-31 16:41 ` Jan Engelhardt 2012-10-31 18:49 ` Jozsef Kadlecsik 2012-10-31 19:07 ` Jozsef Kadlecsik 2012-11-27 19:18 ` Josh Hunt 2012-11-27 19:51 ` Jozsef Kadlecsik 2012-11-27 19:53 ` Josh Hunt 2012-10-31 19:30 ` Josh Hunt
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.