aboutsummaryrefslogtreecommitdiff
path: root/sbin/ping
Commit message (Collapse)AuthorAgeFilesLines
* ipsec: Fix typos in references to IPsec's ESPMateusz Piotrowski2025-12-041-2/+2
| | | | | | | | | | | | ESP is "Encapsulating Security Payload", not "Encapsulated Security Payload". This patch fixes all the place in the tree I could find with `grep -i encapsulated security`. MFC after: 3 days Reviewed by: ae Differential Revision: https://reviews.freebsd.org/D53769
* Ping: Make build reproducibleColin Percival2025-10-141-1/+2
| | | | | | | | | | | | | | | As recently fixed in sockstat (9934558460e4), having tests/Makefile include files from the parent directory with SRCS= ../foo.c results in a race condition as the parent build and the tests build try to produce the same object file but contain different paths. Use .PATH to tell make to find sockstat.c in the parent directory but place the object file in the current object directory. Reviewed by: emaste, jrtc27, kevans MFC after: 3 days Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D53075
* ping: Remove unnecessary compiler flagDag-Erling Smørgrav2025-07-301-2/+0
| | | | This reverts commit 55e0aefae688075718e212594e823fe5fbfba4bf.
* ping.8: typo fix, indentifying -> identifyingMaxim Konovalov2024-12-291-1/+1
|
* ping: remove a stray tabMaxim Konovalov2024-12-281-1/+1
| | | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D48233
* ping: adjust error messages and comments for -gGh flagsMaxim Konovalov2024-12-281-9/+9
| | | | | | | | | | The -gGh flags are used for sweep ping to specify minimal, maximum and increment sizes for the ICMP payload, not the packet size. Adjust the error messages and comments accordingly. Reviewed by: glebius Differential Revision: https://reviews.freebsd.org/D48232
* ping: correct minimal payload size for the sweep pingMaxim Konovalov2024-12-281-1/+1
| | | | | | | | | | The -g flag specifies a minimal payload size for the sweep ping and its default is zero. Make it possible to do ping -g 0 ..., i.e., start with no payload. Reviewed by: glebius Differential Revision: https://reviews.freebsd.org/D48231
* ping tests: Run tests unprivileged inside a vnetJose Luis Duran2024-11-051-0/+2
| | | | | | | | | | | | In order to create vnet jails, atf_python needs root privileges. However, once the vnet is created, its privileges inside the vnet can be demoted, as these tests should not require root in order to pass. Reviewed by: markj Approved by: emaste (mentor) Fixes: 4efaf43c6fa7 ("ping: Require root user for pytests") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42175
* ping tests: Silence deprecation warningsJose Luis Duran2024-11-051-4/+4
| | | | | | | | Declare some regex patterns as a raw string by prepending `r`. Reviewed by: markj Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D42174
* ping: tests: Align with Scapy defaultsJose Luis Duran2024-11-051-5/+5
| | | | | | | | | | | Align some of pinger() defaults with Scapy to facilitate debugging when printing packets. No functional change intended. Reviewed by: emaste, kp Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D47159
* ping: tests: Cleanup IPOption()sJose Luis Duran2024-11-051-4/+4
| | | | | | | | | | | Scapy now only accepts known options with IPOption(), so our unknown option must be passed raw. While here, prefer the named options for EOL and NOP. Reviewed by: emaste, kp Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D47160
* Revert "Reapply "sbin/ping: allow normal users to specify larger packets""Mark Johnston2024-10-202-6/+8
| | | | | | | | | The value of MAXPAYLOAD in the re-applied commit is not right. Back this out until it's had a proper review. This reverts commit b88df1e893c455731c7915f72a3b97b078ab04e2. Requested by: maxim, glebius
* Reapply "sbin/ping: allow normal users to specify larger packets"Pedro F. Giffuni2024-10-162-8/+6
| | | | | | | | | The ping tests were originally broken by an unrelated isue that is now fixed ( 2926c2594249f64fecbbdcb0b0b9a3591931ab04 ). THanks to kp@ for fixing the test and Jose Luis Duran for pinting it out. This reverts commit 7bc0cb91a2dfc7e23d96efd0fb7866ee2a23ba88.
* ping tests: fix for scapy-2.6.0Kristof Provost2024-10-161-1/+1
| | | | | | | | | | | | Scapy 2.6.0 now appears to parse the IPOption during construction, and it then gets confused at a single-byte option. IP Options typically contain at least a 1 byte type and 1 byte length. Avoid this by just returning the raw bytes, rather than an IPOption object. MFC after: 1 week Reviewed by: Jose Luis Duran <jlduran@gmail.com> Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D47151
* Revert "sbin/ping: allow normal users to specify larger packets"Pedro F. Giffuni2024-10-162-6/+8
| | | | | | It is causing test failures. This reverts commit 80a5b26871e90a0ad99d95bd129343471a7a36e3.
* sbin/ping: allow normal users to specify larger packetsPedro F. Giffuni2024-10-162-8/+6
| | | | | | | | | | | | | | | Only super-user could specify a packet size larger than the default 56 bytes. This restriction was added by Matt Dillon in 1998 during the BEST days [0]. This restriction doesn't exist in ping IPV6 or on NetBSD, OpenBSD and Linux. UMS [1] uses this feature to estimate the client's bandwidth to optimize the streaming experience. [0] DFGit 526f06b278d9252add168aa18b60242c08771165 [1] UMS: https://github.com/UniversalMediaServer/UniversalMediaServer Obtained from: DragonFlyBSD Differential Revision: https://reviews.freebsd.org/D45774
* Update Makefile.depend filesSimon J. Gerraty2024-10-141-0/+15
| | | | | | | After building packages we have a number of new and updated Makefile.depend files Reviewed by: stevek
* Remove residual blank line at start of MakefileWarner Losh2024-07-152-2/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* ping: Fix protocol selection with NOINET6 kernel.Dag-Erling Smørgrav2024-03-121-1/+1
| | | | | | | | | | | | | A missing else caused the correct resolver hint (AF_INET) to be overwritten with AF_UNSPEC when the kernel supports IPv4 but not IPv6. MFC after: 3 days PR: 277592 Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D44304
* ping(8): Fix typo in ping6.cHao-Yu Hou2024-02-131-3/+3
| | | | | | | | Line 703 & 863: kerel -> kernel Line 2110: resposne -> response Event: Advanced UNIX Programming Course (Fall’23) at NTHU. Pull Request: https://github.com/freebsd/freebsd-src/pull/967
* sbin: Automated cleanup of cdefs and other formattingWarner Losh2023-11-272-2/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* Remove copyright strings ifdef'd outWarner Losh2023-11-273-28/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* sbin: Remove ancient SCCS tags.Warner Losh2023-11-275-12/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* ping6(8): Add ping6(8) as MLINK to ping(8)Antranig Vartanian2023-11-071-0/+1
| | | | | | Reviewed by: chuck MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D42203
* ping tests: Fix test on i386 platformsJose Luis Duran2023-10-191-1/+1
| | | | | | | | | | | Actually use INT_MAX (0x7fffffff), not UINT_MAX (0xffffffff) to avoid overflowing time_t and missing the test. Reported by: Jenkins Reviewed by: markj Fixes: 5b8af90fe332 ("ping: Add ATF-Python tests") Pull Request: https://github.com/freebsd/freebsd-src/pull/874 Differential Revision: https://reviews.freebsd.org/D42268
* ping: Add missing ATF boilerplate.Dag-Erling Smørgrav2023-10-111-0/+5
| | | | | Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D42161
* ping: Consistently use EX_NOHOST for DNS failures.Dag-Erling Smørgrav2023-10-113-5/+46
| | | | | | | | | | | | | | Traditionally, ping returned exit code EX_NOHOST if a DNS lookup failed. That is still the case for the legacy code in the new merged ping, but not for IPv6 targets, nor when a DNS lookup is performed in order to determine which version of the tool to invoke. While here, also make sure that the error message is consistent. Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D42159
* ping: Require root user for pytestsJose Luis Duran2023-10-111-0/+2
| | | | | | | | | atf_python may use vnet jails for creating an isolated test environment. Mark these tests that require root user privileges. Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863
* ping: pr_iph() improvementsJose Luis Duran2023-10-112-14/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Very early on, the Src/Dst IP addresses were printed in hex notation (%08x), which will always be 8-characters wide. It was later changed to use a dot-decimal notation. Depending on the IP address length, the Src and Dst headers may require a different padding. Use the source and destination IP lengths as padding for the headers. Also, print an Opts (options) header, if there are options present. It has been abbreviated to Opts to match the length of the previous Data header, removed in ef9e6dc7eebe9830511602904d3ef5218d964080. Print the header info such that no trailing spaces are produced. As some git workflows may automatically trim them, and make the tests fail (see 25b86f8559c2e7076daff56933217e95cd4398d4). Before Vr HL TOS Len ID Flg off TTL Pro cks Src Dst 4 f 00 007c 0001 0 0000 40 01 d868 192.0.2.1 192.0.2.2␣ After Vr HL TOS Len ID Flg off TTL Pro cks Src Dst 4 f 00 007c 0001 0 0000 40 01 d868 192.0.2.1 192.0.2.2 And with options: Before Vr HL TOS Len ID Flg off TTL Pro cks Src Dst 4 f 00 007c 0001 0 0000 40 01 d868 192.0.2.1 192.0.2.2 01... After Vr HL TOS Len ID Flg off TTL Pro cks Src Dst Opts 4 f 00 007c 0001 0 0000 40 01 d868 192.0.2.1 192.0.2.2 01... Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D39561
* ping: Fix the spacing between the time stamp and cp/dpJose Luis Duran2023-10-112-2/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an echo reply packet is received, the data is compared with the sent data. When a wrong byte is detected the command displays a report with the differences. The first row (the first 8-bytes of data after the ICMP header) should include the time stamp (if data is at least 8-bytes), this value is not taken into consideration for the comparison. The remaining rows represent the data (padded pattern) received/sent, with each byte being compared for differences. Print the space before (not after), to add an extra space after cp:/dp: for better readability when the first time stamp octet is not zero-padded, and to remove trailing spaces in the output. Before: cp:99 0 0 c 1 5 c 0␣ ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd␣ ... After: cp: 99 0 0 c 1 5 c 0 ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd ... Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D39492
* ping: Unify ping/ping6 statistics sectionJose Luis Duran2023-10-117-291/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a first step towards a unification/simplification of ping/ping6 (internally). The end goal is to produce a standardized user-facing output. Before (ping6): PING6(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2 16 bytes from ::1, icmp_seq=0 hlim=64 time=0.168 ms 16 bytes from ::1, icmp_seq=1 hlim=64 time=0.068 ms --- 2001:db8::2 ping6 statistics --- round-trip min/avg/max/std-dev = 0.068/0.118/0.168/0.050 ms After (ping6): PING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2 16 bytes from ::1, icmp_seq=0 hlim=64 time=0.168 ms 16 bytes from ::1, icmp_seq=1 hlim=64 time=0.068 ms --- 2001:db8::2 ping statistics --- round-trip min/avg/max/stddev = 0.068/0.118/0.168/0.050 ms This has the nice side-effect of adding units to SIGINFO's statistics, as printing numbers without units may not be of much help. Also mentions the fact that these times are round-trip. Before (ping/ping6 SIGINFO): 2/2 packets received (100.0%) 0.068 min / 0.118 avg / 0.168 max After (ping/ping6 SIGINFO): --- <ipv4/ipv6 address> ping statistics --- 2 packets transmitted, 2 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.068/0.118/0.168/0.050 ms In the case of a SIGINFO, the output will be printed to stderr, for both ping and ping6. Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D39126
* ping: Specify the sigaction(2) nameJose Luis Duran2023-10-111-1/+1
| | | | | | | | | | After a2a008880568eaeb87d8404b39627b83df851f34, specify the signal name. Obtained from: Darwin MFC after: 1 week Reviewed by: asomers Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D38484
* ping: Remove an extra new line characterJose Luis Duran2023-10-112-3/+1
| | | | | | | | | This matches the behavior when an RR truncated route is printed. Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D39485
* ping tests: Test IHL/quoted data/inner packet pathsJose Luis Duran2023-10-111-0/+112
| | | | | | | | | | | | | | | | Commit 46d7b45a267b3d78c5054b210ff7b6c55bfca42b introduced these code paths. Test and document them. - Add inner packet too short test - Add inner IHL too short test - Add quoted data too short test - Add IHL too short test - Add max inner packet IHL without payload test Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D38528
* ping: Avoid reporting NaNsJose Luis Duran2023-10-112-4/+4
| | | | | | | | | | | | | | | | | | | Avoid calculating the square root of negative zero, which can easily happen on certain architectures when calculating the population standard deviation with a sample size of one, e.g., 0.01 - (0.1 * 0.1) = -0.000000. Avoid returning a NaN by capping the minimum possible variance value to zero (positive). In the future, maybe skip reporting statistics at all for a single sample. Reported by: Jenkins Reviewed by: asomers MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D42114
* ping: Simplify protocol selection.Dag-Erling Smørgrav2023-10-102-75/+76
| | | | | | | | | | | | * Interrupt the option loop as soon as we have an indication of which protocol is intended. * If we end up having to perform a DNS lookup, loop over the entire result looking for either IPv4 or IPv6 addresses. Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Reviewed by: rscheff, kevans, allanjude Differential Revision: https://reviews.freebsd.org/D42137
* ping: The -C option is also supported for IPv6.Dag-Erling Smørgrav2023-09-192-2/+3
| | | | | | | | MFC after: 3 days Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: rscheff, allanjude Differential Revision: https://reviews.freebsd.org/D41881
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-165-5/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-165-10/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-164-8/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* ping: use the in6_addr buffer when parsing src address as AF_INET6R. Christian McDonald2023-08-081-1/+1
| | | | | | Reviewed by: kp MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate")
* ping: low-effort fix to make it compilable without inet6Mateusz Guzik2023-07-051-0/+2
|
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-127-7/+7
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-1/+1
|
* ping: fix failing test_pinger[_3_1_verbose_false] test.Alexander V. Chernikov2023-04-021-1/+1
|
* ping tests: Add a regression testJose Luis Duran2023-03-271-3/+58
| | | | | | | | | | | | | Test regression fixed in 4630a3252ac8. Add two tests that do not use the verbose flag, so the code path in question can be reached: 1. Respond with a proper ICMP destination host unreachable packet. 2. Respond with a doctored ICMP destination host unreachable packet, that has the ICMP Identifier field modified (+1 bit). Reviewed by: cy MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39244
* ping: Fix an uninitialized variableJose Luis Duran2023-03-241-0/+3
| | | | | | | | | | | | | | | The variable oicmp, which holds the original ("quoted packet") ICMP packet in a structured way, did not have a copy of the original ICMP packet obtained from the raw data. The code was accidentally removed in 20b41303140e. Bring it back. Reported by: Coverity Scan, cy Reviewed by: cy CID: 1506960 (UNINIT) Fixes: 20b41303140eee4dfb896558fb83600c5f013d39 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39233
* ping: Avoid reporting negative time statisticsJose Luis Duran2023-03-192-2/+36
| | | | | | | | | Display a warning when the time goes back. PR: 192417 Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38480
* ping tests: Add tests for IP header optionsJose Luis Duran2023-03-191-1/+242
| | | | | | | | | | | | The function pr_pack() prints out a packet, if the IP packet contains options, these are printed as well. Test the functionality fixed in 70960bb86a3ba5b6f5c4652e613e6313a7ed1ac1. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38470