Commit Graph

15487 Commits

Author SHA1 Message Date
Alexander V. Chernikov
9ee6278b78 netstat: fix double-free in netlink error code path.
CID:	1504382
2023-03-18 14:01:46 +00:00
Alexander V. Chernikov
aee2f11bf4 netstat: simplify netlink route printing code.
A number of improvements has commited to snl(3) recently.
A notable one is snl(3) build-in parsers for all of the objects
 exported by the kernel.

This change updates netlink handling code to the latest available snl(3)
API.
2023-03-18 13:05:41 +00:00
Mateusz Guzik
3451ed888e less: silence K&R warns
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-16 18:24:12 +00:00
Dag-Erling Smørgrav
fa3af3ce50 tail: Verify correct behavior when input does not end in a newline.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D39116
2023-03-16 15:37:02 +00:00
Dag-Erling Smørgrav
fc76ddee9b tftp: Add test cases for URL mode.
Sponsored by:	Klara, Inc.
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D39014
2023-03-13 16:16:26 +00:00
David E. O'Brien
65e9eb0701 Look in getlocalbase() for the calendar-data package data
Fix d20d655018 where getlocalbase()
wasn't used to fill out the printf(3) format of _PATH_INCLUDE_LOCAL.

Differential Revision:	https://reviews.freebsd.org/D38975
Reviewed by:	imp
2023-03-12 18:40:07 -07:00
Dag-Erling Smørgrav
64c2a712d6 tftp: Add tests.
Sponsored by:	Klara, Inc.
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D38969
2023-03-10 13:25:16 +00:00
Dag-Erling Smørgrav
92570f67c7 tftp: Correctly propagate transfer errors.
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38958
2023-03-10 13:25:16 +00:00
Brooks Davis
af0cc0b223 NgATM: Remove netgraph ATM support
Most ATM support was removed prior to FreeBSD 12.  The netgraph support
was kept as it was less intrusive, but it is presumed to be unused.

Reviewed by:	manu
Relnotes:	yes
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D38879
2023-03-09 18:04:02 +00:00
Kyle Evans
b617584942 grep: remove tautological condition
st_size is an off_t, it cannot hold values larger than OFF_MAX.

CID:		1008931
2023-03-08 23:53:10 -06:00
Kyle Evans
c816aea7ab Revert "grep: remove tautological condition"
This reverts commit f6d6c66889.

Gremlins snuck into my tree and injected some WIP.
2023-03-08 23:52:23 -06:00
Kyle Evans
f6d6c66889 grep: remove tautological condition
st_size is an off_t, it cannot hold values larger than OFF_MAX.

CID:		1008931
2023-03-08 23:34:22 -06:00
Dag-Erling Smørgrav
473a2c9a40 byacc: Disable backtracking extension.
When updating byacc to 20230201, I enabled the backtracking extension as it seemed useful and harmless.  With a little more experience, it appears to have more impact than I initially thought and I'm no longer sure how useful it really is, so turn it back off.

PR:		244149, 269425
Sponsored by:	Klara, Inc.
Reviewed by:	imp, jkim
Differential Revision:	https://reviews.freebsd.org/D38931
2023-03-07 17:20:49 +00:00
Alexander V. Chernikov
6a6f2b0ce9 netstat: fix IPv6 link-locals & custom multipath printing. 2023-03-06 15:08:09 +00:00
Kajetan Staszkiewicz
cd9e5d4333 netstat: fix pfsync stats spelling
Reviewed by:	mjg
2023-03-05 22:50:07 +00:00
Ed Maste
1b00334852 bc: remove MIPS Makefile case
MIPS support has been removed from FreeBSD.

Sponsored by: The FreeBSD Foundation
2023-03-01 10:38:12 -05:00
Dimitry Andric
ab80f0b21f Ensure .inc files are regenerated when llvm/clang tblgen binaries change
When doing a fully incremental build (with WITHOUT_CLEAN enabled), from
a commit before llvm 15 was merged (3264f6b88f), to a commit after
that, a number of .inc files were not regenerated. This could lead to
unexpected compilation errors when these .inc files were included from
llvm-project sources, similar to:

  In file included from /usr/src/contrib/llvm-project/clang/lib/CodeGen/CGBuiltin.cpp:8268:
  /usr/obj/usr/src/amd64.amd64/lib/clang/libclang/clang/Basic/arm_mve_builtin_cg.inc:279:18: error: no matching constructor for initialization of 'clang::CodeGen::Address'
    Address Val2 = Address(Val1, CharUnits::fromQuantity(2));
                   ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Work around this by making the .inc files dependent on the tblgen binary
used for generating them. E.g., we can relatively safely assume that if
the binary gets updated, the .inc files must also be updated. (Although
this is not 100% optimal, the gain by complicating things even more is
probaby not worth the effort.)

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D38770
2023-02-26 15:56:07 +01:00
Daniel Tameling
e052829e3e uniq(1): use strtonum to parse options
Previously strtol was used and the result was directly cast to an int
without checking for an overflow. Use strtonum instead since it is
safer and tells us what went wrong.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/643
2023-02-25 10:25:51 -07:00
Piotr Kubaj
6ae90f5985 gh-bc: don't disable LTO on powerpc64
Summary:
The LTO issue has been fixed. While -flto for some reason is commented out,
since it wasn't completely removed, it may be expected to be reenabled.

Reviewers: se
Approved by: se
MFC after: 3 days
Subscribers: imp
Differential Revision: https://reviews.freebsd.org/D38755
2023-02-25 00:49:27 +01:00
Stefan Eßer
77606d5a8c usr.bin/gh-bc: clean-up Makefile
Remove commented out debug options and re-enable LTO for most
architectures.
2023-02-25 00:07:25 +01:00
Thomas Munro
58e3631bd0 truss: Add preadv(2) and pwritev(2).
We already knew how to decode readv(2)/writev(2).  Add the versions with
an offset.

Reviewed by:            asomers
Differential Revision:  https://reviews.freebsd.org/D27531
MFC after:              2 weeks
2023-02-21 22:40:14 +13:00
Dag-Erling Smørgrav
8e022d3cde byacc: Update to 20230201.
Note that this enables the backtracking extension, which we had previously left disabled.

PR:		244149, 269425
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38421
2023-02-20 23:35:32 +01:00
Fernando Apesteguía
e6ffcf4ac7 zless(1): handle uncompressed files
In the manual page for zmore(1) and zless(1) it is said that zless(1) is
equivalent to zmore(1) except that it uses less(1) as a pager. However
zmore(1) is able to handle uncompressed files transparently while zless(1)
is not.

Add another case to the switch in lesspipe.sh to handle non-compressed files.

PR:		196437
Reported by:	marquis@roble.com
Approved by:	mjg@
Differential Revision: https://reviews.freebsd.org/D38674
2023-02-20 11:15:09 +01:00
Warner Losh
ef6f20ce47 tail: Retry kevent if the system call was interrupted
kevent returns EINTR when I suspend / resume. This causes tail -f
and tail -F to exit with interrupt system call. Ignore this error
and try kevent again.

Sponsored by:		Netflix
2023-02-18 20:09:26 -07:00
Fernando Apesteguía
91706f0d6d netstat.1: Clarify -i and -I priorities
netstat(1) allows to specify both -i (all interfaces) and -I <ifname>.
However, when both are specified, -I always overrides -i.
Add a comment where appropriate the same way we do in rm(1) for -f and -i.

PR:		202708
Reported by:	demon@
Approved by:	manpages (pauamma@)
Differential Revision: https://reviews.freebsd.org/D38654
2023-02-18 18:01:34 +01:00
Mateusz Guzik
2924ae099a Revert "cpuset: add --count"
The patch introduced a behavior change coming from getopt_long, namely
the entire argument array would be parsed looking for opts, which
affected uses spawning new processes without passing '--' to delimit
where cpuset arguments end. [1]

Apart from that turns out the change had a bug: using CPU_LEVEL_ROOT
instead of CPU_LEVEL_WHICH, returning a different cpuset than intended.
[2]

The intended functionality is provided with nproc(1), which landed after
this change.

As such, revert for the time being.

This reverts commit d9d5f2c042.

Reported by:	Mark Millard [1]
Reported by:	jbeich [2]
2023-02-16 18:18:49 +00:00
Dag-Erling Smørgrav
5016d112ad wc: Make the read buffer static.
The read buffer in cnt() is 64 kB, which is a bit excessive for a stack variable.  MAXBSIZE has grown since this code was originally written, and it might grow again in the future.  Since the program is single-threaded and cnt() does not recurse, we can safely make the buffer static.

While there, constify p since it is only used to read.

Sponsored by:	Klara, Inc.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D38608
2023-02-16 00:40:45 +00:00
Dag-Erling Smørgrav
5c870e1b48 wc: Improve test coverage.
* Add a test that causes mbrtowc() to return 0.

* Add a test that causes mbrtowc() to return -2.

Sponsored by:	Klara, Inc.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D38605
2023-02-16 00:40:45 +00:00
Dag-Erling Smørgrav
dad64f0e7c wc: Clean up and modernize.
* Drop <err.h>, which is unnecessary since we use libxo.

* As per POSIX, report an error if output fails.

* Fix some type mismatches.

* Use bool instead of int where appropriate.

* Avoid repeatedly checking for a null filename.

* Miscellaneous other tidying.

* Add tests (partly derived from work performed by SHENG-YI HONG <i19780219111@kimo.com>).

Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D38496
2023-02-14 22:26:47 +00:00
Alan Somers
4c163a5480 Change "ctlstat -P"'s schema
It now reports stats separately for both ports and luns.

Also, prohibit using both "-p" and "-P" at the same time.

MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	mav
Differential Revision: https://reviews.freebsd.org/D38500
2023-02-13 09:18:38 -07:00
Kyle Evans
deb63adf94 top: fix sorting by pid (-o pid)
The 'pid' order was added, but the equivalent comparator was not back in
8b800d3af2 ("Add the PID column to the list of sort keys.").
`ordernames` indices need to match `compares` indices in order for this
to work.

A future commit will restructure all of this to make it less error prone
going forward (see D37083).

MFC after:	3 days
Reviewed by:	pstef (D37083)
2023-02-13 00:43:32 -06:00
Kyle Evans
7e688ed493 patch: omit filename if the prompt was ignored
When a file is missing, patch(1) will prompt for a filename to try and
patch it.  If we're doing a dry-run, we'll output that the patch to the
source file was either ignored/failed.  If you ignore the prompt in a
dry-run (i.e. just hit enter), we'll output:

X out of X hunks ignored while patching (null)

Let's improve the aesthetics a bit and just omit the last part if the
prompt was ignored:

X out of X hunks ignored

Unfortunately we can't really test this without expect(1) because both
force and batch mode will use the first best guess, which is wiped out
by the "File to patch:" prompt.  We could record the initially derived
bestguess there and use *that*, but given that this is only possible in
an interactive session I think it's fine to just omit the filename
rather than adding a fair amount of complexity (which could also break
other scenarios I haven't considered yet)..

Reviewed by:	des
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38179
2023-02-13 00:15:08 -06:00
Simon J. Gerraty
dc1b8c9a84 Merge bmake-20230208
Merge commit 'f4d51098686d961fc03dc5aa327619d0af3c9dcd'
2023-02-09 17:23:23 -08:00
Mateusz Guzik
48bfd35976 Add nproc(1)
This program prints the number of CPU threads it can run on, while
respecting cpusets (or not, depending on switches).

It aims to be compatible with nproc as found in GNU coreutils.

Reviewed by:	des
Reviewed by:	pstef
Differential Revision:	https://reviews.freebsd.org/D38386
2023-02-08 19:47:33 +00:00
Dimitry Andric
fcaf7f8644 Merge llvm-project main llvmorg-15-init-17485-ga3e38b4a206b
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-17485-ga3e38b4a206b.

PR:		265425
MFC after:	2 weeks
2023-02-08 20:04:38 +01:00
Dimitry Andric
81ad626541 Merge llvm-project main llvmorg-15-init-15358-g53dc0f10787
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-15358-g53dc0f10787.

PR:		265425
MFC after:	2 weeks
2023-02-08 20:02:26 +01:00
Emmanuel Vadot
1af3908ce6 pkgbase: Create a FreeBSD-elftoolchain package
It contain all the binaries and libs from the elftoolchain contrib
project except for libelf which is used everywhere.
All of those tools are never used by the average user.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38224
2023-02-08 08:49:12 +01:00
Emmanuel Vadot
9c1720e59a pkgbase: Create a FreeBSD-smbutils package
And put smb related programs and lib in it.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38228
2023-02-08 08:48:28 +01:00
Stefan Eßer
4fca8e0f65 contrib/bc: uodate to version 6.2.4
This update contains only documentation changes (new main repository
URL and changed mail address of the program author) and changes to
the build system that do not affect the FreeBSD base system build.

MFC after:	3 days
2023-02-06 22:33:56 +01:00
Mateusz Guzik
d9d5f2c042 cpuset: add --count
Can be used to count the number of hardware threads in the cpu set.

For example:
$ cpuset -g -p $$
pid 2440 mask: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39
pid 2440 domain policy: first-touch mask: 0, 1
$ cpuset -g --count -p $$
40

The intent is to replace calls to sysctl hw.ncpu and kern.smp.cpus which
can be found in the tree, which are not adequate given existence of
cpusets.

Right now only -g -p combination is supported to reduce complexity.
As anything else errors out, this can be expanded later as needed.

Differential Revision:	https://reviews.freebsd.org/D36351
2023-02-04 17:50:41 +00:00
Dimitry Andric
a9e0629719 gh-bc: don't force CFLAGS to -O0 -g
Otherwise, CFLAGS passed in via bsd.sys.mk or the user's environment are
not respected, and this leads to link errors on riscv64sf.
2023-02-02 19:20:18 +01:00
Mateusz Piotrowski
e7ab133648 timeout: Move from /usr/bin to /bin
timeout(1) is used by /etc/rc.d/zfskeys. Unfortunately, having
timeout(1) installed in /usr/bin causes problems when /usr is an
encrypted ZFS partition.

Implementing timeout(1) in sh(1) is not trivial. A more elegant solution
is to move timeout(1) to /bin so that it is available to early services
in the boot process.

PR:		265221
Reviewed by:	allanjude, des, imp
Approved by:	allanjude, des, imp
Reported by:	Ivan <r4@sovserv.ru>
Fixes:	33ff39796f Add zfskeys rc.d script for auto-loading encryption keys
MFC after:	1 week
Relnotes:	yes
Sponsored by:	Modirum MDPay
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D38344
2023-02-02 18:34:35 +01:00
Dag-Erling Smørgrav
134841a7f3 cmp: Increase buffer size for non-mmap case.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	rpokala
Differential Revision:	https://reviews.freebsd.org/D38281
2023-01-31 01:29:05 +01:00
Dag-Erling Smørgrav
6673a5476d cmp: Print a summary on SIGINFO.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38280
2023-01-31 01:29:05 +01:00
Gleb Smirnoff
bcad3f96ae gh-bc: fix build with WITHOUT_NLS_CATALOGS=YES 2023-01-30 13:26:49 -08:00
Phil Shafer
ef7d10fde4 Add missing check for xo_parse_args return code. 2023-01-30 15:43:01 -05:00
Phil Shafer
e1e2080fc1 Import Juniper libxo-1.6.0
PR:		262332
2023-01-30 13:37:33 -05:00
Cameron Katri
c8abb673a5 man(1): Support zstd compressed manpages using zstdcat
Reviewed by:	emaste, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D32296
2023-01-30 13:12:36 -05:00
Jamie Landeg-Jones
37399d5bcf usr.bin/stat: Fix error message formatting.
PR:		bin/261657
MFC after:	3 days
2023-01-29 14:37:25 -08:00
Alexander V. Chernikov
15dbf5a241 netstat: export weight for single-path routes.
* Parse and export newly-added NL_RTA_WEIGHT attribute, providing path
 weight for a non-multipath route. This fixes a number of tests in
 sys/net/routing which rely on this data.
* Remove handling of NL_RTA_KNH_ID in multipath routes, as it is
 not provided.
* Improve kernel/user nexthop index export. As a result,
 for multipath routes:
  * nhg-kidx attribute represents kernel nhg index (always provided)
  * nhg-uidx attribute represents user-provided nhg index (if set)
 for non-multipath routes:
  * nhop-kidx attribute represents kernel nhop index (always provided)
  * nhop-udx attribute represents user-provided nexthop index (if set)
2023-01-29 16:27:31 +00:00