Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37560461
en ru br
ALT Linux repos
S:20221126-alt1
5.0: 20071127-alt4
4.1: 20071127-alt0.M41.1
4.0: 20020927-alt4.2
3.0: 20020927-alt2

Group :: Networking/Other
RPM: iputils

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: iputils-20020927-fc-addrcache.patch
Download


--- iputils/ping.c.addrcache	2002-09-20 17:08:11.000000000 +0200
+++ iputils/ping.c	2003-05-15 16:41:19.000000000 +0200
@@ -1124,6 +1124,12 @@
 {
 	struct hostent *hp;
 	static char buf[4096];
+	static __u32 addr_cache = 0;
+
+	if ( addr == addr_cache )
+		return buf;
+
+	addr_cache = addr;
 
 	if ((options & F_NUMERIC) ||
 	    !(hp = gethostbyaddr((char *)&addr, 4, AF_INET)))
--- iputils/ping6.c.addrcache	2002-09-20 17:08:11.000000000 +0200
+++ iputils/ping6.c	2003-05-15 16:41:19.000000000 +0200
@@ -893,7 +893,14 @@
  */
 char * pr_addr(struct in6_addr *addr)
 {
-	struct hostent *hp = NULL;
+	static struct hostent *hp = NULL;
+	static struct in6_addr addr_cache = {{{0,0,0,0}}};
+
+	if ( addr->s6_addr32[0] == addr_cache.s6_addr32[0] &&
+	     addr->s6_addr32[1] == addr_cache.s6_addr32[1] &&
+	     addr->s6_addr32[2] == addr_cache.s6_addr32[2] &&
+	     addr->s6_addr32[3] == addr_cache.s6_addr32[3] )
+		return hp ? hp->h_name : pr_addr_n(addr);
 
 	if (!(options&F_NUMERIC))
 		hp = gethostbyaddr((__u8*)addr, sizeof(struct in6_addr), AF_INET6);
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin