git: 9b7a920a12a9 - main - traceroute: move from contrib to usr.sbin
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 08 Feb 2024 16:55:05 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=9b7a920a12a9377b9c8227f72748ab32fbbb4822 commit 9b7a920a12a9377b9c8227f72748ab32fbbb4822 Author: Lexi Winter <lexi@le-Fay.ORG> AuthorDate: 2024-02-03 13:10:09 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-02-08 16:52:42 +0000 traceroute: move from contrib to usr.sbin traceroute hasn't had a vendor import since 2002, while since then it's had several significant FreeBSD-specific commits. Since it's unlikely another vendor import will happen, and to make the merge of traceroute6 into traceroute easier, import traceroute into usr.sbin. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1100 --- contrib/traceroute/CHANGES | 148 --------------------- contrib/traceroute/FILES | 37 ------ contrib/traceroute/FREEBSD-upgrade | 36 ----- contrib/traceroute/INSTALL | 105 --------------- contrib/traceroute/README | 29 ---- contrib/traceroute/VERSION | 1 - contrib/traceroute/mean.awk | 12 -- contrib/traceroute/median.awk | 29 ---- contrib/traceroute/rip_output.c | 73 ---------- usr.sbin/traceroute/Makefile | 14 +- {contrib => usr.sbin}/traceroute/as.c | 0 {contrib => usr.sbin}/traceroute/as.h | 0 .../traceroute/findsaddr-socket.c | 0 {contrib => usr.sbin}/traceroute/findsaddr.h | 0 {contrib => usr.sbin}/traceroute/ifaddrlist.c | 0 {contrib => usr.sbin}/traceroute/ifaddrlist.h | 0 {contrib => usr.sbin}/traceroute/traceroute.8 | 0 {contrib => usr.sbin}/traceroute/traceroute.c | 3 - {contrib => usr.sbin}/traceroute/traceroute.h | 0 19 files changed, 1 insertion(+), 486 deletions(-) diff --git a/contrib/traceroute/CHANGES b/contrib/traceroute/CHANGES deleted file mode 100644 index 25ef7bedc43f..000000000000 --- a/contrib/traceroute/CHANGES +++ /dev/null @@ -1,148 +0,0 @@ -@(#) $Id: CHANGES,v 1.23 2000/12/14 06:53:11 leres Exp $ (LBL) - -v1.4 Wed Dec 13 22:50:35 PST 2000 - -- Add an option to use icmp echo instead of udp datagrams. - -- Add HPUX and Linux support. - -- Handle hex argument values as suggested by John Hawkinson - (jhawk@mit.edu) - -- Added flags to set the first ttl and to set the don't fragment bit. - -- Add a local autoconf macro to check for routines in libraries; the - autoconf version is broken (it only puts the library name in the - cache variable name). Thanks to John Hawkinson. - -- Add a local autoconf macro to check for types; the autoconf version - is broken (it uses grep instead of actually compiling a code fragment). - -- Attempt to detect "egcs" versions of gcc. - -- Fix problems caused by savestr(). - -- Detect when there are more interfaces than we can deal with. Thanks - to Guy Harris guy@netapp.com. - -- Accommodate changes made to FreeBSD 3.2-RELEASE network headers files. - -- The ip header offset needs to be byte swapped under Solaris on the - intel as well. Reported by John McDermott (jjm@jkintl.com) Also byte - ip length and offset for linux. - -- In wait_for_reply(), use passed socket instead of global one. Thanks - to Richard Kettlewell (richard.kettlewell@kewill.com) - -- Check for IFF_LOOPBACK as a define or an enum (concession to linux). - Reported by Robert Bihlmeyer (robbe@orcus.priv.at) - -- Increase size of SIOCGIFCONF buffer to accommodate systems with lots - of virtual interfaces. Ignore sun virtual interfaces. Suggested by - Ian Donaldson (iand@aone.com.au) - -- Always calculate icmp checksums when using -I. Reported by Soumen - (sbiswas@novell.com) - -- Documentation fix for description of -p. Thanks to Jeffrey C Honig - (jch@bsdi.com) - -- Enable ip checksums for Solaris 2.6 and higher (since they seem to - work correctly now). - -- Avoid problems when broken routers return 0.0.0.0 as their source - address. Thanks to John Hawkinson (jhawk@bbnplanet.com) - -- Canonicalize hostname if gethostname() doesn't return a domain. - -- Add -z flag (pause msecs) to allow optional pause between probes. - Suggested by Dave Morrison (drmorris@uplanet.com) - -- Fix max packet length test. - -- Use "/dev/null" instead of "." for file descriptor fodder. - Suggested by Tim Robbins (fyre@box3n.gumbynet.org) - -- Watch for a NULL argv[0]. Suggested by Tim Robbins. - -- Be careful with hostname legnths. - -- Print RFC1191 Path MTU Discovery value on "needfrag" unreachables. - -- Limit port size to 16 bits. Suggested by Tim Robbins. - -- Limit wait time to 24 hours. - -- Modified linux specific struct ipovly definition to avoid problems - with 64 bit systems. Problem reported by Uros Prestor - (uros@turbolinux.com) - -- Use kernel routing tables to determine correct source address. - Three styles are supported: bsd/socket, solaris/mib and linux. - -- Fix configure to recognize older versions of Solaris. - -v1.3.2 Thu Sep 26 18:06:16 PDT 1996 - -- Rewrite source routing code to eliminate a number of problems on - systems using raw ip options. Also pad options with a noop so gateway - addresses are aligned. - -- Don't call inet_ntoa() twice in the same printf(). Thanks to NetBSD - via Bill Fenner (fenner@parc.xerox.com) - -- Decode "administratively prohibited filter" icmp code and print - numeric value for unknown codes. Thanks to Bill Fenner. - -v1.3.1 Wed Sep 18 21:08:16 PDT 1996 - -- Some systems (e.g. AIX) need sys/select.h. Thanks to Brett Hogden - (hogden@rge.com) - -- Byte swap ip header length under Solaris. (This has no effect on the - sparc but is required on the i386.) - -- Made optional packet length control total size of packet. - -v1.3 Mon Sep 16 14:55:44 PDT 1996 - -- Overrun buffer security fixes. Thanks to Bill Fenner - (fenner@parc.xerox.com) - -- Wait for response packet relative to start of probe. Thanks to Bill - Fenner. - -- Fix bug that prevented changing the packet size. Thanks to Gregory - Decker (gdecker@nate.dcrt.nih.gov) - -- Add support for RAW_OPTIONS (e.g. 4.4 BSD systems such as BSD/OS and - FreeBSD) thanks to Jeffrey C Honig (jch@bsdi.com) - -- Remove ip header byte swap fix from v1.2; most kernels swap the ip - header length in the kernel (and it causes OSF3 to crash). - -- Fix to not exit when the number of probes is set to 1 (i.e. "-q 1") - -- Improve autoconf configuration. - -v1.2 Tue Oct 17 23:50:05 PDT 1995 - -- Convert to autoconf and ansify. - -- Byte swap ip header length for little endian machines. Fix thanks to - Y Badri (yb@greybox.demon.co.uk). - -v1.1 Thu Jun 15 02:32:55 PDT 1995 - -- Check for too many arguments. - -- Recode to make timing of packet's round trip more obvious and to - tighten up code. - -- Ifdef IP_OPTIONS code. - -- Display time in microseconds. - -v1.0 Tue Feb 28 23:50:05 PDT 1989 - -- Initial public release. diff --git a/contrib/traceroute/FILES b/contrib/traceroute/FILES deleted file mode 100644 index 7a585ba9cedc..000000000000 --- a/contrib/traceroute/FILES +++ /dev/null @@ -1,37 +0,0 @@ -CHANGES -FILES -INSTALL -Makefile.in -README -VERSION -aclocal.m4 -config.guess -config.sub -configure -configure.in -findsaddr-generic.c -findsaddr-linux.c -findsaddr-mib.c -findsaddr-socket.c -findsaddr.h -ifaddrlist.c -ifaddrlist.h -install-sh -lbl/gnuc.h -lbl/os-solaris2.h -lbl/os-sunos4.h -linux-include/netinet/in_systm.h -linux-include/netinet/ip.h -linux-include/netinet/ip_icmp.h -linux-include/netinet/ip_var.h -linux-include/netinet/udp.h -linux-include/netinet/udp_var.h -mean.awk -median.awk -mkdep -rip_output.c -strerror.c -traceroute.8 -traceroute.c -traceroute.h -usleep.c diff --git a/contrib/traceroute/FREEBSD-upgrade b/contrib/traceroute/FREEBSD-upgrade deleted file mode 100644 index 4ed42321d26e..000000000000 --- a/contrib/traceroute/FREEBSD-upgrade +++ /dev/null @@ -1,36 +0,0 @@ -This directory contains virgin copies of the original distribution files -on a "vendor" branch. Do not, under any circumstances, attempt to upgrade -the files in this directory via patches and a cvs commit. - -To upgrade to a newer version of traceroute, when it is available: - - 1. Unpack the new version into an empty directory. - [Do not make ANY changes to the files.] - - 2. Use the command: - cvs import -I linux-include \ - -m 'Virgin import of LBL traceroute v<version>' \ - src/contrib/traceroute LBL v<version> - - For example, to do the import of version 1.3.2, I might have typed: - cvs import -I linux-include \ - -m 'Virgin import of LBL traceroute v1.3.2' \ - src/contrib/traceroute LBL v1_3_2 - - 3. Follow the instructions printed out in step 2 to resolve any - conflicts between local FreeBSD changes and the newer version. - -Do not, under any circumstances, deviate from this procedure. - -To make local changes to traceroute, simply patch and commit to the main -branch (aka HEAD). Never make local changes on the LBL branch. - -All local changes should be submitted to "traceroute@ee.lbl.gov" for -inclusion in the next vendor release of traceroute. - -(The "SANE_PRECISION" patch has been submitted and rejected.) - -(The extensive modifications for TCP and GRE probes have not been -submitted.) - -fenner@freebsd.org - 30 Sep 1996 diff --git a/contrib/traceroute/INSTALL b/contrib/traceroute/INSTALL deleted file mode 100644 index 45d361dc4a0e..000000000000 --- a/contrib/traceroute/INSTALL +++ /dev/null @@ -1,105 +0,0 @@ -@(#) $Id: INSTALL,v 1.13 2000/11/23 20:07:29 leres Exp $ (LBL) - -Traceroute is known to build and run under SunOS 4.1.4 and Solaris 5.4. -If you are running a really old kernel, see the instructions under the -title "KERNEL MODIFICATIONS" further down. - -To build traceroute, first customize any paths in Makefile.in, then run -"./configure" (a shell script). The configure script will determine -your system attributes and generate an appropriate Makefile from -Makefile.in. Next run "make". If everything goes well you can su to -root and run "make install" and "make install-man". Note that traceroute -must be installed setuid to root or run as root. - -If configure fails for some reason and decide to submit a bug report to -traceroute@ee.lbl.gov, please include a copy of config.log. - -You will need an ANSI C compiler to build libpcap. The configure script -will abort if your compiler is not ANSI compliant. If this happens, use -the GNU C compiler, available via anonymous ftp: - - ftp://prep.ai.mit.edu/pub/gnu/gcc-*.tar.gz - -If you get the error message: - - traceroute: unknown protocol icmp - -it usually means you're missing the icmp line in /etc/protocols. - -If you are using Solaris 2.5.1 (and possibly higher), traceroute cannot -calculate checksums; configure automatically changes the default to -reflect this. The kernel updates the ip_id field with some unknown -value and the ip_off field with the IP_DF bit. Also, if the the udp -uh_sum field is non-zero, it gets updated with the value of the uh_ulen -field... This means that the icmp echo option (-I flag) is not as -useful. - -KERNEL MODIFICATIONS --------------------- -If yor have a really old system, it may be necessary to modify your -kernel before traceroute will work. If you want to hack on your kernel, -a modified version of the routine rip_output (normally found in the -file /sys/netinet/raw_ip.c) can be found in rip_output.c. This code may -or may not resemble the code in your kernel. It may offer you a place -to start but we make no promises. If you do hack your kernel, remember -to test everything that uses raw ip sockets (e.g., ping and -egpup/gated) & make sure they still work. We wish you the best of luck -and you're on your own. - -Some older kernels forward icmp packets that have a ttl of zero. If -your system has this bug, you might want to fix it while you're in the -kernel. (This bug appears in all releases of BSD up to but not -including 4.3tahoe. If your version of netinet/ip_icmp.c is any earlier -than 7.3 (April, '87), it has the bug.) The fix is just to add the -line: - - ip->ip_ttl = MAXTTL; - -after the line: - - ip->ip_src = t; - -(or anywhere before the call to icmp_send) in routine icmp_reflect. - -If you're running this on a pre-4.3bsd system (e.g., SunOS 3) that -strips ip headers from icmp messages, add -DARCHAIC to CFLAGS in the -Makefile. Also note that rip_output contains a conditional for a -4.2/4.3 change in the location of a raw socket's protocol number. I've -checked this under 4.3 & SunOS 3 but you should double-check your -system to make sure the appropriate branch of the #if is taken (check -the line that assigned to ip->ip_p in your system's original -rip_output). - - -FILES ------ -CHANGES - description of differences between releases -FILES - list of files exported as part of the distribution -INSTALL - this file -Makefile.in - compilation rules (input to the configure script) -README - description of distribution -VERSION - version of this release -aclocal.m4 - autoconf macros -config.guess - autoconf support -config.sub - autoconf support -configure - configure script (run this first) -configure.in - configure script source -findsaddr-generic.c - generic source address code -findsaddr-linux.c - linux source address code -findsaddr-socket.c - socket based soruce address code -findsaddr.h - source address prototypes -ifaddrlist.c - inet address routines -ifaddrlist.h - inet address prototypes -install-sh - BSD style install script -lbl/gnuc.h - gcc macros and defines -lbl/os-*.h - os dependent defines and prototypes -linux-include/* - network include files missing on Linux -mean.awk - awk script to print out the mean time along a route -median.awk - awk script to print out the median time along a route -mkdep - construct Makefile dependency list -rip_output.c - sample rip_output() from /sys/netinet/raw_ip.c -strerror.c - emulation routine -traceroute.8 - manual entry -traceroute.c - main program -traceroute.h - global prototypes -usleep.c - missing system call emulation diff --git a/contrib/traceroute/README b/contrib/traceroute/README deleted file mode 100644 index bd4df4cb8295..000000000000 --- a/contrib/traceroute/README +++ /dev/null @@ -1,29 +0,0 @@ -@(#) $Id: README,v 1.9 2000/09/16 05:32:01 leres Exp $ (LBL) - -TRACEROUTE 1.4 -Lawrence Berkeley National Laboratory -Network Research Group -traceroute@ee.lbl.gov -ftp://ftp.ee.lbl.gov/traceroute.tar.gz - -Traceroute is a system administrators utility to trace the route -ip packets from the current system take in getting to some -destination system. See the comments at the front of the -program for a description of its use. - -This program uses raw ip sockets and must be run as root (or installed -setuid to root). - -A couple of awk programs to massage the traceroute output are -included. "mean.awk" and "median.awk" compute the mean and median time -to each hop, respectively. I've found that something like - - traceroute -q 7 foo.somewhere >t - awk -f median.awk t | xgraph - -can give you a quick picture of the bad spots on a long path (median is -usually a better noise filter than mean). - -Problems, bugs, questions, desirable enhancements, source code -contributions, etc., should be sent to the email address -"traceroute@ee.lbl.gov". diff --git a/contrib/traceroute/VERSION b/contrib/traceroute/VERSION deleted file mode 100644 index 4044959ea471..000000000000 --- a/contrib/traceroute/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.4a12+FreeBSD diff --git a/contrib/traceroute/mean.awk b/contrib/traceroute/mean.awk deleted file mode 100644 index 2d5e37820694..000000000000 --- a/contrib/traceroute/mean.awk +++ /dev/null @@ -1,12 +0,0 @@ -/^ *[0-9]/ { - # print out the average time to each hop along a route. - tottime = 0; n = 0; - for (f = 5; f <= NF; ++f) { - if ($f == "ms") { - tottime += $(f - 1) - ++n - } - } - if (n > 0) - print $1, tottime/n, median -} diff --git a/contrib/traceroute/median.awk b/contrib/traceroute/median.awk deleted file mode 100644 index 5935bad4ff4b..000000000000 --- a/contrib/traceroute/median.awk +++ /dev/null @@ -1,29 +0,0 @@ -/^ *[0-9]/ { - # print out the median time to each hop along a route. - tottime = 0; n = 0; - for (f = 5; f <= NF; ++f) { - if ($f == "ms") { - ++n - time[n] = $(f - 1) - } - } - if (n > 0) { - # insertion sort the times to find the median - for (i = 2; i <= n; ++i) { - v = time[i]; j = i - 1; - while (time[j] > v) { - time[j+1] = time[j]; - j = j - 1; - if (j < 0) - break; - } - time[j+1] = v; - } - if (n > 1 && (n % 2) == 0) - median = (time[n/2] + time[(n/2) + 1]) / 2 - else - median = time[(n+1)/2] - - print $1, median - } -} diff --git a/contrib/traceroute/rip_output.c b/contrib/traceroute/rip_output.c deleted file mode 100644 index 0b092b1e8e2f..000000000000 --- a/contrib/traceroute/rip_output.c +++ /dev/null @@ -1,73 +0,0 @@ -/* A sample version of rip_output() from /sys/netinet/raw_ip.c */ - -rip_output(m, so) - register struct mbuf *m; - struct socket *so; -{ - register struct ip *ip; - int error; - struct rawcb *rp = sotorawcb(so); - struct sockaddr_in *sin; -#if BSD>=43 - short proto = rp->rcb_proto.sp_protocol; -#else - short proto = so->so_proto->pr_protocol; -#endif - /* - * if the protocol is IPPROTO_RAW, the user handed us a - * complete IP packet. Otherwise, allocate an mbuf for a - * header and fill it in as needed. - */ - if (proto != IPPROTO_RAW) { - /* - * Calculate data length and get an mbuf - * for IP header. - */ - int len = 0; - struct mbuf *m0; - - for (m0 = m; m; m = m->m_next) - len += m->m_len; - - m = m_get(M_DONTWAIT, MT_HEADER); - if (m == 0) { - m = m0; - error = ENOBUFS; - goto bad; - } - m->m_off = MMAXOFF - sizeof(struct ip); - m->m_len = sizeof(struct ip); - m->m_next = m0; - - ip = mtod(m, struct ip *); - ip->ip_tos = 0; - ip->ip_off = 0; - ip->ip_p = proto; - ip->ip_len = sizeof(struct ip) + len; - ip->ip_ttl = MAXTTL; - } else - ip = mtod(m, struct ip *); - - if (rp->rcb_flags & RAW_LADDR) { - sin = (struct sockaddr_in *)&rp->rcb_laddr; - if (sin->sin_family != AF_INET) { - error = EAFNOSUPPORT; - goto bad; - } - ip->ip_src.s_addr = sin->sin_addr.s_addr; - } else - ip->ip_src.s_addr = 0; - - ip->ip_dst = ((struct sockaddr_in *)&rp->rcb_faddr)->sin_addr; - -#if BSD>=43 - return (ip_output(m, rp->rcb_options, &rp->rcb_route, - (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST)); -#else - return (ip_output(m, (struct mbuf *)0, &rp->rcb_route, - (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST)); -#endif -bad: - m_freem(m); - return (error); -} diff --git a/usr.sbin/traceroute/Makefile b/usr.sbin/traceroute/Makefile index 8ea7ee22d19a..fd013be9ba9a 100644 --- a/usr.sbin/traceroute/Makefile +++ b/usr.sbin/traceroute/Makefile @@ -1,16 +1,12 @@ .include <src.opts.mk> -TRACEROUTE_DISTDIR?= ${SRCTOP}/contrib/traceroute -.PATH: ${TRACEROUTE_DISTDIR} - PACKAGE= runtime PROG= traceroute MAN= traceroute.8 -SRCS= as.c version.c traceroute.c ifaddrlist.c findsaddr-udp.c +SRCS= as.c traceroute.c ifaddrlist.c findsaddr-udp.c BINOWN= root BINMODE=4555 -CLEANFILES= version.c CFLAGS+= -DHAVE_SYS_SELECT_H=1 -DHAVE_SYS_SOCKIO_H=1 \ -DHAVE_NET_ROUTE_H=1 -DHAVE_NET_IF_DL_H=1 \ @@ -36,14 +32,6 @@ LIBADD+= cap_dns CFLAGS+=-DWITH_CASPER .endif -CFLAGS+= -I${TRACEROUTE_DISTDIR} - WARNS?= 3 -version.c: ${TRACEROUTE_DISTDIR}/VERSION - @rm -f ${.TARGET} - head -1 ${TRACEROUTE_DISTDIR}/VERSION | \ - sed -e 's/.*/char version[] = "&";/' \ - > ${.TARGET} - .include <bsd.prog.mk> diff --git a/contrib/traceroute/as.c b/usr.sbin/traceroute/as.c similarity index 100% rename from contrib/traceroute/as.c rename to usr.sbin/traceroute/as.c diff --git a/contrib/traceroute/as.h b/usr.sbin/traceroute/as.h similarity index 100% rename from contrib/traceroute/as.h rename to usr.sbin/traceroute/as.h diff --git a/contrib/traceroute/findsaddr-socket.c b/usr.sbin/traceroute/findsaddr-socket.c similarity index 100% rename from contrib/traceroute/findsaddr-socket.c rename to usr.sbin/traceroute/findsaddr-socket.c diff --git a/contrib/traceroute/findsaddr.h b/usr.sbin/traceroute/findsaddr.h similarity index 100% rename from contrib/traceroute/findsaddr.h rename to usr.sbin/traceroute/findsaddr.h diff --git a/contrib/traceroute/ifaddrlist.c b/usr.sbin/traceroute/ifaddrlist.c similarity index 100% rename from contrib/traceroute/ifaddrlist.c rename to usr.sbin/traceroute/ifaddrlist.c diff --git a/contrib/traceroute/ifaddrlist.h b/usr.sbin/traceroute/ifaddrlist.h similarity index 100% rename from contrib/traceroute/ifaddrlist.h rename to usr.sbin/traceroute/ifaddrlist.h diff --git a/contrib/traceroute/traceroute.8 b/usr.sbin/traceroute/traceroute.8 similarity index 100% rename from contrib/traceroute/traceroute.8 rename to usr.sbin/traceroute/traceroute.8 diff --git a/contrib/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c similarity index 99% rename from contrib/traceroute/traceroute.c rename to usr.sbin/traceroute/traceroute.c index 643caedc4c34..b8dcc423ebde 100644 --- a/contrib/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -2146,9 +2146,6 @@ pkt_compare(const u_char *a, int la, const u_char *b, int lb) { void usage(void) { - extern char version[]; - - Fprintf(stderr, "Version %s\n", version); Fprintf(stderr, "Usage: %s [-adDeEFInrSvx] [-A as_server] [-f first_ttl] [-g gateway]\n" "\t[-i iface] [-m max_ttl] [-M first_ttl] [-p port] [-P proto]\n" diff --git a/contrib/traceroute/traceroute.h b/usr.sbin/traceroute/traceroute.h similarity index 100% rename from contrib/traceroute/traceroute.h rename to usr.sbin/traceroute/traceroute.h