aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-13 15:53:06 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-13 15:53:06 +0100
commit623e55a396597be7d6f3be332f28c2f0e3b09a1d (patch)
tree85462a39fa7ca5edd8b5d8cf0eba8f104ece3c25
parentd067acb0052c20edbfe7f13c99b8947ce8911eb7 (diff)
downloadbusybox-w32-623e55a396597be7d6f3be332f28c2f0e3b09a1d.tar.gz
busybox-w32-623e55a396597be7d6f3be332f28c2f0e3b09a1d.tar.bz2
busybox-w32-623e55a396597be7d6f3be332f28c2f0e3b09a1d.zip
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>
-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 5f7e5b9b5..318d561bb 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -332,6 +332,11 @@ static int common_ping_main(sa_family_t af, char **argv)
332 332
333 create_icmp_socket(lsa); 333 create_icmp_socket(lsa);
334 G.myid = (uint16_t) getpid(); 334 G.myid = (uint16_t) getpid();
335 /* we can use native-endian ident, but other Unix ping/traceroute
336 * utils use *big-endian pid*, and e.g. traceroute on our machine may be
337 * *not* from busybox, idents may collide. Follow the convention:
338 */
339 G.myid = htons(G.myid);
335#if ENABLE_PING6 340#if ENABLE_PING6
336 if (lsa->u.sa.sa_family == AF_INET6) 341 if (lsa->u.sa.sa_family == AF_INET6)
337 ping6(lsa); 342 ping6(lsa);
@@ -927,6 +932,11 @@ static int common_ping_main(int opt, char **argv)
927 G.interval_us = interval * 1000000; 932 G.interval_us = interval * 1000000;
928 933
929 myid = (uint16_t) getpid(); 934 myid = (uint16_t) getpid();
935 /* we can use native-endian ident, but other Unix ping/traceroute
936 * utils use *big-endian pid*, and e.g. traceroute on our machine may be
937 * *not* from busybox, idents may collide. Follow the convention:
938 */
939 myid = htons(myid);
930 hostname = argv[optind]; 940 hostname = argv[optind];
931#if ENABLE_PING6 941#if ENABLE_PING6
932 { 942 {
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)
659 659
660 if ((option_mask32 & OPT_USE_ICMP) 660 if ((option_mask32 & OPT_USE_ICMP)
661 && type == ICMP_ECHOREPLY 661 && type == ICMP_ECHOREPLY
662 && icp->icmp_id == ident
663 && icp->icmp_seq == htons(seq) 662 && icp->icmp_seq == htons(seq)
664 ) { 663 ) {
664 if (icp->icmp_id != ident)
665 /* reply to another ping/traceroute from this box? */
666 return 0; /* ignore, silently */
665 /* In UDP mode, when we reach the machine, we (usually) 667 /* In UDP mode, when we reach the machine, we (usually)
666 * would get "port unreachable" - in ICMP we got "echo reply". 668 * would get "port unreachable" - in ICMP we got "echo reply".
667 * Simulate "port unreachable" for caller: 669 * Simulate "port unreachable" for caller:
@@ -726,9 +728,11 @@ packet6_ok(int read_len, int seq)
726 728
727 if ((option_mask32 & OPT_USE_ICMP) 729 if ((option_mask32 & OPT_USE_ICMP)
728 && type == ICMP6_ECHO_REPLY 730 && type == ICMP6_ECHO_REPLY
729 && icp->icmp6_id == ident
730 && icp->icmp6_seq == htons(seq) 731 && icp->icmp6_seq == htons(seq)
731 ) { 732 ) {
733 if (icp->icmp6_id != ident)
734 /* reply to another ping/traceroute from this box? */
735 return 0; /* ignore, silently */
732 /* In UDP mode, when we reach the machine, we (usually) 736 /* In UDP mode, when we reach the machine, we (usually)
733 * would get "port unreachable" - in ICMP we got "echo reply". 737 * would get "port unreachable" - in ICMP we got "echo reply".
734 * Simulate "port unreachable" for caller: 738 * Simulate "port unreachable" for caller:
@@ -988,6 +992,11 @@ traceroute_init(int op, char **argv)
988 outip = xzalloc(packlen); 992 outip = xzalloc(packlen);
989 993
990 ident = getpid(); 994 ident = getpid();
995 /* we can use native-endian ident, but other Unix ping/traceroute
996 * utils use *big-endian pid*, and e.g. ping on our machine may be
997 * *not* from busybox, idents may collide. Follow the convention:
998 */
999 ident = htons(ident);
991 1000
992 outdata = (void*)(outudp + 1); 1001 outdata = (void*)(outudp + 1);
993 if (af == AF_INET) { 1002 if (af == AF_INET) {