Commit Graph

8726 Commits

Author SHA1 Message Date
Mariusz Zaborski
8f1c45c20a Introduce dry run option for attaching the device.
This will allow us to verify if passphrase and key is valid without
decrypting whole device.

Reviewed by:	cem@, allanjude@
Differential Revision:	https://reviews.freebsd.org/D15000
2018-04-10 13:22:48 +00:00
Edward Tomasz Napierala
f0bbdd70ad Strip trailing whitespace.
MFC after:	2 weeks
2018-04-10 08:13:59 +00:00
Kirk McKusick
2a36aee276 When using the fsdb `blocks' command, replace the long and ugly list of
blocks with the much more concise and readable block list shown by the
prtblknos() function imported from tools/diag/prtblknos.
2018-04-08 07:06:12 +00:00
Rodney W. Grimes
2e23ded5c4 Exit with usage when extra arguments are on command line
preventing mistakes such as "halt 0p" for "halt -p".
Approved by:	bde (mentor), phk (mentor)
MFC after:	1 week
2018-04-05 15:00:08 +00:00
Alexander V. Chernikov
2d5832444f Fix memory leaks in route(8).
Submitted by:	Tom Rix (trix_juniper.net)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D9676
2018-03-31 15:06:14 +00:00
Andrey V. Elsukov
aed0267989 Rework ipfw rules parsing and printing code.
Introduce show_state structure to keep information about printed opcodes.
Split show_static_rule() function into several smaller functions. Make
parsing and printing opcodes into several passes. Each printed opcode
is marked in show_state structure and will be skipped in next passes.
Now show_static_rule() function is simple, it just prints each part
of rule separately: action, modifiers, proto, src and dst addresses,
options. The main goal of this change is avoiding occurrence of wrong
result of `ifpw show` command, that can not be parsed by ipfw(8).
Also now it is possible to make some simple static optimizations
by reordering of opcodes in the rule.

PR:		222705
Discussed with:	melifaro
MFC after:	2 weeks
Sponsored by:	Yandex LLC
2018-03-28 12:44:28 +00:00
Edward Tomasz Napierala
0457d75c14 Bump .Dd after r331113.
Reported by:	oshogbo@
MFC after:	2 weeks
2018-03-27 16:38:32 +00:00
Konstantin Belousov
f137973487 Allow to specify PCP on packets not belonging to any VLAN.
According to 802.1Q-2014, VLAN tagged packets with VLAN id 0 should be
considered as untagged, and only PCP and DEI values from the VLAN tag
are meaningful.  See for instance
https://www.cisco.com/c/en/us/td/docs/switches/connectedgrid/cg-switch-sw-master/software/configuration/guide/vlan0/b_vlan_0.html.

Make it possible to specify PCP value for outgoing packets on an
ethernet interface.  When PCP is supplied, the tag is appended, VLAN
id set to 0, and PCP is filled by the supplied value.  The code to do
VLAN tag encapsulation is refactored from the if_vlan.c and moved into
if_ethersubr.c.

Drivers might have issues with filtering VID 0 packets on
receive.  This bug should be fixed for each driver.

Reviewed by:	ae (previous version), hselasky, melifaro
Sponsored by:	Mellanox Technologies
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D14702
2018-03-27 15:29:32 +00:00
Andriy Gapon
31260bf042 vfs_donmount: in certain cases try r/o mount if r/w mount fails
If the operation is not an update, if neither r/w nor r/o mode is
explicitly requested, if the error code hints at the possibility of the
media being read-only, and if the fallback is allowed, then we can try
to automatically downgrade to the readonly mode.

This is especially useful for auto-mounting of removable media that
sometimes can happen to be write-protected.

The fallback to r/o is not enabled by default.  It can be requested on a
per-mount basis with a new mount option, 'autoro'.  Or it can be
globally allowed by setting vfs.default_autoro.

Reviewed by:	cem, kib
MFC after:	3 weeks
Relnotes:	yes
Differential Revision: https://reviews.freebsd.org/D13361
2018-03-27 14:31:42 +00:00
Andrey V. Elsukov
b43b604b30 Remove note that fwd tablearg is supported only by IPv4. IPv6 is
supported too.

MFC after:	1 week
2018-03-19 10:50:27 +00:00
Edward Tomasz Napierala
7dc5b4402b Xr crashinfo(8) from savecore(8).
MFC after:	2 weeks
2018-03-17 21:58:41 +00:00
Ed Maste
d8ba45e213 Revert r313780 (UFS_ prefix) 2018-03-17 12:59:55 +00:00
Ed Maste
1e2b9afca9 Prefix UFS symbols with UFS_ to reduce namespace pollution
Followup to r313780.  Also prefix ext2's and nandfs's versions with
EXT2_ and NANDFS_.

Reported by:	kib
Reviewed by:	kib, mckusick
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D9623
2018-03-17 01:48:27 +00:00
Kirill Ponomarev
29c29cbb40 Extend SSID maximum string length to 32 chars to support longer SSID
names.

Approved by:	adrian
Differential Revision:	https://reviews.freebsd.org/D14710
2018-03-16 16:56:56 +00:00
Alexander Motin
011bbaa513 Add some argument checks to be more user-friendly.
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2018-03-13 15:29:13 +00:00
Alexander Motin
635c517ae9 Add nvmecontrol format subcommand.
It allows to change namespace parameters, such as block size, metadata,
protection information, etc. and/or erase the data.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2018-03-13 03:02:09 +00:00
Alexander Motin
01c1be35e0 Print fuses and fna fields in identify data.
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2018-03-12 16:31:25 +00:00
Andrey V. Elsukov
12c080e613 Do not try to reassemble IPv6 fragments in "reass" rule.
ip_reass() expects IPv4 packet and will just corrupt any IPv6 packets
that it gets. Until proper IPv6 fragments handling function will be
implemented, pass IPv6 packets to next rule.

PR:		170604
MFC after:	1 week
2018-03-12 09:40:46 +00:00
Alexander Motin
3fa5467a06 Add new identify data structures fields from NVMe 1.3a.
Some of them are already supported by existing hardware, so reporting
them `nvmecontrol identify` can be useful.
2018-03-11 05:09:02 +00:00
John Baldwin
2365fe5616 Permit sysctl(8) to set an array of numeric values for a single node.
Most sysctl nodes only return a single value, but some nodes return an
array of values (e.g. kern.cp_time).  sysctl(8) understand how to display
the values of a node that returns multiple values (it prints out each
numeric value separated by spaces).  However, until now sysctl(8) has
only been able to set sysctl nodes to a single value.  This change
allows sysctl to accept a new value for a numeric sysctl node that contains
multiple values separated by either spaces or commas.  sysctl(8) parses
this list into an array of values and passes the array as the "new" value
to sysctl(2).

Reviewed by:	rpokala
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D14569
2018-03-09 23:37:19 +00:00
Warner Losh
0b8c33590a Remove decade's old whine about msdos vs msdosfs.
Retain the compatibility silently though.

Reviewed by: cem@, kevans@, emaste@ (and many others in the past)
2018-03-09 21:32:07 +00:00
Conrad Meyer
4e0a8b6105 ipfw(8): Fix endianness for Legacy and Ipv4 table hostname values
The lookup_host() helper subroutine emits a struct in_addr value in network
byte order via caller passed pointer.  However, the table value is expected
to be stored in host byte order.  On little-endian machines, this produced a
reversed endian table value for Legacy or IPv4 table types when the value
was a hostname (instead of a plain IP address).

Fix by using ntohl() on the output 32-bit address.

While here, avoid some aliasing violations by storing the lookup_host()
output in an intermediate object of the correct type.

PR:		226429
Reported by:	bugs.freebsd.org AT mx.zzux.com (also: Tested by)
Security:	ipfw hostname table rules could potentially not act as admin intended
Sponsored by:	Dell EMC Isilon
2018-03-08 17:23:18 +00:00
Warren Block
21b386d516 Clarify and clean up some language, and add an explicit example.
Sponsored by:	iXsystems
Differential Revision:	https://reviews.freebsd.org/D12336
2018-03-02 19:07:32 +00:00
David Bright
3acf1760b7 dhclient violates RFC2131 when sending early DHCPREQUEST message to re-obtain old IP
When dhclient first starts, if an old IP address exists in the
dhclient.leases file, dhclient(8) sends early DHCPREQUEST message(s)
in an attempt to re-obtain the old IP address again. These messages
contain the old IP as a requested-IP-address option in the message
body (correct) but also use the old IP address as the packet's source
IP (incorrect).

RFC2131 sec 4.1 states:

  DHCP messages broadcast by a client prior to that client obtaining
  its IP address must have the source address field in the IP header
  set to 0.

The use of the old IP as the packet's source address is incorrect if
(a) the computer is now on a different network or (b) it is on the
same network, but the old IP has been reallocated to another host.

Fix dhclient to use 0.0.0.0 as the source IP in this circumstance
without removing any existing functionality. Any previously-used old
IP is still requested in the body of an early DHCPREQUEST message.

PR:		199378
Submitted by:	J.R. Oldroyd <fbsd@opal.com>
Reported by:	J.R. Oldroyd <fbsd@opal.com>
Reviewed by:	cem, asomers, vangyzen
MFC after:	1 week
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D14527
2018-02-27 21:59:23 +00:00
Alan Somers
6ef82c0ae2 fix typo in ipfw(8). No functional change.
Submitted by:	zxzharmlesszxz
Pull Request:	https://github.com/freebsd/freebsd/pull/132
2018-02-27 17:12:33 +00:00
Edward Tomasz Napierala
1cde387c83 Improve missing tty handling in init(8). This removes a check that did
nothing - it was checking for ENXIO, which, with devfs, is no longer
returned - and was badly placed anyway, and replaces it with similar
one that works, and is done just before starting getty, instead of being
done when rereading ttys(5).

From the practical point of view, this makes init(8) handle disappearing
terminals (eg /dev/ttyU*) gracefully, without unneccessary getty restarts
and resulting error messages.

Reviewed by:	imp@
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D14307
2018-02-27 10:54:15 +00:00
Eugene Grosbein
0d41f9c9f0 route(8): make it possible to manually delete pinned route
Reported by:	Andreas Longwitz <longwitz@incore.de>
Approved by:	avg (mentor)
MFC after:	1 week
2018-02-24 21:25:56 +00:00
Alan Somers
deeec7728b nvmecontrol: fix build on amd64/clang
Broken by:	329824
Sponsored by:	Spectra Logic Corp
2018-02-22 17:47:16 +00:00
Wojciech Macek
0d787e9b35 NVMe: Add big-endian support
Remove bitfields from defined structures as they are not portable.
Instead use shift and mask macros in the driver and nvmecontrol application.

NVMe is now working on powerpc64 host.

Submitted by:          Michal Stanek <mst@semihalf.com>
Obtained from:         Semihalf
Reviewed by:           imp, wma
Sponsored by:          IBM, QCM Technologies
Differential revision: https://reviews.freebsd.org/D13916
2018-02-22 13:32:31 +00:00
Wojciech Macek
ea1d5fd117 Add bsdlabel and fdisk to powerpc64
Submitted by:          Wojciech Macek <wma@semihalf.org>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies
2018-02-22 12:31:28 +00:00
Alan Somers
79a1d19516 dhclient: raise WARNS to 4
Mostly const-correctness fixes. There were also some variable-shadowing,
unused variable, and a couple of sockaddr type-correctness changes. I also had
trouble with cast-align warnings. I was able to prove that one of them was a
false positive. But ultimately I had to disable the warning program-wide to
deal with the others.

Reviewed by:	cem
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D14460
2018-02-21 21:13:08 +00:00
Kirk McKusick
12487c7243 Fix a read past the end of a buffer in fsck.
To minimize the time spent scanning all of the directories in pass 2
(Check Pathnames), fsck uses a search order based on the location
of their first block. Zero length directories have no first block,
so the array being used to hold the block numbers of directory
inodes was of zero length. Thus a lookup was done past the end of
the array getting at best a random value and at worst a segment
fault.  For zero length directories, this change allocates a one
element block array and initializes it to zero. The effect is that
all zero length directories are handled first in pass 2.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D14163
2018-02-21 20:32:23 +00:00
Ryan Stone
9ec35e3cb4 Fix route manpage to show correct flush syntax
The current route(8) manpage shows that "flush" is an argument to
the optional -n flag, rather than a separate subcommand.  Correct
this to properly show flush as a route subcommand.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Reviewed by: rgrimes
Differential Revision: https://reviews.freebsd.org/D14401
2018-02-21 19:13:27 +00:00
Ryan Stone
b3b6ff23e7 Allow route change requests to not specify the gateway.
Only require a gateway to be specified on a route add request.  On
a route change request that does not specify the gateway, the
gateway will remain the same.  This allows changing other route
parameters without having to re-specifying the gateway, like in
"route change 10.0.0.0/8 -mtu 9000".

Update the route(8) manpage to explicitly call out this usage
as being supported.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Reviewed By: eugen (rtsock.c change), rgrimes
Differential Revision: https://reviews.freebsd.org/D14291
2018-02-21 19:13:23 +00:00
Warner Losh
c798d98e75 More verbose output. 2018-02-20 05:35:00 +00:00
Warner Losh
bbd4852a9b Print more info for -v runs and temp hack for usb vs uhub
Despite best efforts to regularize, there's a few tables in the system
that still report they are for bus usb when they are really for bus
uhub (where usb devices attach). Add a temporary workaround for this
until these places have been eliminated (likely my fault).

Second, when running verbose, describe what we're doing when
searching. This output can be quite long, but says exactly what's
going on (this output is to stdout, so it's useless for scripting).
2018-02-18 23:16:16 +00:00
Hans Petter Selasky
201c73815f Fix USB driver matching in devmatch(8).
Multiple drivers can match on the same USB device and the order of loading
decides which driver gets the device. Use the supplied mask value as an
indication of priority, so that vendor specific device drivers are loaded
before more generic ones.

Sponsored by:	Mellanox Technologies
2018-02-17 14:34:47 +00:00
Warner Losh
3fa2c0489b Implement --hints to read hints file directly
In testing, it's often useful to copy a few files into a directory and
kldxref them to ensure that particular cases are handled correctly.
Add --hints (-h) to facilitate this testing and enable future
automated testing.

Sponsored by: Netflix
2018-02-17 06:57:43 +00:00
Warner Losh
d38a8a7aa5 Add option to parse NOMATCH event and suggest modules to load
Add --nomatch/-p to search for individual drivers based on a NOMATCH
event from devd.

Submitted by: hps (earlier version)
Sponsored by: Netflix
2018-02-17 06:57:34 +00:00
Warner Losh
5e0195c8f5 Tweak the 'I' flagged value
'I' was omitting 'zero' values. This is not quite correct, and was put
in as a hack but not documented. Remove it. If we find what the hack
was really needed for, we'll either fix the need for it, or invent a
new flagged value type.

Submitted by: hps@
Sponsored by: Netflix
2018-02-17 06:57:30 +00:00
Warner Losh
b9c40202d8 Implement 'T' field matching.
Implement 'T' field matching. This is needed to prevent false
positives. However, it's not general enough. It only handles one field
and there's a ton of edge cases even with that it likely wouldn't
handle. To do it more generally and also eliminate a lot of the
hackiness that's in this program now, we'd need to creating
directories for lookups ala awk, pearl, python, etc. It appears to be
sufficient, though, to get my keyboard loaded on boot.

Sponsored by: Netflix
2018-02-17 06:57:25 +00:00
Warner Losh
a164a319eb Warn when we encounter unknown PNP field specifiers.
The 'T' field went unimplemented for months due to a lack of warning.
Add a warnings to detect mistakes sooner.

Sponsored by: Netflix
2018-02-17 06:57:12 +00:00
Mike Silbersack
b761400b51 Prevent savecore from reading bounds from the current directory.
Rev 244218 removed the requirement that you provide a dump
directory when checking if there is a coredump ready to be written.
That had the side-effect of causing the bounds file to be read
from the current working directory instead of the dump directory.
As the bounds file is irrelevant when just checking, the simplest
fix is to not read the bounds file when checking.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D14383
2018-02-16 06:51:39 +00:00
Eitan Adler
dacbef689d devd: don't pass &fds in useless parameters to select(2)
select(2) should be declared as restrict. In addition the only fd in
the fdset is open O_RDONLY, and it's not a socket that can provide OOB
notifications,

Reviewed by:	ian, imp, vangyzen
2018-02-15 03:22:53 +00:00
Mark Johnston
6026dcd7ca Add support for zstd-compressed user and kernel core dumps.
This works similarly to the existing gzip compression support, but
zstd is typically faster and gives better compression ratios.

Support for this functionality must be configured by adding ZSTDIO to
one's kernel configuration file. dumpon(8)'s new -Z option is used to
configure zstd compression for kernel dumps. savecore(8) now recognizes
and saves zstd-compressed kernel dumps with a .zst extension.

Submitted by:	cem (original version)
Relnotes:	yes
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D13101,
			https://reviews.freebsd.org/D13633
2018-02-13 19:28:02 +00:00
Nick Hibma
9ea81ab56a DSCP values passed to setdscp need to be lowercase.
See definition of f_ipdscp values. They are compared against using bcmp
which is case sensitive.

MFC after:	1 week
2018-02-13 10:11:39 +00:00
Conrad Meyer
487340b004 devmatch.8: Link to MODULE_PNP_INFO(9)
Sponsored by:	Dell EMC Isilon
2018-02-12 22:43:47 +00:00
Warner Losh
590682b6e6 Move devmatch to sbin from usr/sbin.
Since we want to use devmatch in context before a split /,/usr system
has mounted /usr, move devmatch to /sbin.

Sponsored by: Netflix
2018-02-12 14:44:21 +00:00
Conrad Meyer
b42712a8b7 Add GUID and alias for Apple APFS partition
PR:		225813
Submitted by:	James Wright <james.wright AT jigsawdezign.com>
2018-02-11 06:57:20 +00:00
Kirk McKusick
31461aa2f1 Include files missed in 329051. 2018-02-08 23:14:24 +00:00
Kirk McKusick
068beacf21 The goal of this change is to prevent accidental foot shooting by
folks running filesystems created on check-hash enabled kernels
(which I will call "new") on a non-check-hash enabled kernels (which
I will call "old). The idea here is to detect when a filesystem is
run on an old kernel and flag the filesystem so that when it gets
moved back to a new kernel, it will not start getting a slew of
check-hash errors.

Back when the UFS version 2 filesystem was created, it added a file
flag FS_INDEXDIRS that was to be set on any filesystem that kept
some sort of on-disk indexing for directories. The idea was precisely
to solve the issue we have today. Specifically that a newer kernel
that supported indexing would be able to tell that the filesystem
had been run on an older non-indexing kernel and that the indexes
should not be used until they had been rebuilt. Since we have never
implemented on-disk directory indicies, the FS_INDEXDIRS flag is
cleared every time any UFS version 2 filesystem ever created is
mounted for writing.

This commit repurposes the FS_INDEXDIRS flag as the FS_METACKHASH
flag. Thus, the FS_METACKHASH is definitively known to have always
been cleared. The FS_INDEXDIRS flag has been moved to a new block
of flags that will always be cleared starting with this commit
(until they get used to implement some future feature which needs
to detect that the filesystem was mounted on a kernel that predates
the new feature).

If a filesystem with check-hashes enabled is mounted on an old
kernel the FS_METACKHASH flag is cleared. When that filesystem is
mounted on a new kernel it will see that the FS_METACKHASH has been
cleared and clears all of the fs_metackhash flags. To get them
re-enabled the user must run fsck (in interactive mode without the
-y flag) which will ask for each supported check hash whether it
should be rebuilt and enabled. When fsck is run in its default preen
mode, it will just ignore the check hashes so they will remain
disabled.

The kernel has always disabled any check hash functions that it
does not support, so as more types of check hashes are added, we
will get a non-surprising result. Specifically if filesystems get
moved to kernels supporting fewer of the check hashes, those that
are not supported will be disabled. If the filesystem is moved back
to a kernel with more of the check-hashes available and fsck is run
interactively to rebuild them, then their checking will resume.
Otherwise just the smaller subset will be checked.

A side effect of this commit is that filesystems running with
cylinder-group check hashes will stop having them checked until
fsck is run to re-enable them (since none of them currently have
the FS_METACKHASH flag set). So, if you want check hashes enabled
on your filesystems after booting a kernel with these changes, you
need to run fsck to enable them. Any newly created filesystems will
have check hashes enabled. If in doubt as to whether you have check
hashes emabled, run dumpfs and look at the list of enabled flags
at the end of the superblock details.
2018-02-08 23:06:58 +00:00
Adrian Chadd
93e98f5f14 [etherswitchcfg] print the switch MAC address if provided. 2018-02-06 08:35:09 +00:00
Alan Somers
f5b4099e6b geom: don't write stack garbage in disk labels
Most consumers of g_metadata_store were passing in partially unallocated
memory, resulting in stack garbage being written to disk labels. Fix them by
zeroing the memory first.

gvirstor repeated the same mistake, but in the kernel.

Also, glabel's label contained a fixed-size string that wasn't
initialized to zero.

PR:		222077
Reported by:	Maxim Khitrov <max@mxcrypt.com>
Reviewed by:	cem
MFC after:	3 weeks
X-MFC-With:	323314
X-MFC-With:	323338
Differential Revision:	https://reviews.freebsd.org/D14164
2018-02-04 14:49:55 +00:00
Kirk McKusick
8bd0b5ce0a Check and report error returns from sbput(3) calls.
Convert to using cgput(3) for writing cylinder groups.
Check and report error returns from cgput(3).

Submitted by: Bruce Evans <bde@freebsd.org>
2018-02-02 23:26:52 +00:00
Adrian Chadd
138952cfc7 [etherswitchcfg] add atu flush and atu dump commands.
Extend the argc/argv handling to include variable length commands (like flush all,
flush port X).
2018-02-02 22:08:35 +00:00
Mariusz Zaborski
3169840599 Use daemonfd(3) in the dhclient(8).
Reviewed by:	brooks@
Differential Revision:	https://reviews.freebsd.org/D13603
2018-02-02 18:11:56 +00:00
Kirk McKusick
26772fefc1 Use sbput(3) rather than sbwrite(3) to ensure that the updated copy of
the superblock gets written.

Reported by: Mark Johnston <markj@FreeBSD.org>
2018-02-02 00:07:38 +00:00
Mariusz Zaborski
8586c17750 Bump date after r328535.
Submitted by:	def@
2018-01-29 09:27:32 +00:00
Konrad Witaszczyk
02670b9048 Fix misspelling of encryptedcore.
PR:		223991
Submitted by:	Trond Endrestol <Trond.Endrestol@ximalas.info>
Approved by:	pjd (mentor)
2018-01-29 09:21:08 +00:00
Pedro F. Giffuni
e2d84d5adc pfctl(8): Fix two wrong conditions.
Caught by gcc80's -Wtautological-compare option.

MFC after:	5 days
Approved by:	kp
Obtained from:	DragonFlyBSD (git e3cdbf6c)
Differential Revision:	https://reviews.freebsd.org/D14083
2018-01-27 22:57:01 +00:00
Eitan Adler
7548968ac2 devd: readd virtual
- my C++ knowledge is old and rusty. re-add virtual
2018-01-26 05:03:37 +00:00
Eitan Adler
510a8c88f0 devd: minor nits
- mark usage as noreturn
- config does not need a virtual destructor
2018-01-26 04:40:41 +00:00
Kirk McKusick
dffce2150e Refactoring of reading and writing of the UFS/FFS superblock.
Specifically reading is done if ffs_sbget() and writing is done
in ffs_sbput(). These functions are exported to libufs via the
sbget() and sbput() functions which then used in the various
filesystem utilities. This work is in preparation for adding
subperblock check hashes.

No functional change intended.

Reviewed by: kib
2018-01-26 00:58:32 +00:00
Li-Wen Hsu
af89fcf725 Fix architectures where pointer and u_int have different sizes
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D14049
2018-01-25 08:36:19 +00:00
Kirk McKusick
a6bbdf81b5 More throughly integrate libufs into fsck_ffs by using its cgput()
routine to write out the cylinder groups rather than recreating the
calculation of the cylinder-group check hash in fsck_ffs.

No functional change intended.
2018-01-24 23:57:40 +00:00
Scott Long
19641ce893 Revert ABI breakage to CAM that came in with MMC/SD support in r320844.
Make it possible to retrieve mmc parameters via the XPT_GET_ADVINFO
call instead.  Convert camcontrol to the new scheme.

Reviewed by:	imp. kibab
Sponsored by:	Netflix
Differential Revision:	D13868
2018-01-19 15:32:27 +00:00
Alan Somers
6f7f85e0e1 gnop(8): add the ability to set a nop provider's physical path
While I'm here, expand the existing tests a bit.

MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D13579
2018-01-18 05:57:10 +00:00
Kirk McKusick
72f854ce8f Correct fsck journal-recovery code to update a cylinder-group
check-hash after making changes to the cylinder group. The problem
was that the journal-recovery code was calling the libufs bwrite()
function instead of the cgput() function. The cgput() function updates
the cylinder-group check-hash before writing the cylinder group.

This change required the additions of the cgget() and cgput() functions
to the libufs API to avoid a gratuitous bcopy of every cylinder group
to be read or written. These new functions have been added to the
libufs manual pages. This was the first opportunity that I have had
to use and document the use of the EDOOFUS error code.

Reviewed by: kib
Reported by: emaste and others
2018-01-17 17:58:24 +00:00
Dimitry Andric
2d3c3a5038 Fix buildworld after r328075, by also renaming cgget to cglookup in
fsdb.

Reported by:	ohartmann@walstatt.org,david@catwhisker.org
Pointy hat to:	mckusick
2018-01-17 13:19:37 +00:00
Kirk McKusick
957fc241ec Rename cgget => cglookup to clear name space for new libufs function cgget.
No functional change.
2018-01-17 06:31:21 +00:00
David Bright
469759f8e4 Exit fsck_ffs with non-zero status when file system is not repaired.
When the fsck_ffs program cannot fully repair a file system, it will
output the message PLEASE RERUN FSCK. However, it does not exit with a
non-zero status in this case (contradicting the man page claim that it
"exits with 0 on success, and >0 if an error occurs."  The fsck
rc-script (when running "fsck -y") tests the status from fsck (which
passes along the exit status from fsck_ffs) and issues a "stop_boot"
if the status fails. However, this is not effective since fsck_ffs can
return zero even on (some) errors. Effectively, it is left to a later
step in the boot process when the file systems are mounted to detect
the still-unclean file system and stop the boot.

This change modifies fsck_ffs so that when it cannot fully repair the
file system and issues the PLEASE RERUN FSCK message it also exits
with a non-zero status.

While here, the fsck_ffs man page has also been updated to document
the failing exit status codes used by fsck_ffs. Previously, only exit
status 7 was documented. Some of these exit statuses are tested for in
the fsck rc-script, so they are clearly depended upon and deserve
documentation.

Reviewed by:	mckusick, vangyzen, jilles (manpages)
MFC after:	1 week
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D13862
2018-01-15 19:25:11 +00:00
Warner Losh
3922493a21 Report CG checksum mismatches. These errors are non-fatal. The
previous behavior is preserved (the CG checksum is fixed). We're just
noisy about it now.

Reviewed by: kirk@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13884
2018-01-14 16:55:14 +00:00
Alan Somers
066ebd56c1 dhclient(8): add missing include
stdbool is technically needed, though we can get away without it due to
header pollution.

MFC after:	3 days
2018-01-12 04:26:40 +00:00
Scott Long
f2592b12e9 Refactor code related to 'camcontrol devlist'
Obtained from:	Netflix
2018-01-10 05:52:24 +00:00
Scott Long
c371df4f47 Implement the ability to query NVME for its controller data so that it will
be shown when issueing the 'camcontrol devlist' command.

Obtained from:	Netflix
2018-01-10 05:29:02 +00:00
Eitan Adler
d85e65cb35 ldconfig(8): use .Nm instead of 'ldconfig' 2018-01-09 06:51:41 +00:00
Eitan Adler
f0c0c1daec ldconfig(8): clarify language for files
The previous language did not make it clear that 'Files' are
the files specified above. Clarify it.

Reported by:	dana <dana@dana.is>
Reviewed by:	dana <dana@dana.is>
MFC After:	1 week
2018-01-07 05:38:53 +00:00
Warner Losh
783d8ed04e Only call close if fd and fd1 are not -1.
CID: 1384018, 1384017
2018-01-05 05:34:14 +00:00
Eitan Adler
7d3df1907a shutdown: Fix r327476 by adding init
Initialize maybe_today. While here sort.

PR:				32411
Additionally reported by:	rgrimes, ian
2018-01-02 09:02:42 +00:00
Eitan Adler
cb1101afd7 shutdown: Assume absolute time is in the future
The original bug describes it best:

When an absolute time is specified to shutdown, the program's
behavior depends on whether that time has passed during the
current calendar day.  POLA would suggest that for shutdown,
whose time argument is always supposed to be in the future,
absolute times specified without a specific date should refer
to the next occurrence of that time, rather than erroring out
if that time has already passed during the current day.

PR:		32411
Submitted by:	wollman@khavrinen.lcs.mit.edu
Submitted on:	2001-11-30 20:30:01 UTC
Reviewed by:	asmodai (at time of bug submission)
2018-01-01 22:33:57 +00:00
Bryan Venteicher
33e0d8f057 Add support for IPv6 scoped addresses to vxlan
MFC after:	2 weeks
2017-12-30 04:03:53 +00:00
Pedro F. Giffuni
02547822f3 ccdconfig: Move VCS tags to be more consistent with our style.
Update a now-bogus SPDX tag while here.
2017-12-30 00:26:42 +00:00
Pedro F. Giffuni
9a827f1751 ccdconfig: Update licensing terms to match NetBSD.
The code originated in NetBSD which has since removed Clauses 3 and 4.

Approved by:	phk (concerning his own copyright)
Obtained from:	NetBSD (CVS ccdconfig.c 1.47, ccdconfig.8 1.24)
2017-12-30 00:22:47 +00:00
Xin LI
5a8ad265c9 The fix in r327273 turns a memory leak into freeing wild pointer.
Fix this by freeing only the initialized pointer.
2017-12-29 06:22:05 +00:00
Warner Losh
5539da566e When bind fails, make sure we closed the socket we tried to bind the
address to.

CID: 978244
2017-12-28 05:34:24 +00:00
Warner Losh
cd4461513c Close fd and fd1 before returning now that we're done with them.
CID: 978234, 978236
2017-12-28 05:34:19 +00:00
Warner Losh
0bebba31d3 Plug memory leak by freeing wantedblk{32,64}.
CID: 273655, 273656
2017-12-28 05:34:08 +00:00
Warner Losh
076950009f Free path before returnig.
CID: 977827
2017-12-28 05:33:54 +00:00
Eitan Adler
837fe32558 Fix a few more speelling errors
Reviewed by:		bjk
Reviewed by:		jilles (incl formal "accept")
Differential Revision:	https://reviews.freebsd.org/D13650
2017-12-28 01:31:28 +00:00
Kirk McKusick
a770ae06ed In preparation for converting to libufs to read the superblock,
change conflicting function names:

	getino => getinode
	bread => blkread

No functional change.
2017-12-27 22:18:56 +00:00
Pedro F. Giffuni
3a7c4a1c83 ccdconfig: Update licensing terms.
The code originate in NetBSD and there are the copyright notes have been
assigned to the NetBSD Foundation. Update the files up to the point where
we started diverging.

Further relaxation of the licensing terms are possible after we
check the NetBSD updates, and contact the local authors.

In the case of ccdconfig.8 this reinstates the 3rd clause but since the
code is not directly from Berkeley, the change was bogus.

Obtained from:	NetBSD
2017-12-27 20:09:50 +00:00
Eitan Adler
9914452050 other: Fix several typos and minor errors
- duplicate words
- typos
- references to old versions of FreeBSD

Reviewed by:	imp, benno
2017-12-27 03:23:58 +00:00
Andrey V. Elsukov
c690824a91 Fix rule number truncation, use uint16_t type to specify rulenum.
PR:		224555
MFC after:	1 week
2017-12-24 01:55:12 +00:00
Pedro F. Giffuni
33d72c30f1 Revert r327005 - SPDX tags for license similar to BSD-2-Clause.
After consultation with SPDX experts and their matching guidelines[1],
the licensing doesn't exactly match the BSD-2-Clause. It yet remains to be
determined if they are equivalent or if there is a recognized license that
matches but it is safer to just revert the tags.

Let this also be a reminder that on FreeBSD, SPDX tags are only advisory
and have no legal value (but IANAL).

Pointyhat to:	pfg
Thanks to:	Rodney Grimes, Gary O'Neall

[1] https://spdx.org/spdx-license-list/matching-guidelines
2017-12-20 20:25:28 +00:00
Warner Losh
8c0fa2cc56 Flesh out the reason for the need for tmpfs a little.
Sponsored by: Netflix
2017-12-20 16:02:11 +00:00
Brad Davis
71688f3b71 Save others some forehead damange by noting that -r require tmpfs.
Reviewed by:	bapt
2017-12-20 15:21:29 +00:00
Pedro F. Giffuni
d17aef79bb SPDX: These are fundamentally BSD-2-Clause.
They just omit the introductory line and numbering.
2017-12-19 22:40:16 +00:00
Alan Somers
afe6f8358e dhclient(8): raise WARNS to 3
Mostly had to fix a lot of signed/unsigned comparison warnings

MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2017-12-14 15:41:32 +00:00
Alan Somers
5f28c51db6 dhclient(8): Don't shift through the sign bit of a signed int
PR:		208007
Submitted by:	Michael McConville <mmcco@mykolab.com>
MFC after:	3 weeks
2017-12-13 20:48:20 +00:00
Edward Tomasz Napierala
b8ea5b468b Tone down the description for the growfs "-y" flag.
MFC after:	2 weeks
2017-12-13 14:08:33 +00:00
Bryan Venteicher
f53d97231b Use consistent name for the vxlan VNI parameter name and provide shorthand
Submitted by:	hrs
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D2868
2017-12-07 04:55:31 +00:00
Eric Joyner
b0f3e715fa ifconfig(8): Display extended compliance code string for SFP transceivers
- Updates tables in affected files with new entries from newer spec
revisions of SFF-8472, SFF-8024, and SFF-8636

- Change ifconfig to read and display the extended compliance code for
SFP media if the extended compliance code is not 0. This was being displayed
for QSFP transceivers only, but SFP28 media uses this to report 25G
capability.

Reviewed by:	melifaro, sbruno
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D13286
2017-12-05 18:42:07 +00:00
Mark Johnston
3384cf0b45 Document gmirror sysctls.
MFC after:	2 weeks
2017-11-30 20:37:12 +00:00
Pedro F. Giffuni
64de3fdd58 SPDX: use the Beerware identifier. 2017-11-30 20:33:45 +00:00
Xin LI
aa031ef4a3 Prevent OOB access on corrupted msdos directories.
Submitted by:	Veo Zhang <veo live com>
MFC after:	2 weeks
2017-11-30 08:28:17 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

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

No functional change intended.
2017-11-27 15:37:16 +00:00
Michael Tuexen
665c8a2ee5 Add to ipfw support for sending an SCTP packet containing an ABORT chunk.
This is similar to the TCP case. where a TCP RST segment can be sent.

There is one limitation: When sending an ABORT in response to an incoming
packet, it should be tested if there is no ABORT chunk in the received
packet. Currently, it is only checked if the first chunk is an ABORT
chunk to avoid parsing the whole packet, which could result in a DOS attack.

Thanks to Timo Voelker for helping me to test this patch.
Reviewed by: bcr@ (man page part), ae@ (generic, non-SCTP part)
Differential Revision:	https://reviews.freebsd.org/D13239
2017-11-26 18:19:01 +00:00
Konstantin Belousov
41c0f8d354 Improve sysctl(8) pretty printing of some structures.
S_vmtotal:
Use unsigned format to print unsigned memory counters from struct
vmtotal.
Remove unneeded cast, style locals declarations.

S_efi_map:
Make printing of the memory regions descriptions less MD by
using uintmax_t formats.

Noted by and discussed with:	bde
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-11-26 10:02:43 +00:00
Alan Somers
8d68f9d430 Print ZAC device type in "camcontrol identify" output
ZAC (Zoned-device ATA Command set) is the standard for addressing SMR
(shingled magnetic recording) devices over SATA.  Drives indicate their
support for ZAC in their IDENTIFY block. Print whether and how a drive
supports ZAC in the output of "camcontrol identify".

Reviewed by:	ken, imp
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D13171
2017-11-20 21:56:25 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

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

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Pedro F. Giffuni
df57947f08 spdx: initial adoption of licensing ID tags.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes:	yes
Differential Revision:	https://reviews.freebsd.org/D13133
2017-11-18 14:26:50 +00:00
Scott Long
7841fefb62 Rename P_OSREL_CK_CLYGRP to P_OSREL_CK_CYLGRP 2017-11-17 13:12:20 +00:00
Warner Losh
a3c15a4445 Only try to enable CK_CLYGRP if we're running on kernel newer than
1200046, the first version that supports this feature. If we set it,
then use an old kernel, we'll break the 'contract' of having
checksummed cylinder groups this flag signifies. To avoid creating
something with an inconsistent state, don't turn the flag on in these
cases. The first full fsck with a new kernel will turn this on.

Spnsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13114
2017-11-16 21:28:14 +00:00
Ed Maste
4acb68a8a5 newfs: warn if newer than kernel
Creating a UFS filesystem with a newfs newer than the running kernel,
and then mounting that filesystem, can lead to interesting failures.

Add a safety belt to explicitly warn when newfs is newer than the
running kernel.

Reviewed by:	gjb, jhb, mckusick
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12765
2017-11-15 18:40:40 +00:00
Kristof Provost
58c8430a32 pfctl: teach route-to to deal with interfaces with multiple addresses
The route_host parsing code set the interface name, but only for the first
node_host in the list. If that one happened to be the inet6 address and the
rule wanted an inet address it'd get removed by remove_invalid_hosts() later
on, and we'd have no interface name.

We must set the interface name for all node_host entries in the list, not just
the first one.

PR:		223208
MFC after:	2 weeks
2017-11-15 12:27:02 +00:00
Mariusz Zaborski
6789a8b559 dhclient(8) should not close stdio using daemon(3) function.
dhclient(8) is chrooted so opening /dev/null always will fail.
In capability world this is also annoying because we getting error that
open(2) is not permitted in Capsicum. dhclient(8) is closing stdio by
precaching fd to /dev/null before chroot.
This is done few lines below daemon(3) function so let's not try to do that
in daemon(3) function.

Reviewed by:	cem@
Differential Revision:	https://reviews.freebsd.org/D12826
2017-11-12 08:54:23 +00:00
Mariusz Zaborski
cb003dd918 Use syslog service in dhclient(8).
dhclient(8) is failing during boot to connect to the syslog service, because
syslog daemon is started after dhclient(8). This can be reproduced by stooping
syslog daemon and ktrace the dhclient or use kern.trap_enotcap sysctl and boot
the machine. Using the Casper syslog service fix the problem.

Reviewed by:	bapt@
Differential Revision:	https://reviews.freebsd.org/D12825
2017-11-12 08:42:43 +00:00
Mariusz Zaborski
8751b03b19 We return a pointer when we are using cap_init() or cap_service_open()
function, so check if cap_chanel_t is NULL is not enough.
Casper with a normal libc will still fail in capability mote so let's not
enter capability mode without casper support when we need to resolve DNS.

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D12823
2017-11-12 07:18:10 +00:00
Bryan Drewery
ae9f7248f9 rescue ipf: Remove hacks and link in libipf directly.
Sponsored by:	Dell EMC Isilon
2017-11-10 07:52:58 +00:00
Konstantin Belousov
3cf8254f1e Add a place for a driver to report rx timestamps in nanoseconds from
boot for the received packets.

The rcv_tstmp field overlaps the place of Ln header length indicators,
not used by received packets.  The basic pkthdr rearrangement change
in sys/mbuf.h was provided by gallatin.

There are two accompanying M_ flags: M_TSTMP means that there is the
timestamp (and it was generated by hardware).

Another flag M_TSTMP_HPREC indicates that the timestamp is
high-precision.  Practically M_TSTMP_HPREC means that hardware
provided additional precision comparing with the stamps when the flag
is not set.  E.g., for ConnectX all packets are stamped by hardware
when PCIe transaction to write out the completion descriptor is
performed, but PTP packet are stamped on port.  For Intel cards, when
PTP assist is enabled, only PTP packets are stamped in the limited
number of registers, so if Intel cards ever start support this
mechanism, they would always set M_TSTMP | M_TSTMP_HPREC if hardware
timestamp is present for the given packet.

Add IFCAP_HWRXTSTMP interface capability to indicate the support for
hardware rx timestamping, and ifconfig(8) command to toggle it.

Based on the patch by:	gallatin
Reviewed by:	gallatin (previous version), hselasky
Sponsored by:	Mellanox Technologies
MFC after:	2 weeks (? mbuf KBI issue)
X-Differential revision:	https://reviews.freebsd.org/D12638
2017-11-07 09:29:14 +00:00
Konstantin Belousov
93b09f581a Remove badsect(8).
Failure modes of the modern (that is, produced in the last 25 years)
hard drives and SSDs made the utility outdated.  Since the kernel
interface to support it was removed in r324853, cut the userspace
remnants as well.

Discussed with:	bde (who does not like the removal)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2017-11-05 22:00:54 +00:00
Warner Losh
25fd081525 Add -c to the usage statements.
Submitted by: Maxim Konovalov
2017-10-31 03:39:36 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Bryan Drewery
3806950135 DIRDEPS_BUILD: Connect new directories.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:04:07 +00:00
Edward Tomasz Napierala
be8f91d3d0 Use MAP_PRIVATE instead of obsolete MAP_COPY. No functional changes.
MFC after:	2 weeks
2017-10-30 08:56:04 +00:00
Mariusz Zaborski
0b9d37d25f Simplify ping sandbox.
We don't need to check if casper is present, this is done in the library itself.

Reviewed by:	emaste, cem, ed
Differential Revision:	https://reviews.freebsd.org/D8754
2017-10-28 19:39:22 +00:00
Warner Losh
35c1d16e3e Implement power cycle in init.
If SIGWINCH is received, then halt with power cycle.

Sponsored by: Netflix
2017-10-25 15:30:40 +00:00
Warner Losh
7d7d9013f1 Add power cycle support to reboot/halt as -c.
When -c is specified, the system will be power cycled if the
underlying hardware supports it. Otherwise the system will be halted
or rebooted depending on which command was used.

Sponsored by: Netflix
2017-10-25 15:30:35 +00:00
Warner Losh
e60baa7252 Add power cycle support (-c) to shutdown.
Sponsored by: Netflix
2017-10-25 15:30:30 +00:00
Warner Losh
24e99dabf7 Report only the valid slots in the firmware log page.
Printing the entire log page is causing confusion over available
slots. Report only those slots that are valid. In the case where the
firmware download isn't supported, assume that only the first slot is
valid (I have no hardware to test this assumption though)

Sponsored by: Netflix
2017-10-25 15:26:03 +00:00
Warner Losh
8ce85adf7d Add nvme_controller_data argument to all print functions.
It's desirable to access controler data to inform printing log pages
(such as limiting the printing to valid ranges).

Sponsored by: Netflix
2017-10-25 15:25:55 +00:00
Mark Johnston
64a16434d8 Add support for compressed kernel dumps.
When using a kernel built with the GZIO config option, dumpon -z can be
used to configure gzip compression using the in-kernel copy of zlib.
This is useful on systems with large amounts of RAM, which require a
correspondingly large dump device. Recovery of compressed dumps is also
faster since fewer bytes need to be copied from the dump device.

Because we have no way of knowing the final size of a compressed dump
until it is written, the kernel will always attempt to dump when
compression is configured, regardless of the dump device size. If the
dump is aborted because we run out of space, an error is reported on
the console.

savecore(8) is modified to handle compressed dumps and save them to
vmcore.<index>.gz, as it does when given the -z option.

A new rc.conf variable, dumpon_flags, is added. Its value is added to
the boot-time dumpon(8) invocation that occurs when a dump device is
configured in rc.conf.

Reviewed by:	cem (earlier version)
Discussed with:	def, rgrimes
Relnotes:	yes
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D11723
2017-10-25 00:51:00 +00:00
Andrey V. Elsukov
092f8ba32f Return 'errno' value from the table_do_modify_record(), it is expected
by table_modify_record().

This makes quiet operations with tables really quiet.

PR:		222953
MFC after:	1 week
2017-10-13 11:01:33 +00:00
Ed Maste
4887fa3635 growfs: ANSIfy cgckhash()
The build was broken on GCC-using architectures with:

growfs.c: In function 'cgckhash':
growfs.c:1753: warning: old-style function definition

Sponsored by:	The FreeBSD Foundation
2017-10-10 21:16:07 +00:00
Kirk McKusick
3abf5d76f2 Growfs got missed in r323923 that added a check hash to cylinder groups.
This makes the needed changes to add/update cylinder group check hashes
when a filesystem is expanded.

Reported by: kib and Warner Losh (imp)
Reviewed by: kib
Tested by: Peter Holm (pho)
2017-10-10 16:17:03 +00:00
Enji Cooper
5b347b28cd Check the exit code from fsck_ffs instead of relying on MODIFIED being in the output
^/head@r323923 changed when MODIFIED is printed at exit. It's better to follow the
documented way of determining whether or not a filesystem is clean per fsck_ffs, i.e.,
ensure that the exit code is either 0 or 7.

The pass/fail determination is brittle prior to this commit, and ^/head@r323923 made
the issue apparent -- thus this needs to be fixed independent of ^/head@r323923.

PR:		222780
MFC after:	1 week
MFC with:	r323923
Reported by:	Jenkins
2017-10-10 05:58:33 +00:00
Kirk McKusick
918820682e Do not report the filesystem as modified when the only change is to
update the timestamp in the superblock.

Reported by:	Peter Holm
MFC after:	1 week
2017-10-09 22:19:58 +00:00
Marcel Moolenaar
b5dc98c049 Fix alignment of 'last' in autofill.
'last' is the sector number of the last usable sector. Sector
numbers start with 0. As such, 'last' is always 1 less than
the count of sectors and aligning 'last' down as-is means that
the number of free sectors is pessimized by 'alignment - 1' if
the number of usable sectors was already a multiple of the
alignment. Consequently, gpart(8) failed to create a partition
when the alignment and size were such that it would extend to
the end of the disk.
2017-10-06 16:38:00 +00:00
Conrad Meyer
2c9a33f557 Correct sense of crypt(3) NULL checks in init(8) and lock(1)
In r231994, an attempt was made to fix crypt(3) failure returns (NULL).
However, instead of treating crypt(3) failure as authentication failure,
some of the changes treated crypt(3) failure as authentication success.
This is wrong.

r324225 fixed this for ppp, which also inspired this review.  The other
changes in the 231994 revision were audited for correctness and look ok.

Reviewed by:	jhb
Security:	yes
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12571
2017-10-03 00:53:11 +00:00
Michael Tuexen
ab1d48801b Whitespace changes: Remove leading spaces followed by a tab. 2017-10-02 20:02:25 +00:00
Michael Tuexen
945906384d Fix a bug which avoided that rules for matching port numbers for SCTP
packets where actually matched.
While there, make clean in the man-page that SCTP port numbers are
supported in rules.

MFC after:	1 month
2017-10-02 18:25:30 +00:00
Andreas Tobler
f3b5058c8e Initialize mdsize to make gcc happy again. This fixes buildworld on powerpc.
Reviewed by:	ian@
2017-09-30 17:51:10 +00:00
Ian Lepore
50e3590c44 Enhance mdmfs(8) to work with tmpfs(5).
Existing scripts and associated config such as rc.initdiskless, rc.d/var,
and others, use mdmfs to create memory filesystems. That program accepts a
size argument which allows SI suffixes and treats an unsuffixed number as a
count of 512 byte sectors. That makes it difficult to convert existing
scripts to use tmpfs instead of mdmfs, because tmpfs treats unsuffixed
numbers as a count of bytes. The script logic to deal with existing user
config that might include suffixed and unsuffixed numbers is... unpleasant.

Also, there is no g'tee that tmpfs will be available. It is sometimes
configured out of small-resource embedded systems to save memory and flash
storage space.

These changes enhance mdmfs(8) so that it accepts two new values for the
'md-device' arg: 'tmpfs' and 'auto'. With tmpfs, the program always uses
tmpfs(5) (and fails if it's not available). With 'auto' the program prefers
tmpfs, but falls back to using md(4) if tmpfs isn't available. It also
handles the -s <size> argument so that the mdconfig interpetation of
unsuffixed numbers applies when tmpfs is used as well, so that existing user
config keeps working after a switch to tmpfs.

A new rc setting, mfs_type, is added to etc/defaults/rc.conf to let users
force the use of tmpfs or md; the default value is "auto".

Differential Revision:	https://reviews.freebsd.org/D12301
2017-09-29 22:13:26 +00:00
Kirk McKusick
75e3597abb Continuing efforts to provide hardening of FFS, this change adds a
check hash to cylinder groups. If a check hash fails when a cylinder
group is read, no further allocations are attempted in that cylinder
group until it has been fixed by fsck. This avoids a class of
filesystem panics related to corrupted cylinder group maps. The
hash is done using crc32c.

Check hases are added only to UFS2 and not to UFS1 as UFS1 is primarily
used in embedded systems with small memories and low-powered processors
which need as light-weight a filesystem as possible.

Specifics of the changes:

sys/sys/buf.h:
    Add BX_FSPRIV to reserve a set of eight b_xflags that may be used
    by individual filesystems for their own purpose. Their specific
    definitions are found in the header files for each filesystem
    that uses them. Also add fields to struct buf as noted below.

sys/kern/vfs_bio.c:
    It is only necessary to compute a check hash for a cylinder
    group when it is actually read from disk. When calling bread,
    you do not know whether the buffer was found in the cache or
    read. So a new flag (GB_CKHASH) and a pointer to a function to
    perform the hash has been added to breadn_flags to say that the
    function should be called to calculate a hash if the data has
    been read. The check hash is placed in b_ckhash and the B_CKHASH
    flag is set to indicate that a read was done and a check hash
    calculated. Though a rather elaborate mechanism, it should
    also work for check hashing other metadata in the future. A
    kernel internal API change was to change breada into a static
    fucntion and add flags and a function pointer to a check-hash
    function.

sys/ufs/ffs/fs.h:
    Add flags for types of check hashes; stored in a new word in the
    superblock. Define corresponding BX_ flags for the different types
    of check hashes. Add a check hash word in the cylinder group.

sys/ufs/ffs/ffs_alloc.c:
    In ffs_getcg do the dance with breadn_flags to get a check hash and
    if one is provided, check it.

sys/ufs/ffs/ffs_vfsops.c:
    Copy across the BX_FFSTYPES flags in background writes.
    Update the check hash when writing out buffers that need them.

sys/ufs/ffs/ffs_snapshot.c:
    Recompute check hash when updating snapshot cylinder groups.

sys/libkern/crc32.c:
lib/libufs/Makefile:
lib/libufs/libufs.h:
lib/libufs/cgroup.c:
    Include libkern/crc32.c in libufs and use it to compute check
    hashes when updating cylinder groups.

Four utilities are affected:

sbin/newfs/mkfs.c:
    Add the check hashes when building the cylinder groups.

sbin/fsck_ffs/fsck.h:
sbin/fsck_ffs/fsutil.c:
    Verify and update check hashes when checking and writing cylinder groups.

sbin/fsck_ffs/pass5.c:
    Offer to add check hashes to existing filesystems.
    Precompute check hashes when rebuilding cylinder group
    (although this will be done when it is written in fsutil.c
    it is necessary to do it early before comparing with the old
    cylinder group)

sbin/dumpfs/dumpfs.c
    Print out the new check hash flag(s)

sbin/fsdb/Makefile:
    Needs to add libufs now used by pass5.c imported from fsck_ffs.

Reviewed by: kib
Tested by: Peter Holm (pho)
2017-09-22 12:45:15 +00:00
John Baldwin
ed8d06aa19 Use UFS_LINK_MAX instead of LINK_MAX.
Submitted by:	bde
Sponsored by:	Chelsio Communications
2017-09-21 22:33:59 +00:00
Mariusz Zaborski
2560d18180 We use a few different ifdef's names to check if we are using Casper or not,
let's standardize this. Now we are always use WITH_CASPER name.

Discussed with:	emaste@
MFC after:	1 month
2017-09-21 14:41:41 +00:00
Alexey Dokuchaev
37eb5966f9 Provide an articulate example of how to properly delete partitions and
partitioning scheme.

Users often get confused and frustrated when trying to delete partition
table and getting ``Device busy'' error because they forgot (or did not
ever know that they have) to delete all its partitions first, and while
the manual page mentions this briefly, it does not stress it out enough.

Approved by:		ae, manpages (bjk)
PR (as inspiration):	196102
Differential Revision:	https://reviews.freebsd.org/D12336
2017-09-19 15:08:31 +00:00
Mariusz Zaborski
d1797f7bfc Fix language used in the r322923.
Pointed out by: wblock@
MFC after:      1 week
X-MFC-with:     r322923
2017-09-17 10:28:45 +00:00
Allan Jude
ed007b78d7 kern.osreldate is an integer, not a string
PR:		217501
Submitted by:	Yavuz Tanriverdi <stemix@gmail.com>
MFC after:	1 week
2017-09-16 16:23:00 +00:00
Conrad Meyer
985f4b3eb5 geom_virstor: Remove wholly unnecessary g_metadata_store copy
Just code cleanup.  No functional change.

Sponsored by:	Dell EMC Isilon
2017-09-08 15:38:02 +00:00