[git commit] getaddrinfo(): avoid call to __check_pf() when not needed

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Tue Apr 17 10:16:46 UTC 2012


commit: http://git.uclibc.org/uClibc/commit/?id=777aef50973bc3a20db8d9545494e8abb86a692e
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

__check_pf() function is called from getaddrinfo() and it calls
getifaddrs(), which is too much overhead especially if RSBAC-Net
is enabled. So with this patch __check_pf() is being called only
when AI_ADDRCONFIG hint flag is specified - just when we really
need that check.

Signed-off-by: Alexander Komyagin <komyagin at altell.ru>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 libc/inet/getaddrinfo.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c
index fe0d942..88bd745 100644
--- a/libc/inet/getaddrinfo.c
+++ b/libc/inet/getaddrinfo.c
@@ -401,7 +401,13 @@ gaih_inet(const char *name, const struct gaih_service *service,
 	int rc;
 	int v4mapped = (req->ai_family == PF_UNSPEC || req->ai_family == PF_INET6)
 			&& (req->ai_flags & AI_V4MAPPED);
-	unsigned seen = __check_pf();
+	unsigned seen = 0;
+	if (req->ai_flags & AI_ADDRCONFIG) {
+		/* "seen" is only used when AI_ADDRCONFIG is specified.
+		   Avoid unnecessary call to __check_pf() otherwise
+		   since it can be costly especially when RSBAC-Net is enabled.  */
+		seen = __check_pf();
+	}
 
 	memset(&nullserv, 0, sizeof(nullserv));
 


More information about the uClibc-cvs mailing list