Commit Graph

9570 Commits

Author SHA1 Message Date
Kirk McKusick
54fab0fbc4 Add missing cylinder group check-hash updates when doing large expansions
of filesystems.

Reported by:  Colin Percival (cperciva@)
Tested by:    Colin Percival (cperciva@)
MFC after:    3 days
Sponsored by: Netflix
2020-09-22 03:57:48 +00:00
David Bright
52664466c7 Whitespace fix after r365948
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2020-09-21 18:34:13 +00:00
Adrian Chadd
0dcdda0984 [rcorder] [crunch] Fix C function declarations to include void
This fixes a compile issue under gcc6 which complains about
legacy style C function declarations.

Differential Revision:	https://reviews.freebsd.org/D26504
2020-09-21 17:59:45 +00:00
David Bright
16969d1448 Honor the FWUG value of some drives in nvmecontrol
nvmecontrol tries to upload firmware in chunks as large as it thinks
the device permits. It fails to take into account the FWUG value used
by some drives to advertise the size and alignment limits for firmware
chunks.

  - Use the firwmare update granularity value from the
  - If the granularity is not reported or not restricted, fall back to
    the previously existing logic that calculates the max transfer
    size based on MDTS.
  - Add firmware update granularity to the identify-controller output.

Reviewed by:	imp (previous version), chuck
Obtained from:	Dell EMC Isilon
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D26390
2020-09-21 15:45:49 +00:00
Toomas Soome
e307eb94ae loader: zfs should support bootonce an nextboot
bootonce feature is temporary, one time boot, activated by
"bectl activate -t BE", "bectl activate -T BE" will reset the bootonce flag.

By default, the bootonce setting is reset on attempt to boot and the next
boot will use previously active BE.

By setting zfs_bootonce_activate="YES" in rc.conf, the bootonce BE will
be set permanently active.

bootonce dataset name is recorded in boot pool labels, bootenv area.

in case of nextboot, the nextboot_enable boolean variable is recorded in
freebsd:nvstore nvlist, also stored in boot pool label bootenv area.
On boot, the loader will process /boot/nextboot.conf if nextboot_enable
is "YES", and will set nextboot_enable to "NO", preventing /boot/nextboot.conf
processing on next boot.

bootonce and nextboot features are usable in both UEFI and BIOS boot.

To use bootonce/nextboot features, the boot loader needs to be updated on disk;
if loader.efi is stored on ESP, then ESP needs to be updated and
for BIOS boot, stage2 (zfsboot or gptzfsboot) needs to be updated
(gpart or other tools).

At this time, only lua loader is updated.

Sponsored by:	Netflix, Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D25512
2020-09-21 09:01:10 +00:00
Kirk McKusick
85ee267a3e Update the libufs cgget() and cgput() interfaces to have a similar
API to the sbget() and sbput() interfaces. Specifically they take
a file descriptor pointer rather than the struct uufsd *disk pointer
used by the libufs cgread() and cgwrite() interfaces. Update fsck_ffs
to use these revised interfaces.

No functional changes intended.

Sponsored by: Netflix
2020-09-19 22:48:30 +00:00
Kirk McKusick
68d7185b64 The fsdb(8) utility uses the fsck_ffs(8) disk I/O interfaces, so
switch from using libufs's bread() to using fsck_ffs's getdatablk()
when importing tools/diag/prtblnos's prtblknos().

Sponsored by: Netflix
2020-09-19 20:06:12 +00:00
Kyle Evans
fe815331bb build: provide a default WARNS for all in-tree builds
The current default is provided in various Makefile.inc in some top-level
directories and covers a good portion of the tree, but doesn't cover parts
of the build a little deeper (e.g. libcasper).

Provide a default in src.sys.mk and set WARNS to it in bsd.sys.mk if that
variable is defined. This lets us relatively cleanly provide a default WARNS
no matter where you're building in the src tree without breaking things
outside of the tree.

Crunchgen has been updated as a bootstrap tool to work on this change
because it needs r365605 at a minimum to succeed. The cleanup necessary to
successfully walk over this change on WITHOUT_CLEAN builds has been added.

There is a supplemental project to this to list all of the warnings that are
encountered when the environment has WARNS=6 NO_WERROR=yes:
https://warns.kevans.dev -- this project will hopefully eventually go away
in favor of CI doing a much better job than it.

Reviewed by:	emaste, brooks, ngie (all earlier version)
Reviewed by:	emaste, arichardson (depend-cleanup.sh change)
Differential Revision:	https://reviews.freebsd.org/D26455
2020-09-18 17:17:46 +00:00
Navdeep Parhar
830edb4561 Add two new ifnet capabilities for hw checksumming and TSO for VXLAN traffic.
These are similar to the existing VLAN capabilities.

Reviewed by:	kib@
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D25873
2020-09-18 02:10:28 +00:00
Edward Tomasz Napierala
2ccf8a827c Skip armv7 bectl tests on CI; they deadlock (""KSTACK_PAGES is 2").
PR:		249229
Sponsored by:	DARPA
2020-09-14 10:35:39 +00:00
Alex Richardson
d815e42419 pfctl_test: avoid 200 calls to atf_get_srcdir
I have been trying to reduce the time that testsuite runs take for CheriBSD
on QEMU (currently about 22 hours). One of the slowest tests is pfctl_test:
Just listing the available test cases currently takes 98 seconds on a
CheriBSD RISC-V system due to all the processes being spawned. This trivial
patch reduces the time to 92 seconds. The better solution would be to
rewrite the test in C/C++ which I may do as a follow-up change.

Reviewed By:	kp
Differential Revision: https://reviews.freebsd.org/D26417
2020-09-14 08:51:18 +00:00
Kirk McKusick
314a6544c5 In the newfs(8) utility, use the more appropriate sbwrite() and cgwrite()
libufs interfaces rather than sbput() and cgput().

No functional change.

MFC after:    7 days
Sponsored by: Netflix
2020-09-13 22:57:50 +00:00
Kyle Evans
ecebb3cc1d Only set WARNS if not defined
This would allow interested parties to do experimental runs with an
environment set appropriately to raise all the warnings throughout the
build; e.g. env WARNS=6 NO_WERROR=yes buildworld.

Not currently touching the numerous instances in ^/tools.

MFC after:	1 week
2020-09-11 13:28:37 +00:00
Andrey V. Elsukov
b876085f55 Fix compatibility regression after r364117.
Properly handle the case, when some opcode keywords follow after
the `frag` opcode without additional options.

Reported by:	Evgeniy Khramtsov <evgeniy at khramtsov org>
2020-09-11 10:07:09 +00:00
Richard Scheffenegger
6034024dad Add -z "TOS" option to ping6, to test DSCP/ECN values
ping has the option to add the (deprecated) TOS byte
using the -z option. Adding the same option, with the
same (deprecated) Traffic Class Byte (nowadays actually
DSCP and ECN fields) to ping6 to validate proper QoS
processing in network switches.

Reviewed by:	tuexen
MFC after:	2 weeks
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D26384
2020-09-10 00:50:18 +00:00
Mark Johnston
278847ae58 ggate: Fix ggated/ggatec debug print of offsets.
The request offset and length are always unsigned, so print them as
such.

Submitted by:	Yoshihiro Ota <ota@j.email.ne.jp>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D21388
2020-09-09 12:58:19 +00:00
Andrey V. Elsukov
30fe2bbfae Add a few features to rcorder:
o Enhance dependency loop logging: print full chain instead of the
  last link competing the loop;
o Add -g option to generate dependency graph suitable for GraphViz
  visualization, loops and other graph generation issues are highlighted
  automatically;
o Add -p option that enables grouping items that can be processed in
  parallel.

Submitted by:	Boris Lytochkin <lytboris at gmail>
Reviewed by:	melifaro
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25389
2020-09-08 10:36:11 +00:00
Li-Wen Hsu
d8bdfeb653 Call atf_skip function in cleanup procedure as it also triggers zfs.ko loading
PR:		249055
Sponsored by:	The FreeBSD Foundation
2020-09-07 18:15:58 +00:00
Li-Wen Hsu
7c570021c8 Temporarily skip sbin.bectl.bectl_test.* i386 kernel in CI
kldload zfs.ko on i386 hangs in CI

Sponsored by:	The FreeBSD Foundation
2020-09-03 08:16:57 +00:00
Brooks Davis
a449e81e00 Remove risky compatability with old kernels
The badsys() handler for SIGSYS was added as a transtion aid for kernels
lacking sysctl() in 1993.  It is unsafe and unsound so remove it rather
than running the risk of a privilege-dropping system call being silently
omitted.

This partially reverts SCCSID 6.12 (Berkeley) 03/03/93 "add code to
change the system security level".

Reviewed by:	mckusick, imp, kevans
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26289
2020-09-02 21:14:36 +00:00
Li-Wen Hsu
0932ee9fa0 Temporarily skip tests panic i386 kernel in CI
lib.libbe.be_create.libbe_create
sbin.bectl.bectl_test.bectl_create

PR:		249055
Sponsored by:	The FreeBSD Foundation
2020-09-02 19:18:27 +00:00
Mark Johnston
a0efcf6400 Add sysctl(8) formatting for hw.pagesizes.
- Change the type of hw.pagesizes to OPAQUE, since it returns an array.
- Modify the handler to only truncate the returned length if the caller
  supplied an output buffer.  This allows use of the trick of passing a
  NULL output buffer to fetch the output size, while preserving
  compatibility if MAXPAGESIZES is increased.
- Add a "S,pagesize" formatter to sysctl(8).

Reviewed by:	alc, kib
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D26239
2020-09-02 18:17:08 +00:00
Fernando Apesteguía
2825bf5b2a kldstat(8): Add EXAMPLES to the man page
Add EXAMPLES for all the flags

Approved by:	manpages (bcr@)
Differential Revision: https://reviews.freebsd.org/D26283
2020-09-02 18:15:57 +00:00
Chuck Silvers
e83370448f Move all of the error prints in readsb() from stderr to stdout.
The only output from fsck that should go to stderr is the usage message.
if setup() fails then exit with EEXIT rather than 0.

Reviewed by:	mckusick
Sponsored by:	Netflix
2020-09-01 18:50:26 +00:00
Stefan Eßer
0fa427fe19 Change printf format string to include the extra blank
This is a follow up change to r364321 after a discussion about the style.
All near by places use extra blanks in format strings, and while use of the
format string to provide the extra blank may need more cycles than adding 1
to twidth, it generates shorter code and is clearer in the opinion of some
reviewers of the previous change.

Not objected to by:	emaste
MFC after:		3 days
2020-09-01 09:02:43 +00:00
Warner Losh
7daa93c454 Sort IFNET alphabetically 2020-08-31 23:48:27 +00:00
Warner Losh
b87de06445 Add documentation for ETHERNET events. 2020-08-31 23:48:23 +00:00
Mark Johnston
0a01415e6e ggated(8): Avoid doubly opening the requested disk device.
- Initialize the disk device fd field in connection_new().
- Close the disk device after handing the connection over
  to a child worker.
- Avoid re-opening a disk device for each connection from
  the same client, avoiding an fd leak.

PR:		132845
Submitted by:	Yoshihiro Ota <ota@j.email.ne.jp>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26168
2020-08-31 15:59:17 +00:00
Ed Maste
57b278f886 dhclient: improve error handling parsing option 119
Reported by:	Shlomi Oberman, JSOF
Submitted by:	delphij
Reviewed by:	markj
Tested by:	markj
2020-08-31 15:55:29 +00:00
Alex Richardson
6424881cc8 Fix makefs bootstrap on macOS after D25563
The macOS assert.h header does not define static_assert when compiling in
C99 mode. To fix this compile with -std=c11.

Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D25928
2020-08-25 13:30:24 +00:00
Matt Macy
9e5787d228 Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.

I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.

Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.

Improvements include:
  project quotas, encrypted datasets,
  allocation classes, vectorized raidz,
  vectorized checksums, various command line
  improvements, zstd compression.

Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.

Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
Warner Losh
f87655ec76 Change the resume notification event from 'kern' to 'kernel'
We have both a system of 'kern' and of 'kernel'. Prefer the latter and
convert this notification to use 'kernel' instead of 'kern'. As a
transition period, continue to also generate the 'kern' notification
until sometime after FreeBSD 13 is branched.

MFC After: 3 days
2020-08-24 19:35:15 +00:00
Fernando Apesteguía
0ad4bfaef1 sysctl(8): clarify -n flag
-n omits the name of the variable regardless of the type of information that is
requested. Rephrase to clarify this point.

PR:	242191
Submitted by:	stilezy@gmail.com
Approved by:	emaste@
Differential Revision:	https://reviews.freebsd.org/D26149
2020-08-22 11:59:14 +00:00
Fernando Apesteguía
71230912a7 ipfw(8): Fix typo in man page
s/exmaple/example

Approved by:	manpages (gbe@)
Differential Revision:	https://reviews.freebsd.org/D26147
2020-08-21 17:45:17 +00:00
Warner Losh
350711aa85 Document the VFS FS events
MOUNT notifies when a filesystem is mounted
REMOUNT notifies when a filesystem is mounted again
UNMOUNT notifies when a filesystem is unmounted

These events are asynchronous to the actual state of the event (though the data
is recorded at a time when it is stable). The mount event is reported after the
filesystem is mounted. However, in the interim it may be unmounted by another
agent. Likewise, umount is called just before the mountpoint is finished tearing
down. It may be remounted (or maybe if the process scheduling is wonky and devd
gets to run before the last few steps are complete).

Sponsored by: Netflix
Diffential Revision: https://reviews.freebsd.org/D25969
2020-08-19 17:10:09 +00:00
Warner Losh
08b242aeee Move the mount name to bit mapping into sys/mount.h so it can be shared with the
kernel.

Discussed with: kib@
Reviewed by: kirk@ (prior version)
Sponsored by: Netflix
Diffential Revision: https://reviews.freebsd.org/D25969
2020-08-19 17:09:58 +00:00
Warner Losh
346da45741 Three typos:
Amiga is a proper noun
Condition is traditionally spelled starting with 'c'
Some, but not all, of the over/under-voltage instances were hyphenated.
Since they are all adverb phrases, they all need to be hyphenated.

Pointy hat: imp
2020-08-19 02:18:11 +00:00
Robert Wing
deaff65313 bectl(8): Fix output of bectl list for the 'Mountpoint' column.
Currently, the output of `bectl list` doesn't align the 'Mountpoint' column
correctly when the 'mounted' property of a boot environment dataset is longer
than the default column width.

Set the 'Mountpoint' column width to the boot environment dataset with the
longest 'mounted' property or to the default width, whichever is greater.

PR:             241064
Reported by:	vermaden@interia.pl
Reviewed by:    kevans (mentor)
Approved by:    kevans (mentor)
MFC after:      1 week
Differential Revision:	https://reviews.freebsd.org/D26048
2020-08-19 00:09:39 +00:00
Warner Losh
d7e357f85c Fix two typos.
Submitted by: rpokala@
MFC After: 3 days
2020-08-18 21:42:02 +00:00
Warner Losh
97f744901f Document the ZFS events as best I can. These are not well documented.
MFC After: 3 days
2020-08-18 21:26:58 +00:00
Warner Losh
77f4a8090c Document the AEON subsystem for the Amiga's power button.
MFC After: 3 days
2020-08-18 21:26:54 +00:00
Warner Losh
428668cca4 Document the PMU system
The pmu(4) and adb(4) drivers on powerpc generate PMU events. Document them.

The allwinner power modules also generate these events. Document those as well.

MFC After: 3 days
2020-08-18 21:26:50 +00:00
Warner Losh
17910c7f6d GEOM::rotation_rate changes are also signaled via devctl.
MFC After: 3 days
2020-08-18 21:26:45 +00:00
Warner Losh
e3c77e3197 Move the possible event types into a column table to make it easier to read.
Sort system type alphabetically.
Remove some commas that aren't in the devd notification messages.

MFC After: 3 days
Reviewed by: 0mp (earlier versions), jhb (useful feedback on earlier versions)
Differential Revision: https://reviews.freebsd.org/D26105
2020-08-18 21:26:39 +00:00
Warner Losh
31178c8a9e Modernize a bit.
Remove PC Card specific information. It's of little value these days and on
the way out after most of its drivers have been removed.
Use iwn instead of wi device.
2020-08-18 06:07:34 +00:00
Ed Maste
c1b355d378 ipfw: line up ipfw -t list with and without timestamp
From the PR:
    When I run `ipfw -t list` on release/12 or current, I get misaligned
    output between lines that do and do not have a last match timestamp,
    like so:

    00100 Tue Aug 11 03:03:26 2020 allow ip from any to any via lo0
    00200                         deny ip from any to 127.0.0.0/8

    (specifically, the "allow" and "deny" strings do not line up)

PR:		248608
Submitted by:	Taylor Stearns
MFC after:	3 days
2020-08-17 18:53:23 +00:00
Bjoern A. Zeeb
4b1c248795 80211: consistently order 160 and 80+80
For flags and checks the order goes VHT160 and then VHT80P80 unless
checks are in reverse order ("more comes first") in which case we
deal with VHT80P80 first.
The one reverse order to pick out is where we check channel
prefernences.  While it may seem that VHT160 is better, finding
two "free" channels (VHT 80+80) is more likely so we do prefer that.

While dealing with VHT160 and VHT80P80 add extra clauses previously
missing or marked TODO in a few places.

Reviewed by:	adrian, gnn
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC (d/b/a "Netgate")
Differential Revision:	https://reviews.freebsd.org/D26002
2020-08-17 13:04:18 +00:00
Bjoern A. Zeeb
fd6eb8fec7 80211: consistently spell 80P80
The standard uses 80+80 and 80p80 but nowhere 80_80.
Switch the latter to 80P80 for all the macros and comments refering
to #defined flags which I could find.
The only place we leave as 80p80 is the ifconfig command line arguments
as we spell them all in lower case.
Ideally we would use 80+80 for any interactions with the user and
80P80 for anything internal but let us not confuse parsers and
hence avoid the '+' in either case.

Reviewed by:	adrian, gnn
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC (d/b/a "Netgate")
Differential Revision:	https://reviews.freebsd.org/D26001
2020-08-17 12:52:57 +00:00
Bjoern A. Zeeb
96811be22f net80211 / ifconfig: cleanup the use of IEEE80211_FVHT_USEVHT*
Rather then using magic numbers duplicate IEEE80211_FVHT_VHT* in
ifconfig (cleanup of these and other flags used and not exposed by
net80211 should happen later) and use those.
In the kernel this simplifies one ioctl path (the other one currently
relies on individual bit flags being passed in).
We also re-order the 80P80 and 160 flag for 160 to come before 80+80
and more clearly leave the flags as TODO in one of the 160/80+80 cases.

Reviewed by:	adrian
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC (d/b/a "Netgate")
Differential Revision:	https://reviews.freebsd.org/D26000
2020-08-17 12:43:07 +00:00
Mateusz Piotrowski
d61057562a Comment out TODO notes from bectl(8) manual page
MFC after:	2 days
2020-08-17 08:43:36 +00:00
Mateusz Piotrowski
55b954c628 Remove an unnecessary macro
MFC after:	2 days
2020-08-17 08:24:50 +00:00
Kirk McKusick
f644caad88 Use the sbput() function to write alternate superblocks so that
they get a checkhash.

PR:           246983
Sponsored by: Netflix
2020-08-15 21:40:36 +00:00
Eugene Grosbein
cf51899564 ifconfig(8): plug memory leak after r361790 by me.
MFC after:	3 days
2020-08-13 06:32:39 +00:00
Gleb Smirnoff
825398f946 ipfw: make the "frag" keyword accept additional options "mf",
"df", "rf" and "offset".  This allows to match on specific
bits of ip_off field.

For compatibility reasons lack of keyword means "offset".

Reviewed by:	ae
Differential Revision:	https://reviews.freebsd.org/D26021
2020-08-11 15:46:22 +00:00
Ryan Moeller
94cba8034b Move ifconfig SFP status functionality into libifconfig
libifconfig_sfp.h provides an API in libifconfig for querying SFP module
properties, operational status, and vendor strings, as well as descriptions
of the various fields, string conversions, and other useful helpers for
implementing user interfaces.

SFP module status is obtained by reading registers via an I2C interface.
Descriptions of these registers and the values therein have been collected
in a Lua table which is used to generate all the boilerplace C headers and
source files for accessing these values, their names, and descriptions.
The generated code is fully commented and readable.

This is the first use of libifconfig in ifconfig itself.  For now, the
scope remains very limited.  Over time, more of ifconfig will be replaced
with libifconfig.

Some minor changes to the formatting of ifconfig output have been made:
- Module memory hex dumps are indented one extra space as a result of using
hexdump(3) instead of a bespoke hex dump function.
- Media descriptions have an added two-character short-name in parenthesis.
- QSFP modules were incorrectly displaying TX bias current as power.  Now
  TX channels display bias current, and this change has been made for both
  SFP and QSFP modules for consistency.

A Lua binding for libifconfig including this functionality is implemented
but has not been included in this commit.  The plan is for it to be
committed after dynamic module loading has been enabled in flua.

Reviewed by:	kp, melifaro
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D25494
2020-08-09 16:27:28 +00:00
Bjoern A. Zeeb
7d1d4407f5 net80211/ifconfig: print hardware device name for wlan interfaces
Add IEEE80211_IOC_IC_NAME to query the ic_name field and in ifconfig
to print the parent interface again. This functionality was lost
around r287197. It helps in case of multiple wlan interfaces and
multiple underlying hardware devices to keep track which wlan
interface belongs to which physical device.

Sponsored by:	Rubicon Communications, LLC (d/b/a "Netgate")
Reviewed by:	adrian, Idwer Vollering
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D25832
2020-08-07 12:24:23 +00:00
Emmanuel Vadot
4323354324 pkgbase: We can't easily have a package with either a - or a _
Rename iscsi_legacy to iscsilegacy, having - or _ in a package name cause
problems when we process them and generate the ucl.
2020-08-07 12:19:21 +00:00
Warner Losh
57d4cc2c58 All the other printf() calls cast to (void) here, do the two newer ones for
consistency.
2020-08-07 02:48:19 +00:00
Andrey V. Elsukov
2403d47744 Fix SIGSEGV in ipfw(8) when NAT64 prefix length is omitted.
Submitted by:	Evgeniy Khramtsov <evgeniy at khramtsov org>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25734
2020-08-05 11:26:49 +00:00
Olivier Cochard
784d8d8db0 Skip sbin/route tests if jail not installed (WITHOUT_JAIL).
Approved by:	kp
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D25935
2020-08-04 21:34:13 +00:00
Yoshihiro Takahashi
8f11c99715 - Cleanups related to sparc64 removal.
- Remove remains of sparc64 files.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D25831
2020-07-28 10:58:37 +00:00
Ilya Bakulin
badc50c270 Make it possible to get/set MMC frequency from camcontrol
Enhance camcontrol(8) so that it's possible to manually set frequency for SD/MMC cards.
While here, display more information about the current controller, such as
supported operating modes and VCCQ voltages, as well as current VCCQ voltage.

Reviewed by:	manu
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D25795
2020-07-24 21:14:59 +00:00
Ed Maste
af9de844c4 md5: return non-zero if built-in tests (-x) fail
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-07-23 20:06:24 +00:00
Alexander Motin
81614d236f Add missing newlines.
MFC after:	3 days
2020-07-23 14:33:25 +00:00
Tom Jones
3b01bf881c Add tests for "add", "change" and "delete" functionality of /sbin/route.
Add tests to cover "add", "change" and "delete" functionality of /sbin/route
for ipv4 and ipv6. These tests for the existing route tool are the first step
towards creating libroute.

Submitted by:   Ahsan Barkati
Sponsored by:   Google, Inc. (GSoC 2020)
Reviewed by:    kp, thj
Approved by:    bz (mentor)
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D25220
2020-07-22 13:49:54 +00:00
Simon J. Gerraty
f2be828f97 Revert that! 2020-07-19 23:56:19 +00:00
Simon J. Gerraty
e17f5b1d30 Oops missed Makefile.config 2020-07-19 23:54:00 +00:00
Gordon Bergling
d511702b8d mount_nfs(8): document alternate form of the gssname option
PR:		238506
Submitted by:	Greg Veldman <freebsd at gregv dot net>
Reviewed by:	0mp, bcr (mentor)
Approved by:	bcr (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25667
2020-07-17 21:55:24 +00:00
Mateusz Piotrowski
f2ed697e73 Remove old devd rules for ActiveWire and Entrega Serial DB25
Those rules have been broken at least since 8-STABLE, when the port
providing the ezdownload binary was removed (misc/ezload).

Reviewed by:	kevans, imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D25686
2020-07-16 14:04:29 +00:00
Adrian Chadd
268a20a0e7 [ipfw] quieten maybe-uninitialized errors in ipfw when compiled under mips-gcc-6.3.0.
This is mostly an exercise to set variables to NULL/0 when declared, but
one was ensuring a string variable was set before printing it.
We should never see "<unknown>" in a printed rule; if we do then this code
definitely has some bugs that need addressing.
2020-07-14 05:07:16 +00:00
Mark Johnston
165236a101 ipfw(8): Handle unaligned pointers in pr_u64.
struct _ipfw_dyn_rule is defined as packed, and as a result, its
uint64_t fields are misaligned on some 32-bit platforms.  Since
pr_u64() is explicitly supposed to handle this case, avoid using a
uint64_t * for the input pointer to make sure that the compiler won't
(correctly) warn about the misalignment.

Reported by:	jenkins
MFC with:	r363164
2020-07-13 19:10:16 +00:00
Mark Johnston
56707bee4b ipfw(8): Fix most warnings with the default WARNS level.
- Add missing const and static qualifiers.
- Avoid shadowing the global "co" by renaming it to "g_co".
- Avoid mixing signedness in loop bound checks.
- Leave -Wcast-align warnings disabled for now.

Reviewed by:	ae, melifaro
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D25456
2020-07-13 17:51:04 +00:00
Allan Jude
d046aae254 boot(8): fix sorting of cross references
Reported by:	yuripv
Event:		July 2020 Bugathon
2020-07-11 19:29:24 +00:00
Allan Jude
4f9917f5ff boot(8): Add additional cross references
Provide hints to direct people towards gptzfsboot, zfsbootcfg, efibootmgr, etc

PR:		199103
MFC after:	2 weeks
Sponsored by:	Klara Inc.
Event:		July 2020 Bugathon
2020-07-11 19:18:43 +00:00
Mark Johnston
87f9c14ad3 ping(8): Check for integer truncation when handling the value for -s.
PR:		239976
Submitted by:	Neeraj <neerajpal09@gmail.com>
MFC after:	1 week
Event:		July 2020 Bugathon
2020-07-11 17:10:16 +00:00
Niclas Zeising
814321a0e8 shutdown.8: Fix typo
Fix a typo in shutdown.8, use ',' instead of '.' when listing items.

MFC after:	1 week
2020-07-05 13:08:17 +00:00
Xin LI
1cbad9d72b Use KERN_MAXPHYS.
Suggested by:	imp
Reviewed by:	imp, cem (earlier version), emaste
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D25563
2020-07-05 00:19:08 +00:00
Xin LI
33c2d974d0 Gather writes to larger chunks (MAXPHYS) instead of issuing them in
sectors.

On my SanDisk Cruzer Blade 16GB USB stick this made formatting much faster:

x before
+ after
+--------------------------------------------------------------------------+
|+                                                                         |
|+                                                                      x  |
|+                                                                      x x|
|A                                                                      MA||
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         15.89         16.38            16         16.09     0.2570992
+   3          0.32          0.37          0.35    0.34666667   0.025166115
Difference at 95.0% confidence
	-15.7433 +/- 0.414029
	-97.8455% +/- 0.25668%
	(Student's t, pooled s = 0.182665)

Reviewed by:	emaste
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24508
2020-07-04 18:37:04 +00:00
Ryan Moeller
e5539fb618 libifconfig: Add function to get bridge status
The new function operates similarly to ifconfig_lagg_get_lagg_status and
likewise is accompanied by a function to free the bridge status data structure.

I have included in this patch the relocation of some strings describing STP
parameters and the PV2ID macro from ifconfig into net/if_bridgevar.h as they
are useful for consumers of libifconfig.

Reviewed by:	kp, melifaro, mmacy
Approved by:	mmacy (mentor)
MFC after:	1 week
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D25460
2020-07-01 02:32:41 +00:00
Alan Somers
81884a247c savecore: accept device names without the /dev/ prefix
dumpon has accepted device names without the prefix ever since r291207.
Since dumpon and savecore are always paired, they ought to accept the same
arguments. Prior to this change, specifying 'dumpdev="da3"' in
/etc/rc.conf, for example, would result in dumpon working just fine but
savecore complaining that "Dump device does not exist".

PR:		247618
Reviewed by:	cem, bcr
MFC after:	2 weeks
Sponsored by:	Axcient
Differential Revision:	https://reviews.freebsd.org/D25500
2020-06-29 22:12:23 +00:00
Allan Jude
d4be5ce558 ifconfig(8): optimize -f ether:dash mode
Switch to the simplified while loop suggest by Aaron LI

Post commit review via: https://reviews.freebsd.org/rS301185#inline-232

Submitted by:	Aaron LI <aly@aaronly.me>
Sponsored by:	Klara Inc.
2020-06-26 16:20:34 +00:00
Allan Jude
d9d09a7c99 ifconfig(8): remove duplicate line from man page
Reported by:	Weitian LI <liweitianux@live.com>
Sponsored by:	Klara Inc.
2020-06-26 15:14:03 +00:00
Mark Johnston
a3349dd906 ipfw: Support the literal IPv6 address syntax in the fwd command.
Discussed with:	rgrimes, Lutz Donnerhacke
Submitted by:	Neel Chauhan <neel AT neelc DOT org>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24011
2020-06-25 19:27:22 +00:00
Mark Johnston
27b3db9709 ipfw(8): In fill_ip6(), use a single statement for both "me" and "me6".
Submitted by:	Neel Chauhan <neel AT neelc DOT org>
Reviewed by:	rgrimes, Lutz Donnerhacke
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24403
2020-06-24 15:05:42 +00:00
Kirk McKusick
92c839a156 The libufs library needs to track and free the new fs_si structure
in addition to the fs_csp structure that it references.

PR:           247425
Sponsored by: Netflix
2020-06-23 21:28:26 +00:00
Colin Percival
0c577f4f80 Clean up some function and variable names.
The change from "slave" processes to "minion" processes to "worker"
processes left some less-than-coherent names:
1. "enslave" turned into the ungrammatical "enworker".
2. "slp" (SLave Pointer) turned into "mlp" (Minion [L] Pointer?).

Convert "enworker" to "create_workers" (the function in question forks
off 3 worker processes), and replace "mlp" with "wp" (Worker Pointer)
and "tmlp" with "twp" (Temporary Worker Pointer).

Reviewed by:	imp, cem, danfe
Differential Revision:	https://reviews.freebsd.org/D25403
2020-06-23 21:11:40 +00:00
Mateusz Piotrowski
f5c5d4147f Improve the rcorder manual page
- Fix formatting issues such as:
  - Use Ql instead of Dq Li as Li is deprecated
  - Address some mandoc warnings
- Add arguments missing from the list of options (i.e., document "-k keep"
  instead of just "-k").
- Document that -k and -s can be specified multiple times
- Use sshd instead of named for the example in the BUGS section, as named
  is not in the base system. Also, use Nm instead of Xr there as it is not
  the sshd binary that is required to be running, but the service.
- Use Sy instead of Cm for KEYWORDS. Cm is reserved for command-line
  modifiers of the CLI.
- Add an EXAMPLES section
- Cross-reference service(8).

MFC after:	2 weeks
2020-06-22 10:01:24 +00:00
Conrad Meyer
a74534b121 dump(8): Reapply slightly modified r362422
Go ahead and replace the distasteful slave language for worker processes
with the straightforward description, "worker(s)."
2020-06-20 20:14:50 +00:00
Warner Losh
b1779ca056 Revert -r362422.
While whimsical, there's too much negative energy around minion as well as the
positive.
2020-06-20 20:06:14 +00:00
Warner Losh
0447cda0cb Increase the whimsy in this file by famring dump's work out to minions. Adjust
variables accordingly. Thankfully, we are able to do this without additional
banana expenditures.
2020-06-20 04:19:17 +00:00
Allan Jude
0bc6f34c3d md5(1): fix -c flag to work with input on stdin
Previously, the -p and -c flags were ignored when reading from stdin
Additionally, -s and -c can be used together now.

PR:		247295
Reviewed by:	kevans
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D25362
2020-06-19 19:16:25 +00:00
Fernando Apesteguía
83d742d661 md5(1): Add EXAMPLES section
Add EXAMLES covering -c, -s and -r

Approved by:	bcr@, 0mp@
Differential Revision:	https://reviews.freebsd.org/D25278
2020-06-19 06:23:55 +00:00
Kirk McKusick
34816cb9ae Move the pointers stored in the superblock into a separate
fs_summary_info structure. This change was originally done
by the CheriBSD project as they need larger pointers that
do not fit in the existing superblock.

This cleanup of the superblock eases the task of the commit
that immediately follows this one.

Suggested by: brooks
Reviewed by:  kib
PR:           246983
Sponsored by: Netflix
2020-06-19 01:02:53 +00:00
Mateusz Piotrowski
0a0c18180c Document that umount -A does not unmount /dev
Reported by:	kaktus
Reviewed by:	kaktus
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25351
2020-06-18 23:12:55 +00:00
Adrian Chadd
c11c97cc61 [ifconfig] add UAPSD and LPDC flags
* Add UAPSD and LDPC flags
* expand the FLAGS section; it's kinda grown since I started hacking
  on net80211..
2020-06-16 04:17:08 +00:00
Adrian Chadd
4cd568babf [net80211] Add uapsd option to ifconfig
Add an enable/disable option for controlling uapsd.  I'm not yet controlling
the individual AC configs or the service period.
2020-06-16 00:28:08 +00:00
Fernando Apesteguía
7d40dd249a md5(1): fix style in man page
Fix a bunch of style problems reported by mandoc(1) and igor:

mandoc: ./md5.1:19:71: STYLE: no blank before trailing delimiter: Nm ... rmd160,
mandoc: ./md5.1:20:23: STYLE: no blank before trailing delimiter: Nm ...  skein512,
mandoc: ./md5.1:33:2: STYLE: useless macro: Tn
mandoc: ./md5.1:33:2: STYLE: useless macro: Tn
mandoc: ./md5.1:33:2: STYLE: useless macro: Tn
mandoc: ./md5.1:33:2: STYLE: useless macro: Tn
mandoc: ./md5.1:35:2: STYLE: useless macro: Tn
mandoc: ./md5.1:42:2: STYLE: useless macro: Tn
mandoc: ./md5.1:45:2: STYLE: useless macro: Tn
mandoc: ./md5.1:47:2: STYLE: useless macro: Tn
mandoc: ./md5.1:56:2: STYLE: useless macro: Tn
mandoc: ./md5.1:58:2: STYLE: useless macro: Tn
mandoc: ./md5.1:61:2: STYLE: useless macro: Tn
mandoc: ./md5.1:66:2: STYLE: useless macro: Tn
mandoc: ./md5.1:68:2: STYLE: useless macro: Tn
mandoc: ./md5.1:104:24: STYLE: no blank before trailing delimiter: Nm skein512,
mandoc: ./md5.1:117:6: STYLE: referenced manual not found: Xr sha224 3

igor:
md5.1:46:no comma after "i.e.":either algorithm, [i.e.] to find an input that produces a specific

Approved by:	bcr@
Differential Revision: https://reviews.freebsd.org/D25277
2020-06-15 10:08:02 +00:00
Ravi Pokala
2a73c8f5e1 Decode the "LACP Fast Timeout" LAGG option flag
r286700 added the "lacp_fast_timeout" option to `ifconfig', but we forgot to
include the new option in the string used to decode the option bits. Add
"LACP_FAST_TIMO" to LAGG_OPT_BITS.

Also, s/LAGG_OPT_LACP_TIMEOUT/LAGG_OPT_LACP_FAST_TIMO/g , to be clearer that
the flag indicates "Fast Timeout" mode.

Reported by:	Greg Foster <gfoster at panasas dot com>
Reviewed by:	jpaetzel
MFC after:	1 week
Sponsored by:	Panasas
Differential Revision:	https://reviews.freebsd.org/D25239
2020-06-11 22:46:08 +00:00
Conrad Meyer
b68e92ff60 x86 boot.8: Remove obsolescent non-loader x86 boot documentation
x86 boot uses loader(8) and the boot2-direct-to-kernel process is not
supported.  Remove the documentation, which doesn't document a working
process and leads to confusion.

PR:		247074
Reported by:	Alex K.
2020-06-08 00:46:19 +00:00
Toomas Soome
007278ebf0 zfsbootcfg: use vfs.root.mountfrom and update nextboot on every vdev
vfs.zfs.boot.primary_pool is only set on BIOS boot, use vfs.root.mountfrom
instead and update all vdevs on pool.

Reviewed by:	allanjude
Sponsored by:	Netflix, Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D25103
2020-06-05 18:18:27 +00:00
John Baldwin
00a4311adc Refer to AES-CBC as "aes-cbc" rather than "rijndael-cbc" for IPsec.
At this point, AES is the more common name for Rijndael128.  setkey(8)
will still accept the old name, and old constants remain for
compatiblity.

Reviewed by:	cem, bcr (manpages)
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D24964
2020-06-04 22:58:37 +00:00
Mark Johnston
0006082054 dhclient: Fix a logic bug remove_protocol().
A logic bug in remove_protocol() meant that it would remove (leak) all
structures in the list preceding the one intended for removal.

PR:		245971
Submitted by:	joost@jodocus.org (original version)
MFC after:	1 week
2020-06-04 16:24:13 +00:00
Eugene Grosbein
8e725dacd2 ifconfig(8): make it possible to filter output by interface group.
Now options -g/-G allow to select/unselect interfaces by groups
in the "ifconfig -a" output just like already existing -d/-u.

Examples:

to exclude loopback from the list: ifconfig -a -G lo
to show vlan interfaces only: ifconfig -a -g vlan
to show tap interfaces that are up: ifconfig -aug tap

Arguments to -g/-G may be shell patterns and both may be specified.
Later options -g/-G override previous ones.

MFC after:		2 weeks
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D25029
2020-06-04 14:44:44 +00:00
Andriy Gapon
f95cfecbb2 ifconfig.8: fix cpability and flag descriptions for list scan / sta
Some capability descriptions under list scan actually described flags.
Some capability descriptions were missing.
Some flag descriptions under list sta actually described capabilites.

Reviewed by:	adrian
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D25014
2020-06-04 13:06:49 +00:00
Eugene Grosbein
48773728fe ifconfig(8): spell "groupname" consistently with SYNOPSYS.
MFC after:	1 week
2020-05-27 08:16:17 +00:00
Ryan Moeller
245bfd34da Deduplicate fsid comparisons
Comparing fsid_t objects requires internal knowledge of the fsid structure
and yet this is duplicated across a number of places in the code.

Simplify by creating a fsidcmp function (macro).

Reviewed by:	mjg, rmacklem
Approved by:	mav (mentor)
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D24749
2020-05-21 01:55:35 +00:00
Benedict Reuschling
acace3175c The -F flag of swapon(8) requires -a to work.
Before this change, swapon(8) implied that -F works as a standalone option,
which is not the case and would produce a usage message. This change extends
the description of the -F option to mention that -a is required with it.

PR:		238551
Submitted by:	Christian Baltini
MFC after:	5 days
2020-05-19 12:16:44 +00:00
Poul-Henning Kamp
ca9acde238 Don't send clear screen until we are committed to run. 2020-05-09 10:55:34 +00:00
John Baldwin
af5b6f81db Add RFC reference for AES-CTR with IPsec.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2020-05-04 16:50:01 +00:00
Xin LI
883b75538f - Fix logic error in swapoff case: follow same handling of p and
linelen in the swapon case.
 - Use strlcpy instead of strncpy.

MFC after:	1 week
2020-05-04 05:49:11 +00:00
Chuck Silvers
a9d9cfff01 Print the fs last-mounted time too.
Reviewed by:	mckusick
Approved by:	mckusick (mentor)
Sponsored by:	Netflix
2020-05-02 00:10:25 +00:00
John Baldwin
16aabb761c Remove support for IPsec algorithms deprecated in r348205 and r360202.
Examples of depecrated algorithms in manual pages and sample configs
are updated where relevant.  I removed the one example of combining
ESP and AH (vs using a cipher and auth in ESP) as RFC 8221 says this
combination is NOT RECOMMENDED.

Specifically, this removes support for the following ciphers:
- des-cbc
- 3des-cbc
- blowfish-cbc
- cast128-cbc
- des-deriv
- des-32iv
- camellia-cbc

This also removes support for the following authentication algorithms:
- hmac-md5
- keyed-md5
- keyed-sha1
- hmac-ripemd160

Reviewed by:	cem, gnn (older verisons)
Relnotes:	yes
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D24342
2020-05-02 00:06:58 +00:00
Warner Losh
e2d6a6e938 Document the passthru commands.
Reviewed by: bcr@ (earlier version)
Differential Revision: https://reviews.freebsd.org/D24639
2020-05-01 20:29:51 +00:00
Warner Losh
a41b48ea12 Various improvements to this man page:
o Be consistent about device-id and namespace-id
o Use consistent arg markup for these
o document you can use disk names too
o document nsid command better
o document the idenntify command
o add a couple of examples.

Differential Revision: https://reviews.freebsd.org/D24638
2020-05-01 20:29:46 +00:00
Olivier Cochard
b33e1edd26 Skip bectl jail test if jail not installed (WITHOUT_JAIL).
Approved by:	kevans
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D24613
2020-04-29 14:15:21 +00:00
Xin LI
85f4f80c42 Do not overflow when calculating file system size.
Reported by:		Hyeongseok Kim <hyeongseok kim lge com>
Reviewed by:		cem, Hyeongseok Kim
MFC after:		3 days
Differential Revision:	https://reviews.freebsd.org/D24603
2020-04-28 05:10:34 +00:00
Xin LI
401475f50c Fix a bug with dirty file system handling.
r356313 broke handling of dirty file system because we have restricted
the correction of "odd" byte sequences to checkfat(), and as a result
the dirty bit is never cleared.  The old fsck_msdosfs code would write
FAT twice to fix the dirty bit, which is also not ideal.

Fix this by introducing a new rountine, cleardirty() which will perform
the set of clean bit only, and use it in checkfilesys() if we thought
the file system was dirty.

Reviewed by:		cem, emaste
MFC after:		3 day
Differential Revision:	https://reviews.freebsd.org/D24581
2020-04-27 02:01:48 +00:00
Conrad Meyer
7575e5c472 dumpon.8: Update minimum key size language
dumpon(8) has not accepted 1024-bit RSA keys since prior to r339784 (2018-10).
The manual page language was not updated at that time (oops).  The minimum
accepted is 2048 bits, which is also a good default choice.

Sponsored by:	Dell EMC Isilon
2020-04-23 18:04:52 +00:00
Conrad Meyer
4647ce4fb6 EKCD: Preload error strings, PRNG seed; use OAEP padding
Preload OpenSSL ERR string data so that the formatted error messages are
vaguely meaningful. Add OpenSSL error information to the RSA_public_encrypt()
operation failure case in one-time key generation.

For obsolescent OpenSSL versions (*cough* FIPS *cough*), pre-seed the PRNG
before entering Cap mode, as old versions of OpenSSL are unaware of kernel
RNG interfaces aside from /dev/random (such as the long-supported kern.arnd, or
the slightly more recent getentropy(3) or getrandom(2)). (RSA_public_encrypt()
wants a seeded PRNG to randomize the "PS" portion of PKCS 1.5 padding or the
"MGF" pseudo-random function in OAEP padding.)

Switch dumpon to encrypt the one-time key with OAEP padding (recommended since
1998; RFC2437) rather than the obsolescent PKCS 1.5 padding (1993; RFC2313).

Switch decryptcore to attempt OAEP decryption first, and try PKCS 1.5
decryption on failure. This is intended only for transition convenience, and
we should obsolete support for non-OAEP padding in a release or two.

Reviewed by:	markj
MFC After:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D24534
2020-04-23 17:56:48 +00:00
Alexander Motin
5458a1c840 Allow namespace-id specification where it makes sense.
It makes tool more convenient to not require user to explicitly convert
namespace device name into controller device name.  There should be no
changes to already existing syntaxes.

MFC after:	1 week
2020-04-20 14:54:41 +00:00
Alexander Motin
1f15d49eea Open device with O_RDONLY when command is non-invasive.
This allows to use some of the subcommands against mounted nvd devices.

MFC after:	1 week
Sponsored by:	iXystems, Inc.
2020-04-20 13:47:07 +00:00
Kristof Provost
8fd675d8a0 pfctl: Call ifa_load() before ifa_grouplookup()
ifa_grouplookup() uses the data loaded in ifa_load() (through is_a_group()), so
we must call ifa_load() before we can rely on any of the data it populates.

Submitted by:	Nick Rogers
MFC after:	1 week
Sponsored by:	RG Nets
2020-04-19 15:37:13 +00:00
Kristof Provost
681652667a pfctl: Remove unused variable
Submitted by:	Nick Rogers
MFC after:	1 week
Sponsored by:	RG Nets
2020-04-19 15:32:14 +00:00
Alan Somers
cb67aaf20c bectl.8: correctly sort SEE ALSO section after 360078
Reported by:	yuripv
MFC after:	2 weeks
MFC with:	360078
2020-04-19 01:43:59 +00:00
Alan Somers
27586155ac bectl.8, beinstall.sh.8: fix man page section of beinstall.sh
Reported by:	phk
MFC after:	2 weeks
2020-04-18 19:53:47 +00:00
Mateusz Piotrowski
789e4d2f20 Improve manual page formatting
-	Use appropriate macros for command arguments.
-	Increase option list indentation for better readability.

MFC after:	3 days
2020-04-14 10:10:31 +00:00
Li-Wen Hsu
862ac3b74a Ensure kyua list working when there is no /dev/nvme*
Sponsored by:	The FreeBSD Foundation
2020-04-13 21:08:54 +00:00
Mariusz Zaborski
eec362ef58 decryptcore: load the nls data
Load the nls data before the openssl will try to do it in the
capability mode.
On my machine the sa_ossl_private_decrypt is trying to do that.

MFC after:	2 weeks
2020-04-11 17:30:33 +00:00
Kirk McKusick
0c08ecdff3 Inode check-hash errors were being reported after system crashes.
Trace the cause down to journalled soft updates recovery code in
fsck failing to recompute the check-hash after updating an inode.

As inode check-hash was first introduced to UFS in FreeBSD 13,
there is no need to MFC this commit.

Reported by:  Chuck Silvers
Sponsored by: Netflix
2020-04-10 23:58:07 +00:00
Kirk McKusick
2a18059670 Add an inode check-hash verification when running the journalled
soft update recovery code with the debugging (-d) option.

As inode check-hash was first introduced to UFS in FreeBSD 13,
there is no need to MFC this commit.

Reported by:  Chuck Silvers
Sponsored by: Netflix
2020-04-10 23:49:34 +00:00
David Bright
0e3e53d746 Add a basic test for nvmecontrol
I recently made some bug fixes in nvmecontrol. It occurred to me that
since nvmecontrol lacks any kyua tests, I should convert the informal
testing I did into a more formal automated test. The test in this
change should be considered just a starting point; it is neither
complete nor thorough. While converting the test to ATF/kyua, I
discovered a small bug in nvmecontrol; the nvmecontrol devlist command
would always exit with an unsuccessful status. So I included the fix
for that, too, so that the test won't fail.

Reviewed by:	imp@
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D24269
2020-04-07 20:26:42 +00:00
Kirk McKusick
33ceb489d3 Clean up global variable declarations in the dump and restore
utilities so that they will compile with -fno-common.

Started by:  Kyle Evans (kevans)
Reviewed by: Kyle Evans (kevans)
MFC after:   1 week
Differential Revision: https://reviews.freebsd.org/D24210
2020-04-04 00:56:56 +00:00
Mateusz Piotrowski
b75ab02f57 Bump date after recent changes and lint 2020-04-03 13:05:26 +00:00
Poul-Henning Kamp
9546e08e7b Add two options to recoverdisk(1) inspired by a recent
data-archæology project:

-u pattern

    Fill unread parts of the output with pattern.
    Default pattern is "_UNREAD_", empty pattern disables.

-v

    Fancy status reporting using ANSI escapes and UTF-8
2020-04-02 15:17:53 +00:00
David Bright
6995fb5eb7 Fix various Coverity-detected errors in nvmecontrol
This fixes several Coverity-detected errors in nvmecontrol. While in
here, a couple additional errors with shift/mask confusion that were
not diagnosed by Coverity are also fixed.

CIDs addressed: 1040299, 1040300, 1403972, 1403973, 1403985, 1403988,
1403990, 1404374, 1404427, 1404469, 1404510, 1404534, 1418118

CID 1403657 (resource leak of shared library handle) was marked
"intentional" in the Coverity scan database.

Reviewed by:	vangyzen, robert.herndon_dell.com
Reviewed by:	daniel.william.ryan_gmail.com (earlier version)
Reviewed by:	rramsden_isilon.com (earlier version), imp
MFC after:	5 days
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D24203
2020-04-02 13:52:54 +00:00
Kyle Evans
c3e9752ea1 fsck_ffs/fsdb: fix -fno-common build
This one is also a small list:

- 3x duplicate definition (ufs2_zino, returntosingle, nflag)
- 5x 'needs extern', 3/5 of which are referenced in fsdb

-fno-common will become the default in GCC10/LLVM11.

MFC after:	1 week
2020-03-29 20:03:46 +00:00
Kyle Evans
b4cd5daf75 iscontrol: move definition of vflag/iscsidev to iscontrol.c
Mark the declaration extern as these are used elsewhere; this fixes the
build with -fno-common.

MFC after:	3 days
2020-03-29 02:28:15 +00:00
Andrey V. Elsukov
db1102f213 Use IP_FW_NAT44_DESTROY opcode for IP_FW3 socket option to destroy
NAT instance.

The NAT44 group of opcodes for IP_FW3 socket option is modern way
to control NAT instances and this method can be used in future to
switch from numeric to named NAT instances, like was done for ipfw
tables.
The IP_FW_NAT_DEL opcode is the last remnant of old ipfw_ctl control
plane that doesn't support versioned operations. This interface will
be retired soon.

Reviewed by:	melifaro
MFC after:	10 days
Sponsored by:	Yandex LLC
2020-03-24 12:27:02 +00:00
Baptiste Daroussin
1b6c9c3f43 Remove the link to libl which only contains a stub function
on yywrap, if the flex is told yywrap is not in use, then this linkage becomes
unnecessary
2020-03-23 14:37:00 +00:00
Baptiste Daroussin
e2328be509 Revove useless linking to yacc 2020-03-23 14:11:49 +00:00
Kristof Provost
d2568b024d pfctl: improve rule load times with thousands of interfaces
r343287 / D18759 introduced ifa_add_groups_to_map() which is now run by
ifa_load/ifa_lookup/host_if. When loading an anchor or ruleset via pfctl that
does NOT contain ifnames as hosts, host() still ends up iterating all
interfaces twice, grabbing SIOCGIFGROUP ioctl twice for each. This adds an
unnecessary amount of time on systems with thousands or tens of thousands of
interfaces.

Prioritize the IPv4/6 check over the interface name lookup, which skips loading
the iftab and iterating all interfaces when the configuration does not contain
interface names.

Submitted by:	Nick Rogers
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24100
2020-03-19 12:54:43 +00:00
Ed Maste
2ee11faacf ldconfig: add aout deprecation notice
aout support in ldconfig hasn't been required since FreeBSD 2.x.
Anyone still using FreeBSD 2 shared libraries can also use a FreeBSD 2
ldconfig to generate aout ldconfig hints.

Sponsored by:	The FreeBSD Foundation
2020-03-17 15:57:25 +00:00
Alexander V. Chernikov
e3bf606c5d Revert r358858 as it breaks some ipfw(8) setups.
Reported by:	O. Hartmann <o.hartmann@walstatt.org>
2020-03-11 08:08:53 +00:00
Alexander V. Chernikov
8149b12da1 Don't assume !IPv6 is IPv4 in ipfw(8) add_src() and add_dst().
Submitted by:	Neel Chauhan <neel AT neelc DOT org>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D21812
2020-03-10 20:30:21 +00:00
Gleb Smirnoff
3f16af55b2 Align the buffer to the alignment of the structure we expect.
Submitted by:	Slawa Olhovchenkov <slw zxy.spb.ru>
2020-03-05 21:01:47 +00:00
Gleb Smirnoff
8cd9718f0b When a machine boots the NFS mounting script is executed after
interfaces are configured, but for many interfaces (e.g. all Intel)
ifconfig causes link renegotiation, so the first attempt to mount
NFS always fails. After that mount_nfs sleeps for 30 seconds, while
only a couple seconds are actually required for interface to get up.

Instead of sleeping, do select(2) on routing socket and check if
some interface became UP and in this case retry immediately.

Reviewed by:	rmacklem
Differential Revision:	https://reviews.freebsd.org/D23934
2020-03-04 22:27:16 +00:00
Eric van Gyzen
7bef70737b dumpon: skip size check if using zstd
As with gzip, let the dump device be smaller than physical memory
when using zstd and full dumps.

Also print the error message if the size check fails, even if -v
is not specified.  Failing silently is not friendly.

Reviewed by:	cem markj
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D23923
2020-03-03 22:14:23 +00:00
Li-Wen Hsu
fe44c67716 Fix test cases after r358448
sbin.pfctl.pfctl_test.pf0087
sbin.pfctl.pfctl_test.selfpf0087

MFC with:	r358448
Sponsored by:	The FreeBSD Foundation
2020-02-29 13:24:41 +00:00
Alexander V. Chernikov
af14123601 Make ping6(1) return code consistent with the man page.
When every sendto() call originated by ping6(1) fails, current code always
 returns 2 ("transmission was successful but no responses were received")
 which is incorrect. Return EX_OSERR instead as in many cases it indicates
 some kernel-level problems.

MFC after:	3 weeks
2020-02-15 15:39:53 +00:00
Dimitry Andric
dacf624d5f Fix the following -Werror warning from clang 10.0.0 in sconfig:
sbin/sconfig/sconfig.c:909:5: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                                exit (-1);
                                ^
sbin/sconfig/sconfig.c:907:6: note: previous statement is here
                        } else
                          ^

The intent was to group the exit() call with the previous fprintf()
call.

MFC after:	3 days
2020-02-13 18:37:17 +00:00
Eugene Grosbein
04777538e7 ipfw nat: add missing bits after r357092 (RFC 6598/Carrier Grade NAT)
Submitted by:	Neel Chauhan <neel AT neelc DOT org>
Reviewed by:	Lutz Donnerhacke
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D23448
2020-02-12 00:46:33 +00:00
Xin LI
9e4029ff49 Use humanize_number to format available and bad space sizes.
Reviewed by:		mckusick (earlier version)
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D23050
2020-02-10 04:16:41 +00:00
Warner Losh
ab9848aa9b No need to make sunlabel anymore
It was only built on sparc64. Since it wasn't a general tool on other
architectures, no need to keep it around for another release.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D23524
2020-02-06 17:52:02 +00:00
Kyle Evans
21c1a93c04 init(8): set environment variables from the "daemon" class as well
Specifically, when running /etc/rc. This allows one to specify via
login.conf(5) an environment that should be used when running services to
ease, e.g., setting up env vars for an HTTP proxy consistently across cron
and services alike.

Future changes will extend cron(8)/service(8) to use environment vars
pecified in login.conf(5) as well to promote a more cohesive experience.

This is a part of D21481.

Submitted by:	Andrew Gierth <andrew_tao173.riddles.org.uk>
2020-02-05 04:27:44 +00:00
Xin LI
43f1940992 Diff reduction against NetBSD, no functional change.
MFC after:	1 week
2020-02-02 20:53:31 +00:00
Dimitry Andric
e54f2950a6 Fix the following -Werror warning from clang 10.0.0 in newfs_msdos:
sbin/newfs_msdos/newfs_msdos.c:181:2: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
        if (o.align) {
        ^
sbin/newfs_msdos/newfs_msdos.c:179:5: note: previous statement is here
    if (argc < 1 || argc > 2)
    ^

MFC after:	3 days
2020-01-28 20:10:26 +00:00
Alex Richardson
162ae9c834 Allow bootstrapping makefs on older FreeBSD hosts and Linux/macOS
In order to do so we need to install the msdosfs headers to the bootstrap
sysroot and avoid includes of kernel headers that may not exist on every
host (e.g. sys/lockmgr.h). This change should allow bootstrapping of makefs
on FreeBSD 11+ as well as Linux and macOS.

We also have to avoid using the IO_SYNC macro since that may not be
available. In makefs it is only used to switch between calling
bwrite() and bdwrite() which both call the same function. Therefore we
can simply always call bwrite().

For our CheriBSD builds we always bootstrap makefs by setting
LOCAL_XTOOL_DIRS='lib/libnetbsd usr.sbin/makefs' and use the makefs binary
from the build tree to create a bootable disk image.

Reviewed By:	brooks
Differential Revision: https://reviews.freebsd.org/D23201
2020-01-27 12:02:41 +00:00
Alexander V. Chernikov
75b893375f Add support for RFC 6598/Carrier Grade NAT subnets. to libalias and ipfw.
In libalias, a new flag PKT_ALIAS_UNREGISTERED_RFC6598 is added.
 This is like PKT_ALIAS_UNREGISTERED_ONLY, but also is RFC 6598 aware.
Also, we add a new NAT option to ipfw called unreg_cgn, which is like
 unreg_only, but also is RFC 6598-aware.  The reason for the new
 flags/options is to avoid breaking existing networks, especially those
 which rely on RFC 6598 as an external address.

Submitted by:	Neel Chauhan <neel AT neelc DOT org>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D22877
2020-01-24 20:35:41 +00:00
Kyle Evans
6966ac055c Drop "All Rights Reserved" from all libbe/bectl files
I sent out an e-mail on 2020/01/21 with a plan to do this to Kyle, Rob, and
Wes; all parties have responded in the affirmative that it's OK to drop it
from these files.
2020-01-24 02:18:09 +00:00
Warner Losh
73c6e0c358 Small tweak to the default behavior of shutdown -c
'shutdown -c' is supposed to power cycle the system rather than doing a normal
reboot. However, when that fails, it halts the system. This is not quite right
since the intent isn't to halt the system but to restart. Make the default init
behavior be to restart the system. The halt(8) interface can be used if you'd
like to powercycle or halt.

MFC After: 1 week
Differential Revision: https://reviews.freebsd.org/D23129
2020-01-17 01:20:48 +00:00
Eric van Gyzen
a532f299c9 savecore: include time zone in info.N file
This helps with event correlation when machines are distributed
across multiple time zones.

Format the time with relaxed ISO 8601 for all the usual reasons.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2020-01-13 22:01:37 +00:00
Xin LI
d14a599d69 Tighten FAT checks and fix off-by-one error in corner case.
sbin/fsck_msdosfs/fat.c:
 - readfat:
    * Only truncate out-of-range cluster pointers (1, or greater than
      NumClusters but smaller than CLUST_RSRVD), as the current cluster
      may contain some data. We can't fix reserved cluster pointers at
      this pass, because we do no know the potential cluster preceding
      it.
    * Accept valid cluster for head bitmap. This is a no-op, and mainly
      to improve code readability, because the 1 is already handled in
      the previous else if block.
 - truncate_at: absorbed into checkchain.
 - checkchain: save the previous node we have traversed in case that we
   have a chain that ends with a special (>= CLUST_RSRVD) cluster, or is
   free. In these cases, we need to truncate at the cluster preceding the
   current cluster, as the current cluster contains a marker instead of
   a next pointer and can not be changed to CLUST_EOF (the else case can
   happen if the user answered "no" at some point in readfat()).
 - clearchain: correct the iterator for next cluster so that we don't
   stop after clearing the first cluster.
 - checklost: If checkchain() thinks the chain have no cluster, it
   doesn't make sense to reconnect it, so don't bother asking.

Reviewed by:	kevlo
MFC after:	24 days
X-MFC-With:	r356313
Differential Revision:	https://reviews.freebsd.org/D23065
2020-01-12 06:13:52 +00:00
Xin LI
d3dd66792b Correct off-by-two issue when determining FAT type.
In the code we used NumClusters as the upper (non-inclusive) boundary
of valid cluster number, so the actual value was 2 (CLUST_FIRST) more
than the real number of clusters. This causes a FAT16 media with
65524 clusters be treated as FAT32 and might affect FAT12 media with
4084 clusters as well.

To fix this, we increment NumClusters by CLUST_FIRST after the type
determination.

PR:		243179
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D23082
2020-01-11 17:41:20 +00:00
Xin LI
727d995c7d Apply typo fix from NetBSD, we have already applied all NetBSD changes so
update the NetBSD tag while I'm there.

MFC after:	2 weeks
2020-01-11 04:02:40 +00:00
Xin LI
ed0879d944 Require FAT to occupy at least one sector.
Obtained from:	Android https://r.android.com/1205830
MFC after:	3 days
2020-01-11 03:59:06 +00:00
Mark Johnston
c23df8eafa lagg: Further cleanup of the rr_limit option.
Add an option flag so that arbitrary updates to a lagg's configuration
do not clear sc_stride.  Preseve compatibility for old ifconfig
binaries.  Update ifconfig to use the new flag and improve the casting
used when parsing the option parameter.

Modify the RR transmit function to avoid locklessly reading sc_stride
twice.  Ensure that sc_stride is always 1 or greater.

Reviewed by:	hselasky
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23092
2020-01-09 14:58:41 +00:00
Xin LI
9a67c570a9 fsck_msdosfs.8: document -M.
Reported by:	mckusick
Reviewed by:	mckusick, emaste, bcr
MFC after:	28 days
X-MFC-with:	r356313
Differential Revision:	https://reviews.freebsd.org/D23049
2020-01-07 04:33:14 +00:00
Alexander Motin
83018b7987 Fix host memory buffer sizes reporting.
Hardware reports values in 4KB units, not in bytes.

MFC after:	3 days
2020-01-06 01:51:23 +00:00
Xin LI
9708ba9f29 Reduce memory footprint of fsck_msdosfs.
This is a re-apply r356249 with changes to make GCC happy.

This utility was initially written for FAT12/16, which were inherently
small. When FAT32 support was added, the old data structure and
algorithms remain used with minimal changes.

With growing size of FAT32 media, the current data structure that
requires 4 32-bit variables per each FAT32 table entry would consume up
to 4 GiB of RAM, which can be too big for systems with limited RAM
available.

Address this by taking a different approach of validating the FAT.

The FAT is essentially a set of linked lists of chains that was
referenced by directory entries, and the checker needs to make sure that
the linked chains of clusters do not have cross-linked chains, and every
chain were referenced by one and only one directory entry.  Instead of
keeping track of the chain's 'head' cluster number, the size of the
chain, the used status of the chain and the "next" pointer which is
content of the FAT table, we create accessors for the FAT table data
for the "next" pointer, and keep only one bit to indicate if the
current cluster is a 'head' node of a cluster chain, in a bitmap.

We further overhaul the FAT checker to find out the possible head nodes
by excluding ones that are not (in other words, nodes that have some
other nodes claiming them as the next node) instead of marking the head
nodes for each node on the chain.  This approach greatly reduced the
complexiety of computation from O(N^2) worst case, to an O(N) scan for
worst case.  The file (cluster chain) length is not useful for the FAT
checker, so don't bother to calculate them in the FAT checker and
instead leave the task to the directory structure check, at which point
we would have non-crossed cluster chains, and we are guaranteed that
each cluster will be visited for at most one time.

When checking the directory structures, we use the head node indicator
to as the visited (used) flag: every cluster chain can only be
referenced by one directory entry, so we clear them when calculating
the length of the chain, and we can immediately tell if there are
anomalies in the directory entry.

As a result, the required RAM size is now 1 bit per each entry of
the FAT table, plus memory needed to hold the FAT table in memory,
instead of 16 bytes (=128 bits) per each entry.  For FAT12 and FAT16,
we will load the whole FAT table into memory as they are smaller than
128KiB, and for FAT32, we first attempt to mmap() it into memory, and
when that fails, we would fall back to a simple LRU cache of 4 MiB of
RAM.

sbin/fsck_msdosfs/boot.c:

 - Added additional sanity checks for valid FAT32/FAT16/FAT12 cluster
   number.
 - FAT32: check if root directory starts with a valid cluster number,
   moved from dir.c.  There is no point to proceed if the filesystem
   is already damaged beyond repair.

sbin/fsck_msdosfs/check.c:

 - Combine phase 1 and phase 2, now that the readfat() is able to
   detect cross chains.

sbin/fsck_msdosfs/dir.c:

 - Refactor code to use FAT accessor instead of accessing the internal
   representation of FAT table.
 - Make use of the cluster chain head bitmap.
 - Clarify and simplify directory entry check, remove unnecessary
   checks that are would be done at a later time (for example, whether
   the directory's second cluster is a valid one, which is examined
   more throughly in a later checkchain() and does not prevent us
   from proceeding further).

sbin/fsck_msdosfs/dosfs.h:

 - Remove internal representation of FAT table, which is replaced by
   the head bitmap that is opaque to other code.
 - Added a special CLUST_DEAD cluster type to indicate errors.

sbin/fsck_msdosfs/ext.h:

 - Added a flag that overrides mmap(2) setting.  The corresponding
   command line option, -M is intentionally undocumented as we do not
   expect users to need it.
 - Added accessors for FAT table and convert existing interface to use
   it.

sbin/fsck_msdosfs/fat.c:

 - Added head bitmap to represent whether a cluster is a head cluster.
 - Converted FAT internal representation to accessors.
 - Implemented a LRU cache for FAT32 when mmap(2) should not or can not
   be used.
 - _readfat: Attempt a mmap(2) and fall back to regular read for
   non-FAT32 file systems; use the LRU cache for FAT32 and prepopulate
   the cache with the first 4MiB of the entries.
 - readfat: Added support of head bitmap and use the population scan to
   detect bogus chains.
 - clusterdiff: removed, FATs are copied from the checked copy via
   writefat()/copyfat().
 - checkchain: calculates the length of a cluster chain and make sure
   that it ends with a valid EOF marker.
 - clearchain: follow and clear a chain and maintain the free cluster
   count.
 - checklost: convert to use head bitmap. At the end of all other scans,
   the remaining 'head' nodes are leaders of lost cluster chains.

sbin/fsck_msdosfs/fat.c:

 - Added a new -M option which is intentionally undocumented, to disable
   the use of mmap().

Reviewed by:	kevlo
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D22965
2020-01-03 00:31:48 +00:00
Kyle Evans
8f5c6c31ae libbe(3): promote dependent clones when destroying an environment
When removing a boot environment iterate over the dependents and process the
snapshots by grabbing any clones. Promote the clones we found and then
remove the target environment.

This fixes the ability to destroy a boot environment when it has been used
to spawn one or more other boot environments.

PR:		242592
Submitted by:	Wes Maag <jwmaag gmail com> (with changes by myself)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D22953
2020-01-02 18:46:33 +00:00
Xin LI
73db93b889 Revert r356249 for now as it broke GCC builds. 2020-01-01 09:22:06 +00:00
Xin LI
b06cf1e44f Reduce memory footprint of fsck_msdosfs.
This utility was initially written for FAT12/16, which were inherently
small. When FAT32 support was added, the old data structure and
algorithms remain used with minimal changes.

With growing size of FAT32 media, the current data structure that
requires 4 32-bit variables per each FAT32 table entry would consume up
to 4 GiB of RAM, which can be too big for systems with limited RAM
available.

Address this by taking a different approach of validating the FAT.

The FAT is essentially a set of linked lists of chains that was
referenced by directory entries, and the checker needs to make sure that
the linked chains of clusters do not have cross-linked chains, and every
chain were referenced by one and only one directory entry.  Instead of
keeping track of the chain's 'head' cluster number, the size of the
chain, the used status of the chain and the "next" pointer which is
content of the FAT table, we create accessors for the FAT table data
for the "next" pointer, and keep only one bit to indicate if the
current cluster is a 'head' node of a cluster chain, in a bitmap.

We further overhaul the FAT checker to find out the possible head nodes
by excluding ones that are not (in other words, nodes that have some
other nodes claiming them as the next node) instead of marking the head
nodes for each node on the chain.  This approach greatly reduced the
complexiety of computation from O(N^2) worst case, to an O(N) scan for
worst case.  The file (cluster chain) length is not useful for the FAT
checker, so don't bother to calculate them in the FAT checker and
instead leave the task to the directory structure check, at which point
we would have non-crossed cluster chains, and we are guaranteed that
each cluster will be visited for at most one time.

When checking the directory structures, we use the head node indicator
to as the visited (used) flag: every cluster chain can only be
referenced by one directory entry, so we clear them when calculating
the length of the chain, and we can immediately tell if there are
anomalies in the directory entry.

As a result, the required RAM size is now 1 bit per each entry of
the FAT table, plus memory needed to hold the FAT table in memory,
instead of 16 bytes (=128 bits) per each entry.  For FAT12 and FAT16,
we will load the whole FAT table into memory as they are smaller than
128KiB, and for FAT32, we first attempt to mmap() it into memory, and
when that fails, we would fall back to a simple LRU cache of 4 MiB of
RAM.

sbin/fsck_msdosfs/boot.c:

 - Added additional sanity checks for valid FAT32/FAT16/FAT12 cluster
   number.
 - FAT32: check if root directory starts with a valid cluster number,
   moved from dir.c.  There is no point to proceed if the filesystem
   is already damaged beyond repair.

sbin/fsck_msdosfs/check.c:

 - Combine phase 1 and phase 2, now that the readfat() is able to
   detect cross chains.

sbin/fsck_msdosfs/dir.c:

 - Refactor code to use FAT accessor instead of accessing the internal
   representation of FAT table.
 - Make use of the cluster chain head bitmap.
 - Clarify and simplify directory entry check, remove unnecessary
   checks that are would be done at a later time (for example, whether
   the directory's second cluster is a valid one, which is examined
   more throughly in a later checkchain() and does not prevent us
   from proceeding further).

sbin/fsck_msdosfs/dosfs.h:

 - Remove internal representation of FAT table, which is replaced by
   the head bitmap that is opaque to other code.
 - Added a special CLUST_DEAD cluster type to indicate errors.

sbin/fsck_msdosfs/ext.h:

 - Added a flag that overrides mmap(2) setting.  The corresponding
   command line option, -M is intentionally undocumented as we do not
   expect users to need it.
 - Added accessors for FAT table and convert existing interface to use
   it.

sbin/fsck_msdosfs/fat.c:

 - Added head bitmap to represent whether a cluster is a head cluster.
 - Converted FAT internal representation to accessors.
 - Implemented a LRU cache for FAT32 when mmap(2) should not or can not
   be used.
 - _readfat: Attempt a mmap(2) and fall back to regular read for
   non-FAT32 file systems; use the LRU cache for FAT32 and prepopulate
   the cache with the first 4MiB of the entries.
 - readfat: Added support of head bitmap and use the population scan to
   detect bogus chains.
 - clusterdiff: removed, FATs are copied from the checked copy via
   writefat()/copyfat().
 - checkchain: calculates the length of a cluster chain and make sure
   that it ends with a valid EOF marker.
 - clearchain: follow and clear a chain and maintain the free cluster
   count.
 - checklost: convert to use head bitmap. At the end of all other scans,
   the remaining 'head' nodes are leaders of lost cluster chains.

sbin/fsck_msdosfs/fat.c:

 - Added a new -M option which is intentionally undocumented, to disable
   the use of mmap().

Reviewed by:	kevlo
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D22965
2020-01-01 07:43:08 +00:00
Rick Macklem
56c049a003 Fix mount_nfs to recognize the NFSv4 specific errors returned by nmount(2).
When mount_nfs calls nmount(2), certain NFSv4 specific errors such as
NFSERR_MINORVERMISMATCH can be returned.
Without this patch, 10021 is reported as an unknown error.
This is not particulcarily serious, but make it difficult for sysadmins
to figure out why the mount attempt is failing.
This patch uses nfsv4_errstr.h to convert 10021 and similar to error strings
that can be printed out.
A positive side effect of this patch is the removal of a reference to
sys/nfsclient/nfs.h, which should no longer be used, since it is
part of the old NFS client.

This patch should only affect reporting of failed mount attempts and not the
semantics of NFS mount attempts.
2019-12-26 22:33:20 +00:00
Kirk McKusick
c094263a24 When running fsck_ffs manually, do not ask:
USE JOURNAL? [yn]

when the journal timestamp does not match the filesystem mount time
as we are just going to print an error and fall through to a full fsck.
Instead, just run a full fsck.

Requested by: Bjoern A. Zeeb (bz)
MFC after:    7 days
2019-12-24 23:03:12 +00:00
Mark Johnston
c104c2990d lagg: Clean up handling of the rr_limit option.
- Don't allow an unprivileged user to set the stride. [1]
- Only set the stride under the softc lock.
- Rename the internal fields to accurately reflect their use.  Keep
  ro_bkt to avoid changing the user API.
- Simplify the implementation.  The port index is just sc_seq / stride.
- Document rr_limit in ifconfig.8.

Reported by:	Ilja Van Sprundel <ivansprundel@ioactive.com> [1]
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D22857
2019-12-22 21:56:47 +00:00
Xin LI
e87e283ce3 Remove unused includes.
MFC after:	2 weeks
2019-12-22 05:44:29 +00:00
Kirk McKusick
b947472d42 Fix typo in hastd.8 manual page.
Reported by: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
MFC after:   3 days
2019-12-22 01:22:51 +00:00
Ryan Libby
36947e1f4d Declare packed struct ata_params as 2-byte-aligned
This avoids gcc9 warning about unaligned access to the structure when
casting to uint16_t pointer type.

Submitted by:	imp
Reviewed by:	imp
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D22888
2019-12-21 02:44:00 +00:00
Alexander Motin
3ab798a100 Add missing "ereport." prefixes of ZFS events.
I was unable to find time when those were working.  I think they have been
broken for at least 5 years or even longer.

Discussed with:	avg@
MFC after:	1 month
2019-12-18 18:43:44 +00:00
Warner Losh
6ee8575cd7 Remove all the RELEASE_CRUNCH defines, they are useless.
RELEASE_CRUNCH has been broken for a very long time. Remove the
last remants from the tree.
2019-12-16 21:06:24 +00:00
Alexander Motin
5233eb9dc6 Properly detect ATA sanitize errors.
It seems I read specifications not careful enough.  There are devices not
setting successful completion bit, causing previous code report false error.

MFC after:	1 week
2019-12-15 23:28:53 +00:00
Rick Macklem
547a4dba9f Update the mount_nfs.8 man page to include NFSv4.2.
r355677 added NFSv4.2 support to the NFS client. This patch updates the
mount_nfs.8 man page to reflect that.
It also clarifies that the "nolockd" option does not apply to NFSv4 mounts.

This is a content change.
2019-12-14 21:49:47 +00:00
Kristof Provost
3c7fbb06a0 pfctl: Warn users when they run into kernel limits
Warn users when they try to add/delete/modify more items than the kernel will
allow.

Reviewed by:	allanjude (previous version), Lutz Donnerhacke
Differential Revision:	https://reviews.freebsd.org/D22733
2019-12-14 02:03:47 +00:00
Alexander Motin
de57976691 Fix $() handling, broken since the beginning at r108014.
Due to off-by-one error in brackets counting it consumed the rest of the
string, preventing later variables expansions.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-12-13 17:52:09 +00:00
Conrad Meyer
d82e4d759d fsirand(8): Just use arc4random(3)
Remove single use of dubious srandomdev(3) + random(3) and replace with
arc4random(3), as is used already in this program.

Follow-up question: Do we really need this program anymore?  In base?
2019-12-13 04:12:13 +00:00
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
Eric van Gyzen
15da40b0af fsck_ffs: fix some memory leaks found by Coverity.
Reported by:	Coverity
CID:		1380549 1380550 1380551
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2019-12-10 20:04:08 +00:00
Don Lewis
1bf6738f80 Fix a logic bug in error handling code. It is an error if p == NULL.
The linelen tests are only meaningful when p != NULL.

Reported by:	Coverity
Coverity CID:	1368655
MFC after:	1 month
2019-12-09 07:18:40 +00:00
Xin LI
2780a26b6a Fix a couple of minor issues with newfs_msdos:
- Do not unnecessarily strdup().
 - Check return value of getdiskinfo(), if it failed, bail out.

Reviewed by:	imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D22729
2019-12-08 01:20:37 +00:00
Jens Schweikhardt
e7114e1e11 Correct a handful of typos/grammos. 2019-12-07 15:17:00 +00:00
Warner Losh
f86e60008b Regularize my copyright notice
o Remove All Rights Reserved from my notices
o imp@FreeBSD.org everywhere
o regularize punctiation, eliminate date ranges
o Make sure that it's clear that I don't claim All Rights reserved by listing
  All Rights Reserved on same line as other copyright holders (but not
  me). Other such holders are also listed last where it's clear.
2019-12-04 16:56:11 +00:00
Xin LI
7b9934a1c6 Explicitly exit() instead of return in main().
MFC after:	2 weeks
2019-12-03 07:03:25 +00:00
Xin LI
e453f01668 newfs_msdos: -A is incompatible with -r, not -o.
PR:		242314
Submitted by:	Guy Yur <guyyur gmail com>
MFC after:	2 weeks
2019-12-03 07:01:28 +00:00
Benedict Reuschling
23614c2b39 Capitalize some user-visible output messages in
the bectl utility.

No functional changes.

Approved by:	    imp@
MFC after:	    7 days
Differential Revision:	https://reviews.freebsd.org/D22330
2019-11-30 14:17:45 +00:00
Xin LI
f00c55e25a Use strlcat().
MFC after:	2 weeks
2019-11-30 05:57:54 +00:00
Conrad Meyer
74aed808a1 Fix braino in previous bugfix r300174
The previous revision missed the exact same error in a copy paste block
of the same code in another function.  Fix the identical case, too.

A DHCP client identifier is simply the hardware type (one byte)
concatenated with the hardware address (some variable number of bytes,
but at most 16).  Limit the size of the temporary buffer to match and
the rest of the calculations shake out correctly.

PR:		238022
Reported by:	Young <yangx92 AT hotmail.com>
Submitted by:	Young <yangx92 AT hotmail.com>
MFC after:	I don't plan to but you should feel free
Security:	yes
2019-11-29 03:31:47 +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
Dave Cottlehuber
130cfcf3fc dhclient: support option 114, default-url ascii
This will enable further automation of HTTP UEFI boot loader support by
providing a specific option for providing the boot URL to FreeBSD.

Documented in:

https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml
https://kb.isc.org/docs/isc-dhcp-44-manual-pages-dhcp-options
https://tools.ietf.org/html/rfc3679

Approved by:	emaste
MFC after:	2 weeks
Sponsored by:	SkunkWerks, GmbH
Differential Revision:	https://reviews.freebsd.org/D22475
2019-11-22 20:22:16 +00:00
Alexander Motin
f97cf1a168 Fix off-by-one error in HPA/AMA maximum reporting.
Before my refactoring the code reported value as maximum number of sectors,
adding one to the maximum sector number returned by respective command.
While this difference is somewhat confusing, restore previous behavior.

MFC after:	3 days
2019-11-22 15:41:47 +00:00