Commit Graph

47 Commits

Author SHA1 Message Date
Michael Tuexen
8ff4fc03e6 traceroute6: fix capabilities for the rcv socket
On the receive socket, recvmsg() and poll()/select() is called.
Therefore, CAP_EVENT is needed in addition to CAP_RECV..

While there, check the socket for readbility before calling recvmsg().

Reviewed by:		markj@
MFC after:		3 days
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D36878
2022-10-04 23:40:29 +02:00
Zhenlei Huang
1d712c0537 traceroute6: Properly calculate UDP checksum
The revision D25604 capsicumize traceroute6. For UDP the send socket was
changed from SOCK_DGRAM to SOCK_RAW and thus the UDP checksum need be
calculated by application itself other than the kernel.

outpacket is filled with zeros by line 707, thus the first round the UDP
checksum is correct. But subsequent rounds outudp->uh_sum will be left
with garbage.

PR:		255507
Reviewed by:	ae, markj, tuexen
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D30042
2021-05-03 13:24:30 -04:00
Mark Johnston
b8ae450f05 traceroute6: Fix Capsicum rights for rcvsock
- Always use distinct sockets for send and recv
- Limit rights on the recv socket

For ICMP6 we were using the same socket for both send and receive, and
we limited rights on the socket such that it's impossible to receive
anything.

PR:		254623
Diagnosed by:	Zhenlei Huang <zlei.huang@gmail.com>
Reviewed by:	oshogbo
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D29523
2021-04-01 10:00:29 -04:00
Adrian Chadd
5c3bf25fee [traceroute6] Don't do the casper bits when we're not doing casper
This with the previous patch I committed makes traceroute6/traceroute
compile fine when libcasper isn't enabled.

This complains strongly with unused variables and such when compiled
with gcc-6 on mips32.

Tested:

* compiled/run on mips32 hardware (AR9344)

Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D26773
2020-10-14 00:01:17 +00:00
Michael Tuexen
c70906519a Add a -t option to traceroute6 to control the traffic class used when
sending probe packets.

Reviewed by:		rscheff
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D26410
2020-09-13 09:00:00 +00:00
Michael Tuexen
3303e9bc22 Fix the length of probe packets when using UDP.
Since https://svnweb.freebsd.org/changeset/base/365378 a raw socket is
used for sending UDP probe packets instead of a UDP socket. So don't
compensate for the UDP header anymore.
2020-09-12 11:24:36 +00:00
Michael Tuexen
2d0fb1b3c1 Simplify code, no functional change.
Since https://svnweb.freebsd.org/base?view=revision&revision=365378
UDP is handled the same way as SCTP and TCP (using a raw socket).
Therefore use the same code path.
2020-09-12 11:19:54 +00:00
Mariusz Zaborski
cc432e237c traceroute6: capsicumize it
Submitted by:	Shubh Gupta <shubh@freebsd.org>
Sponsored by: Google (GSOC 2020)
Differential Revision:	https://reviews.freebsd.org/D25604
2020-09-06 14:04:02 +00:00
Mark Johnston
ca19d0d78f traceroute6: Fix most warnings at the default WARNS level.
Fix some style issues as well.  Leave -Wno-cast-aligned set for now, as
most of the warnings come casts of CMSG_DATA(), which does provide
sufficient alignment in practice.

Submitted by:	Shubh Gupta <shubh@freebsd.org>
Sponsored by:	Google (GSOC 2020)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25603
2020-07-21 15:03:36 +00:00
Alan Somers
af58a3c6bf Remove the USE_RFC2292BIS option and reap dead code
This option was imported as part of the KAME project in r62627 (in 2000).
It was turned on unconditionally in r121472 (in 2003) and has been on ever
since. The old alternative code has bitrotted. Reap the dead code.

Reported by:	Ján Sučan <jansucan@gmail.com>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D20938
2019-07-22 20:11:33 +00:00
Michael Tuexen
1f69b3fb55 Add support for ICMPv6 messages indicating a parameter problem related
to an unrecognized next header.

MFC after:		2 weeks
2019-07-16 12:57:59 +00:00
Michael Tuexen
64694fdcc0 Let packet_op() explicitly return the type and code instead of doing
this implicitly by encoding it in a number space.

No functional change intended.

This is done as a preparation to add support for ICMPv6 mesages
indicating a parameter problem related to the next header.

MFC after:		2 weeks
2019-07-16 12:38:17 +00:00
Michael Tuexen
83c022b5c0 Whitespace change. No functional change.
MFC after:		2 weeks
2019-07-16 10:06:41 +00:00
Michael Tuexen
51eff8efd9 When using SCTP for sending probe packets, use INIT chunks for payloads
larger than or equal to 32 bytes. For smaller probe packets, keep using
SHUTDOWN-ACK chunks, possibly bundled with a PAD chunk.
Packets with INIT chunks more likely pass through firewalls. Therefore,
use them when possible.

MFC after:	1 week
2018-01-27 19:23:42 +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
Michael Tuexen
d55fae0299 Fix reporting of probing size. This bug was introduced in r324119.
MFC after:	4 weeks
2017-09-30 12:30:05 +00:00
Michael Tuexen
9d8b46c89c Add SCTP and TCP as protocols for sending probe packets.
MFC after:	4 weeks
2017-09-30 11:45:33 +00:00
Michael Tuexen
aa96470cc9 * Update function definitions.
* Ensure that the datalen always describes the length after the IPv6
  header consistently, not matter which protocol us used for probes..
* Document that the default length is 20, not 12.
* Don't send inormation in probe packets which is not needed or
  even checked when the responses are processed.
* Address CID 978587.

This is mainly a cleanup preparing the addition of SCTP and TCP
as possible probe packet protocols.

MFC after:	4 weeks
2017-09-30 11:40:18 +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
Hiroki Sato
161ab37d24 Fix an infinite loop at an non-responding hop when other echo replies
are kept arriving in the waittime time window.

Submitted by:	Denny Page
PR:		210286
MFC after:	3 days
2016-11-05 18:00:36 +00:00
Pedro F. Giffuni
ac97203f5b traceroute6(8): use NULL instead of zero for initializing a pointer. 2016-05-12 02:05:50 +00:00
Hajimu UMEMOTO
0d7d117c7f Add -a and -A option to the usage.
MFC after:	1 week
2012-05-08 15:18:35 +00:00
Joel Dahl
914e11a72b Remove the advertising clause from UCB copyrighted files in usr.sbin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
2010-12-11 09:38:12 +00:00
Ulrich Spörlein
f42640a362 traceroute6(8): make WARNS=3 clean 2010-12-04 14:19:35 +00:00
Hajimu UMEMOTO
d429d7201e - Add AS lookup functionality to traceroute6(8) as well.
- Support for IPv6 transport for AS lookup.
- Introduce $RA_SERVER to set whois server.
- Support for 4 byte ASN.
- ANSIfy function declaration in as.c.

Tested by:	IHANet folks.
2009-08-23 17:00:16 +00:00
David Malone
d7b63faf0c Give traceroute6 the ability to traceroute with packets with no
upper layer header (IP PROTO = 59). Useful for testing firewalls.

MFC after:	2 months
2008-02-10 21:06:38 +00:00
Kevin Lo
784bddbc5b Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
Christian S.J. Peron
59876f938e When processing multi-path ip6 routers, place each router entry on its
own line.  We made this change in traceroute(8) some time ago.  This
is particularly useful when you are not resolving hostnames since ip6
addresses can be quite long, and lines wrap fairly easily in the
multi-path router case.

Discussed with:	bz
MFC after:	1 month
2007-10-24 00:50:13 +00:00
George V. Neville-Neil
8409aedfa6 Commit IPv6 support for FAST_IPSEC to the tree.
This commit includes all remaining changes for the time being including
user space updates.

Submitted by:    bz
Approved by:    re
2007-07-01 12:08:08 +00:00
Maxim Konovalov
eea319c4b7 o I failed to find a suitable explanation why traceroute(8) and
traceroute6(8) force -w flag (wait time) to be > 1 sec.  Make it
possible to use 1 sec wait time.

PR:		bin/110933
Submitted by:	Dmitry Marakasov
Reviewed by:	freebsd-net (silence)
MFC after:	1 month
2007-04-30 19:08:13 +00:00
Kevin Lo
19c7ed845e Use setresuid for simple privilege dropping. 2007-03-08 03:49:23 +00:00
David Malone
e961704aa6 Sync up with KAME. The main change is to try to avoid exposing
exposing information about the endianness and alighment requirements
in the packets sent by traceroute6.

Obtained from:	KAME
2004-06-13 18:38:46 +00:00
Hajimu UMEMOTO
84a1a4cfab - setsockopt/sysctl takes int, not u_long.
- be more picky about argument parsing - like ERANGE.
- use u_long for args, not to lose accuracy/prevent overflow.
- socklen_t audit.
- Add -I (use icmp) option.
- warn if multiple addresses are present for dest.
- no need to pass tz.
- type pedant.  check -p range.
- grab hlim from sysctl.
- typo in port number setting.

Obtained from:	KAME
2003-11-12 18:56:59 +00:00
Hajimu UMEMOTO
c449e28482 - style
- index() -> strchr()
- stop use of MAXHOSTNAMELEN

Obtained from:	KAME
2003-10-23 17:36:29 +00:00
Hajimu UMEMOTO
d24cb2490d stop use of NI_WITHSCOPEID. it was deprecated.
Obtained from:	KAME
2003-10-21 20:11:47 +00:00
Maxim Konovalov
3111be41c2 Quote from a Problem Report:
The output format specifier for the round-trip time in ping6 should be
changed to %.3f instead of %g since %g doesn't accurately represent the
precision of the number being output. In particular, %g truncates trailing
zeroes. 0.01 ms does not mean the same thing as 0.010 ms. Although they
are numerically identical, they do not have the same precision.

PR:		bin/52324, bin/52750
Submitted by:	dg
MFC after:	1 week
2003-07-21 11:06:47 +00:00
Jens Schweikhardt
9d5abbddbf Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
2003-01-01 18:49:04 +00:00
Jacques Vidrine
c3e3619908 Back out previous commit. I was a bit overzealous: the fd_set size is
calculated dynamically here.
2002-09-09 16:43:18 +00:00
Jacques Vidrine
acc005185b Check for FD_SET overrun. 2002-09-09 16:21:10 +00:00
Hajimu UMEMOTO
3384154590 Sync with recent KAME.
This work was based on kame-20010528-freebsd43-snap.tgz and some
critical problem after the snap was out were fixed.
There are many many changes since last KAME merge.

TODO:
  - The definitions of SADB_* in sys/net/pfkeyv2.h are still different
    from RFC2407/IANA assignment because of binary compatibility
    issue.  It should be fixed under 5-CURRENT.
  - ip6po_m member of struct ip6_pktopts is no longer used.  But, it
    is still there because of binary compatibility issue.  It should
    be removed under 5-CURRENT.

Reviewed by:	itojun
Obtained from:	KAME
MFC after:	3 weeks
2001-06-11 12:39:29 +00:00
Kris Kennaway
2a1c5efaa8 Sync with KAME. Don't write past the end of the fd_set.
Obtained from:	KAME
2000-10-08 07:52:08 +00:00
Kris Kennaway
d94e8c62d6 Don't call errx() without a format string, to protect against possible
localized error messages from ipsec_strerror().

Obtained from:	OpenBSD
2000-08-05 06:21:12 +00:00
Kris Kennaway
de68a0dac8 Sync with latest KAME code.
Obtained from:	KAME
2000-07-05 11:00:58 +00:00
Yoshinobu Inoue
53c9088f68 Security fixes. (Just same as sbin/ping and usr.sbin/traceroute)
-Open socket() at first and then setuid() to actual user.
  -Allow ping6 preload option only for root.

Approved by: jkh

Submitted by: Neil Blakey-Milner <nbm@mithrandr.moria.org>
2000-02-24 19:06:05 +00:00
Yoshinobu Inoue
39865d6488 replace gethostbyname() with getaddrinfo(), and gethostbyaddr() with
getipnodebyaddr().
This resolve 2 problems.
 -can specify scope index(@ifname) for IPv6 link local addr
 -reverse lookup for IPv6 loopback addr(::1) was strange, but fixed
2000-01-09 12:46:35 +00:00
Yoshinobu Inoue
04e8772051 remove redundant ifdef's.
some part is specified by: phantom
2000-01-07 10:02:43 +00:00
Yoshinobu Inoue
7d56d3747c Getaddrinfo(), getnameinfo(), and etc support in libc/net.
Several udp and raw apps IPv6 support.

Reviewed by: freebsd-arch, cvs-committers
Obtained from: KAME project
1999-12-28 02:37:14 +00:00