Commit Graph

225 Commits

Author SHA1 Message Date
Simon J. Gerraty
2c9a9dfc18 Update Makefile.depend files
Update a bunch of Makefile.depend files as
a result of adding Makefile.depend.options files

Reviewed by:	 bdrewery
MFC after:	1 week
Sponsored by:   Juniper Networks
Differential Revision:  https://reviews.freebsd.org/D22494
2019-12-11 17:37:53 +00:00
Simon J. Gerraty
5ab1c5846f Add Makefile.depend.options
Leaf directories that have dependencies impacted
by options need a Makefile.depend.options file
to avoid churn in Makefile.depend

DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc
can be set in local.dirdeps-options.mk
which can add to those set in Makefile.depend.options

See share/mk/dirdeps-options.mk

Reviewed by:	 bdrewery
MFC after:	1 week
Sponsored by:   Juniper Networks
Differential Revision:  https://reviews.freebsd.org/D22469
2019-12-11 17:37:37 +00:00
Alan Somers
2eb6acc277 ping, ping6: Use setitimer(2) instead of obsolete alarm(3)
Submitted by:	Ján Sučan <sucanjan@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D22103
2019-11-26 05:06:25 +00:00
Alan Somers
b17fb99228 ping: Verify whether a datagram timestamp was actually received.
ping(8) uses SO_TIMESTAMP, which attaches a timestamp to each IP datagram at
the time it's received by the kernel.  Except that occasionally it doesn't.
Add a check to see whether such a timestamp was actually set before trying
to read it.  This fixes segfaults that can happen when the kernel doesn't
attach a timestamp.

The bug has always existed, but prior to r351461 it manifested as an
implausible round-trip-time, not a segfault.

Reported by:	pho
MFC after:	3 days
MFC-With:	351461
2019-09-11 18:54:45 +00:00
Alan Somers
301bc9f959 ping: fix a string in an error message
MFC after:	3 days
2019-09-11 18:08:40 +00:00
Alan Somers
95b523ea71 ping: raise WARNS level to 6
Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21405
2019-08-27 15:34:37 +00:00
Alan Somers
67511a4c4c ping: fix unaligned access to ancillary data
Use CMSG_FIRSTHDR rather than assume that an array is correctly aligned.
Fixes warnings on sparc64 and powerpcspe.

Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFH:		2 weeks
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21406
2019-08-24 18:00:18 +00:00
Alan Somers
d9cacf605e ping: Fix alignment errors
This fixes -Wcast-align errors when compiled with WARNS=6.

Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21327
2019-08-23 22:04:26 +00:00
Alan Somers
ec7ea489e0 ping: fix include guard symbol name to reflect the header file name
Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
MFC-With:	351171
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21374
2019-08-23 15:24:18 +00:00
Alan Somers
299e2c58b7 ping: By default, don't reverse lookup IP addresses
ping's default is now not to attempt reverse DNS lookups.  The -H flag will
enable them.  This change is not quite a reversion of r351330.  That change
made the happy path and error path do reverse lookups consistently; this
change changes the default for both paths.

Submitted by:	Ján Sučan <sucanjan@gmail.com>
Discussed with:	cem
MFC after:	2 weeks
MFC-With:	351330
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21364
2019-08-22 18:57:24 +00:00
Alan Somers
7cc426fb42 ping: add a basic functional test
Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google, inc. (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21289
2019-08-22 15:00:36 +00:00
Alan Somers
99f13ae12c ping: add -H option for enabling reverse DNS lookup
This is the reverse of the -n flag.

Submitted by:	Ján Sučan <sucanjan@gmail.com>
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21356
2019-08-21 21:05:15 +00:00
Alan Somers
229e8bf2bb ping: do reverse DNS lookup of the target address
When printing replies, ping will now attempt a reverse DNS lookup of the
target.  That can be suppressed by using the "-n" option.  Curiously, ping
has always done reverse lookups in certain error paths, but never in the
success path.

Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21351
2019-08-21 14:52:12 +00:00
Alan Somers
c43633c6a1 ping: Add tests of the Internet checksum function
Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21340
2019-08-20 21:59:48 +00:00
Alan Somers
a3ce769851 Fix uninitialized variable warnings when MK_CASPER=no
Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google, inc. (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21322
2019-08-19 17:54:40 +00:00
Alan Somers
7898770a26 ping: fix -Wformat-truncating warning with GCC
Increase buffer size for the string representation of n_time

ICMP timestamp is a 32-bit number. In pr_ntime(), number of minutes
and seconds is always 2 characters wide. Max. number of hours is 4
characters wide. The buffer size should be at least:

4 + 2 + 2 + 1 (':') + 1 (':') + 1 ('\0') = 11

Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google, inc. (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21325
2019-08-19 17:28:12 +00:00
Alan Somers
ff77ab831a ping: Move in_cksum() to a separate source file
This is a preparation step for adding ATF tests of in_cksum(), which has been
modified to operate on unaligned data. ping.o cannot be linked to the test
executable because both of them contain 'main' symbol.

Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google, inc. (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21288
2019-08-17 15:25:01 +00:00
Alan Somers
d63a94876b ping: Make in_cksum() operate on u_char buffer
This fixes -Wcast-align errors for in_cksum() calls when compiled with
WARNS=6.

Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google, inc. (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21261
2019-08-14 16:55:06 +00:00
Alan Somers
84633ef14a ping: fix triptime calculation after r350998
That revision changed the internal clock to the monotonic, but neglected to
change the datagram's timestamp source.

Reported by:	Oliver Hartmann, Michael Butler
Reviewed by:	Ján Sučan <sucanjan@gmail.com>, allanjude
MFC after:	2 weeks
MFC-With:	r350998
Differential Revision:	https://reviews.freebsd.org/D21258
2019-08-14 16:45:09 +00:00
Alan Somers
1ad76f1b60 ping: use the monotonic clock to measure durations
Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google, inc. (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21245
2019-08-13 19:27:23 +00:00
Alan Somers
2c29d74c4f ping: fix data type of a variable for a packet sequence number
Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google, inc. (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21244
2019-08-13 16:25:23 +00:00
Warner Losh
01b0122954 Remove all the RELEASE_CRUNCH instances that partially disable IPSEC
We remove IPSEC only in parts of the tree, and not others. RELEASE_CRUNCH to
disable it has not kept up with all its uses. Remove it. Should there be a real
need to disable IPSEC, one that hasn't shown up in the base system to date,
it can be re-added behind a WITHOUT_IPSEC build option.
2019-07-15 14:19:39 +00:00
Mark Johnston
18fcfaa4ca Use caph_enter_casper() in ping(8).
Reported by:	oshogbo
MFC with:	r341837
Sponsored by:	The FreeBSD Foundation
2018-12-18 16:47:03 +00:00
Mark Johnston
7bdc329113 Use Capsicum helpers in ping(8).
Also use caph_cache_catpages() to ensure that strerror() works when
run with kern.trap_enotcap=1.

Reviewed by:	oshogbo
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18514
2018-12-12 02:33:01 +00:00
Eugene Grosbein
2d0a6ce24c ping(8): add space after "<=" as per style(9).
MFC after:	1 week
X-MFC-with:	r341768
2018-12-10 14:39:21 +00:00
Eugene Grosbein
65c3a67d23 ping(8): remove needless comparision with LONG_MAX
after unsigned long ultmp changed to long ltmp in r340245.

MFC after:	1 week
2018-12-09 21:11:15 +00:00
Mariusz Zaborski
752d135e0d libcasper: ange the name of limits in cap_dns so the intentions are obvious.
Reported by:	pjd
MFC after:	3 weeks
2018-11-12 15:52:45 +00:00
Eugene Grosbein
c0a3773ad2 ping(8): improve diagnostics in case of wrong arguments.
For example, in case of super-user:
$ sudo ping -s -64 127.0.0.1
PING 127.0.0.1 (127.0.0.1): -64 data bytes
ping: sendto: Invalid argument

For unprivileged user:
$ ping -s -64 127.0.0.1
ping: packet size too large: 18446744073709551552 > 56: Operation not permitted

Fix this by switching from strtoul() to strtol() for integer arguments
and adding explicit checks for negative values.

MFC after:	1 month
2018-11-08 09:45:13 +00:00
Mariusz Zaborski
d68e2c047b ping: simplify use of Casper
There is no need to check if capdns is NULL.
If we will build the system without casper all cap_gethostaddr will be
replaced by the standard functions.
2018-11-04 20:26:29 +00:00
Ed Maste
2c208ed867 Allow dhclient and ping to build WITHOUT_DYNAMICROOT
dhclient and ping normally use libcasper services.  These are not
available in statically-linked binaries, so when WITHOUT_DYNAMICROOT is
set disable libcasper use, as with rescue builds.  Also emit a warning
as it's undesirable to build this way.

Reported by:	Michael Dexter
Reviewed by:	rgrimes
Tested by:	Michael Dexter
Approved by:	re (kib)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17074
2018-09-09 17:26:44 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Mariusz Zaborski
8751b03b19 We return a pointer when we are using cap_init() or cap_service_open()
function, so check if cap_chanel_t is NULL is not enough.
Casper with a normal libc will still fail in capability mote so let's not
enter capability mode without casper support when we need to resolve DNS.

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D12823
2017-11-12 07:18:10 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Mariusz Zaborski
0b9d37d25f Simplify ping sandbox.
We don't need to check if casper is present, this is done in the library itself.

Reviewed by:	emaste, cem, ed
Differential Revision:	https://reviews.freebsd.org/D8754
2017-10-28 19:39:22 +00:00
Mariusz Zaborski
2560d18180 We use a few different ifdef's names to check if we are using Casper or not,
let's standardize this. Now we are always use WITH_CASPER name.

Discussed with:	emaste@
MFC after:	1 month
2017-09-21 14:41:41 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Dimitry Andric
a94c074d6a Fix clang 4.0.0 warnings about taking the address of a packed member of
struct ip in ping(8):

sbin/ping/ping.c:1684:53: error: taking address of packed member
'ip_src' of class or structure 'ip' may result in an unaligned pointer
value [-Werror,-Waddress-of-packed-member]
        (void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_src.s_addr));
                                                           ^~~~~~~~~~~~~~~~~
sbin/ping/ping.c:1685:53: error: taking address of packed member
'ip_dst' of class or structure 'ip' may result in an unaligned pointer
value [-Werror,-Waddress-of-packed-member]
        (void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_dst.s_addr));
                                                           ^~~~~~~~~~~~~~~~~

MFC after:	3 days
2017-01-06 18:41:28 +00:00
Don Lewis
eeb6394364 Check for socket creation success before calling bind().
Reported by:	Coverity
CID:		1194209
2016-05-12 05:43:54 +00:00
Glen Barber
d60840138f MFH
Sponsored by:	The FreeBSD Foundation
2016-04-04 23:55:32 +00:00
Maxim Konovalov
028c7845c0 o Restore some good whitespace killed in the previous commit.
Spotted by:	bjk
2016-03-18 15:44:21 +00:00
Maxim Konovalov
61273736b3 o Kill EoL whitespaces. 2016-03-18 15:07:43 +00:00
Maxim Konovalov
f7fc5c9154 o No need to resolve a mask that we get with ICMP_MASKREPLY,
pass it directly to inet_ntoa(3).
2016-03-18 15:06:50 +00:00
Glen Barber
538354481e MFH
Sponsored by:	The FreeBSD Foundation
2016-03-14 18:54:29 +00:00
Gleb Smirnoff
bb7dfe5e49 Allow minimum and maximum sweep size be the same.
Submitted by:	maxim
2016-03-11 21:06:17 +00:00
Maxim Konovalov
ed5e3d7a83 o Kill EoL whitespaces. No functional changes. 2016-03-11 16:03:47 +00:00
Maxim Konovalov
3c32812b1b o Xr icmp(4). 2016-03-11 15:29:00 +00:00
Maxim Konovalov
4323cae0bd o Document net.inet.icmp.maskfake and net.inet.icmp.tstamprepl sysctls. 2016-03-11 15:26:56 +00:00
Glen Barber
52259a98ad MFH
Sponsored by:	The FreeBSD Foundation
2016-03-02 16:14:46 +00:00
Bryan Drewery
3055a28d44 Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-02-26 22:14:15 +00:00
Mariusz Zaborski
c501d73c7e Convert casperd(8) daemon to the libcasper.
After calling the cap_init(3) function Casper will fork from it's original
process, using pdfork(2). Forking from a process has a lot of advantages:
1. We have the same cwd as the original process.
2. The same uid, gid and groups.
3. The same MAC labels.
4. The same descriptor table.
5. The same routing table.
6. The same umask.
7. The same cpuset(1).
From now services are also in form of libraries.
We also removed libcapsicum at all and converts existing program using Casper
to new architecture.

Discussed with:		pjd, jonathan, ed, drysdale@google.com, emaste
Partially reviewed by:	drysdale@google.com, bdrewery
Approved by:		pjd (mentor)
Differential Revision:	https://reviews.freebsd.org/D4277
2016-02-25 18:23:40 +00:00