summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/ping.c10
-rw-r--r--networking/traceroute.c13
2 files changed, 21 insertions, 2 deletions
diff --git a/networking/ping.c b/networking/ping.c
index 5f7e5b9..318d561 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -332,6 +332,11 @@ static int common_ping_main(sa_family_t af, char **argv)
create_icmp_socket(lsa);
G.myid = (uint16_t) getpid();
+ /* we can use native-endian ident, but other Unix ping/traceroute
+ * utils use *big-endian pid*, and e.g. traceroute on our machine may be
+ * *not* from busybox, idents may collide. Follow the convention:
+ */
+ G.myid = htons(G.myid);
#if ENABLE_PING6
if (lsa->u.sa.sa_family == AF_INET6)
ping6(lsa);
@@ -927,6 +932,11 @@ static int common_ping_main(int opt, char **argv)
G.interval_us = interval * 1000000;
myid = (uint16_t) getpid();
+ /* we can use native-endian ident, but other Unix ping/traceroute
+ * utils use *big-endian pid*, and e.g. traceroute on our machine may be
+ * *not* from busybox, idents may collide. Follow the convention:
+ */
+ myid = htons(myid);
hostname = argv[optind];
#if ENABLE_PING6
{
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 8ab4cae..c1eb2d9 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -659,9 +659,11 @@ packet4_ok(int read_len, int seq)
if ((option_mask32 & OPT_USE_ICMP)
&& type == ICMP_ECHOREPLY
- && icp->icmp_id == ident
&& icp->icmp_seq == htons(seq)
) {
+ if (icp->icmp_id != ident)
+ /* reply to another ping/traceroute from this box? */
+ return 0; /* ignore, silently */
/* In UDP mode, when we reach the machine, we (usually)
* would get "port unreachable" - in ICMP we got "echo reply".
* Simulate "port unreachable" for caller:
@@ -726,9 +728,11 @@ packet6_ok(int read_len, int seq)
if ((option_mask32 & OPT_USE_ICMP)
&& type == ICMP6_ECHO_REPLY
- && icp->icmp6_id == ident
&& icp->icmp6_seq == htons(seq)
) {
+ if (icp->icmp6_id != ident)
+ /* reply to another ping/traceroute from this box? */
+ return 0; /* ignore, silently */
/* In UDP mode, when we reach the machine, we (usually)
* would get "port unreachable" - in ICMP we got "echo reply".
* Simulate "port unreachable" for caller:
@@ -988,6 +992,11 @@ traceroute_init(int op, char **argv)
outip = xzalloc(packlen);
ident = getpid();
+ /* we can use native-endian ident, but other Unix ping/traceroute
+ * utils use *big-endian pid*, and e.g. ping on our machine may be
+ * *not* from busybox, idents may collide. Follow the convention:
+ */
+ ident = htons(ident);
outdata = (void*)(outudp + 1);
if (af == AF_INET) {