From: Jamie Le Tual <jamie.letual@gmail.com>
To: nedev <netdev@vger.kernel.org>
Subject: [iputils] - patch for ping to set un.echo.id to network byte order
Date: Tue, 1 Sep 2009 01:05:37 -0400 [thread overview]
Message-ID: <ebb05fd20908312205v2c6184bfi88eff30bf0834356@mail.gmail.com> (raw)
I noticed in the ping source code that the identity flag on the icmp
echo packet is set to the pid of the ping command being run. I
immediatly fired up a packet sniffer to see it, but got endian
wierdness. Looking back at the code, and comparing with ping6 and
traceroute6, I noticed that when the identity is set, its fed the
value of getpid() without running it through htons(), as is done in
traceroute6.
So this patch for the ipv4 version of ping:
diff -pu iputils-s20071127/ping_common.c iputils-jamie/ping_common.c
--- iputils-s20071127/ping_common.c 2007-11-26 19:57:27.000000000 -0500
+++ iputils-jamie/ping_common.c 2009-09-01 00:10:58.000000000 -0400
@@ -473,7 +473,7 @@ void setup(int icmp_sock)
*p++ = i;
}
- ident = getpid() & 0xFFFF;
+ ident = htons(getpid() & 0xFFFF);
set_signal(SIGINT, sigexit);
set_signal(SIGALRM, sigexit);
seems obvious enough. I figured that htons was safe enough, since
pid_t is just an int.
Is there some reason to not send the identifier properly so it doesn't
end up bass-ackwards on the receiving end?
reply other threads:[~2009-09-01 5:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=ebb05fd20908312205v2c6184bfi88eff30bf0834356@mail.gmail.com \
--to=jamie.letual@gmail.com \
--cc=netdev@vger.kernel.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