diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-13 15:53:06 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-13 15:53:06 +0100 |
commit | 623e55a396597be7d6f3be332f28c2f0e3b09a1d (patch) | |
tree | 85462a39fa7ca5edd8b5d8cf0eba8f104ece3c25 /networking/traceroute.c | |
parent | d067acb0052c20edbfe7f13c99b8947ce8911eb7 (diff) | |
download | busybox-623e55a396597be7d6f3be332f28c2f0e3b09a1d.tar.gz |
traceroute: even with -v, don't show other ping processes reply's
function old new delta
traceroute_init 1135 1151 +16
common_ping_main 1919 1935 +16
common_traceroute_main 1715 1668 -47
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 32/-47) Total: -15 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/traceroute.c')
-rw-r--r-- | networking/traceroute.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c index 8ab4caefe..c1eb2d92e 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) { |