From: David Newall <davidn@davidnewall.com>
To: Jakob Unterwurzacher <jakobunt@gmail.com>, netdev@vger.kernel.org
Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Subject: Re: Small bug in ping
Date: Wed, 04 Jun 2014 19:20:39 +0930 [thread overview]
Message-ID: <538EEBEF.4090500@davidnewall.com> (raw)
In-Reply-To: <538E36E5.4070204@gmail.com>
On 04/06/14 06:28, Jakob Unterwurzacher wrote:
> 4) Ping replies seem to come from your own IP
Yes, a bug. To minimise use of DNS, ping only queries or formats an
addresses once, and returns that result thereafter. The bug was
introduced at bug10979-less-dns. I sent the following patch, which only
returns the previous value if it's for the same IP address, to ping's
maintainer, last month:
Index: iputils/ping.c
===================================================================
--- iputils.orig/ping.c 2013-12-12 21:50:00.237785711 -0800
+++ iputils/ping.c 2013-12-12 22:11:24.800155180 -0800
@@ -1243,7 +1243,12 @@
pr_addr(__u32 addr)
{
struct hostent *hp;
- static char buf[4096];
+ static char buf[4096] = "";
+ static __u32 last_addr;
+
+ if (*buf && addr == last_addr)
+ return(buf);
+ last_addr = addr;
in_pr_addr = !setjmp(pr_addr_jmp);
Index: iputils/ping6.c
===================================================================
--- iputils.orig/ping6.c 2013-12-12 21:50:00.189785476 -0800
+++ iputils/ping6.c 2013-12-12 22:12:22.856444368 -0800
@@ -1794,7 +1794,7 @@
*/
char * pr_addr(struct in6_addr *addr)
{
- struct hostent *hp = NULL;
+ static struct hostent *hp = NULL;
static char *s;
#ifdef USE_IDN
@@ -1803,7 +1803,7 @@
in_pr_addr = !setjmp(pr_addr_jmp);
- if (!(exiting || options&F_NUMERIC))
+ if (!hp && !(exiting || options&F_NUMERIC))
hp = gethostbyaddr((__u8*)addr, sizeof(struct in6_addr), AF_INET6);
in_pr_addr = 0;
prev parent reply other threads:[~2014-06-04 9:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-03 20:58 Small bug in ping Jakob Unterwurzacher
2014-06-04 9:50 ` David Newall [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=538EEBEF.4090500@davidnewall.com \
--to=davidn@davidnewall.com \
--cc=jakobunt@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).