Commit Graph

8843 Commits

Author SHA1 Message Date
Mariusz Zaborski
31f7586d73 Introduce the 'n' flag for the geli attach command.
If the 'n' flag is provided the provided key number will be used to
decrypt device. This can be used combined with dryrun to verify if the key
is set correctly. This can be also used to determine which key slot we want to
change on already attached device.

Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D15309
2018-05-09 20:53:38 +00:00
Mariusz Zaborski
c2ac0fc5e0 Change option dry-run from 'n' to 'C' in geli attach command.
'n' is used in other commands to define the key index.
We should be consistent with that.
'C' option is used by patch(1) to perform dryrun so lets use that.

Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D15308
2018-05-09 20:51:16 +00:00
Warner Losh
0272270a8d nda protocol rate reporting
Report the NVMe spec, number of lanes (and max) as well as the PCIe
generation we're negotiated at (and max) for the camcontrol rate
command.

Reviewed by: scottl (the output, not the code)
Sponsored by: Netflix
2018-05-09 18:41:04 +00:00
Andrey V. Elsukov
c54e0abbc6 Update NAT64 documentation, now we support any IPv6 prefixes.
MFC after:	1 month
2018-05-09 12:25:23 +00:00
Andrey V. Elsukov
782360dec3 Bring in some last changes in NAT64 implementation:
o Modify ipfw(8) to be able set any prefix6 not just Well-Known,
  and also show configured prefix6;
o relocate some definitions and macros into proper place;
o convert nat64_debug and nat64_allow_private variables to be
  VNET-compatible;
o add struct nat64_config that keeps generic configuration needed
  to NAT64 code;
o add nat64_check_prefix6() function to check validness of specified
  by user IPv6 prefix according to RFC6052;
o use nat64_check_private_ip4() and nat64_embed_ip4() functions
  instead of nat64_get_ip4() and nat64_set_ip4() macros. This allows
  to use any configured IPv6 prefixes that are allowed by RFC6052;
o introduce NAT64_WKPFX flag, that is set when IPv6 prefix is
  Well-Known IPv6 prefix. It is used to reduce overhead to check this;
o modify nat64lsn_cfg and nat64stl_cfg structures to use nat64_config
  structure. And respectivelly modify the rest of code;
o remove now unused ro argument from nat64_output() function;
o remove __FreeBSD_version ifdef, NAT64 was not merged to older versions;
o add commented -DIPFIREWALL_NAT64_DIRECT_OUTPUT flag to module's Makefile
  as example.

Obtained from:	Yandex LLC
MFC after:	1 month
Sponsored by:	Yandex LLC
2018-05-09 11:59:24 +00:00
Mark Johnston
0ff40d3d29 Add netdump support to dumpon(8).
A new usage is added so that parameters for netdump may be specified.
Specifically, one configures an interface for netdump with:

# dumpon -c <client IP> -s <server IP> [-g <gateway IP>] <iface name>

Reviewed by:	bdrewery, cem (earlier versions), sbruno
MFC after:	1 month
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D15254
2018-05-06 00:42:30 +00:00
Alexander Motin
ba405bc811 Add NVMe Namespace Management support to nvmecontrol(8).
This allows create/delete/attach/detach namespaces on new NVMe controllers.
This is only a first user-level part of the bigger change set.  Kernel part
required to detect and handle the configuration changes without reboot is
completely independent and will be added separately.

Submitted by:	Matt Williams <mffbsdw@gmail.com> (original version)
Differential Revision:	https://reviews.freebsd.org/D11399
2018-05-05 20:08:03 +00:00
Xin LI
3e855e9c21 Don't bail out from the check if readboot() returns !FSFATAL.
This can happen when the fsinfo signature is invalid, and the
user have choose to fix it, in which case the code would return
FSBOOTMOD (not FSOK but not FSFATAL either).

All other (fatal) cases would return FSFATAL.

Obtained from:	Android Open Source Project
Obtained from:	d8775a29ea
MFC after:	2 weeks
2018-04-30 05:57:55 +00:00
Kristof Provost
c5e105655b pfctl: Don't break connections on skipped interfaces on reload
On reload we used to first flush everything, including the list of skipped
interfaces.  This can lead to termination of these connections if they send
packets before the new configuration is applied.

Note that this doesn't currently happen on 12 or 11, because of special EACCES
handling introduced in r315514. This special behaviour in tcp_output() may
change, hence the fix in pfctl.

PR:		214613
2018-04-28 13:16:58 +00:00
Brooks Davis
4204224162 Finish removing FDDI and tokenring media support.
This fixes media display for 802.11 wireless devices.

Software outside the base system that uses these media types and
defines should use #ifdef IFM_FDDI or IFM_TOKEN to include or remove
support.

Reported by:	zeising
Reviewed by:	emaste, kib, zeising
Tested by:	zeising
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15170
2018-04-23 21:10:33 +00:00
Andrew Gallatin
47528c67ef Make lagg creation more fault tolerant
- Warn, don't exit, when SIOCSLAGGPORT returns an error.

When we exit with an error during lagg creation, a single
failed NIC (which no longer attaches) can prevent lagg
creation and other configuration, such as adding an IPv4
address, and thus leave a machine unreachable.

- Preserve non-EEXISTS errors for exit status from SIOCSLAGGPORT,
  in case scripts are looking for it. Hopefully this can be
  extended if other parts of ifconfig can allow a "soft" failure.

- Improve the warning message to mention what lagg and what
  member are problematic.

Reviewed by: jtl, glebius
Sponsored by: Netflix
Differential Revision:	https://reviews.freebsd.org/D15046
2018-04-17 12:54:58 +00:00
Brooks Davis
eec02418d8 Remove support for FDDI and token ring media types in userland utilities.
Reviewed by:	kib
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15077
2018-04-16 18:07:51 +00:00
Andrey V. Elsukov
0f71e509e5 Fix indenting in ipv6.c file, use tabs instead of mixing tabs and spaces.
MFC after:	1 week
2018-04-12 20:05:26 +00:00
Andrey V. Elsukov
bd32e33552 Remove printing of "not" keyword from print_ip6() function.
After r331668 handling of F_NOT flag done in one place by
print_instruction() function. Also remove unused argument from
print_ip[6]() functions.

MFC after:	1 week
2018-04-12 19:44:04 +00:00
Andrey V. Elsukov
09a6be91bc Remove printing of "not" keyword from print_ip() function.
After r331668 handling of F_NOT flag done in one place by
print_instruction() function.

MFC after:	1 week
2018-04-12 19:34:35 +00:00
Brooks Davis
0437c8e3b1 Remove support for FDDI networks.
Defines in net/if_media.h remain in case code copied from ifconfig is in
use elsewere (supporting non-existant media type is harmless).

Reviewed by:	kib, jhb
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15017
2018-04-11 17:28:24 +00:00
Oleg Bulyzhin
e5e8324fea Fix typo.
MFC after:	1 week
2018-04-11 11:17:57 +00:00
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
Conrad Meyer
0bd816f211 Audit userspace geom code for leaking memory to disk
Any geom class using g_metadata_store, as well as geom_virstor which
duplicated g_metadata_store internally, would dump sectorsize - mdsize bytes
of userspace memory following the metadata block stored. This is most or all
geom classes (gcache, gconcat, geli, gjournal, glabel, gmirror, gmultipath,
graid3, gshsec, gstripe, and geom_virstor).

PR:		222077 (comment #3)
Reported by:	Maxim Khitrov <max AT mxcrypt.com>
Reviewed by:	des
Security:	yes
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12269
2017-09-08 15:08:17 +00:00
Kirk McKusick
855662c611 The new fsck recovery information to enable it to find backup
superblocks created in revision 322297 only works on disks
with sector sizes up to 4K. This update allows the recovery
information to be created by newfs and used by fsck on disks
with sector sizes up to 64K. Note that FFS currently limits
filesystem to be mounted from disks with up to 8K sectors.
Expanding this limitation will be the subject of another
commit.

Reported by: Peter Holm
Reviewed with: kib
2017-09-04 20:19:36 +00:00
Warner Losh
781fe538ae Print the controller's ID in identify.
Submitted by: Matt Williams
Sponsored by: Netflix
2017-08-28 23:54:08 +00:00
Maxim Sobolev
f7ca2bbe44 Add ability to label md(4) devices.
This feature comes from the fact that we rely memory-backed md(4)
in our build process heavily. However, if the build goes haywire
the allocated resources (i.e. swap and memory-backed md(4)'s) need
to be purged. It is extremely useful to have ability to attach
arbitrary labels to each of the virtual disks so that they can
be identified and GC'ed if neecessary.

MFC after:	4 weeks
Differential Revision:	https://reviews.freebsd.org/D10457
2017-08-28 15:54:07 +00:00
Mariusz Zaborski
3453dc72ad Hide length of geli passphrase during boot.
Introduce additional flag to the geli which allows to restore previous
behavior.

Reviewed by:	AllanJude@, cem@ (previous version)
MFC:		1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D11751
2017-08-26 14:07:24 +00:00
Konstantin Belousov
24328efbb4 Typo, the '-6' option selects inet6.
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2017-08-15 19:29:10 +00:00
Enji Cooper
188e46ab03 Add supporting changes for Add limited sandbox capability to "make check"
Non-tests/... changes:
- Add HAS_TESTS= to Makefiles with libraries and programs to enable iteration
  and propagate the appropriate environment down to *.test.mk.

tests/... changes:
- Add appropriate support Makefile.inc's to set HAS_TESTS in a minimal manner,
  since tests/... is a special subdirectory tree compared to the others.

MFC after:	2 months
MFC with:	r322511
Reviewed by:	arch (silence), testing (silence)
Differential Revision:	D12014
2017-08-14 19:21:37 +00:00
Kirk McKusick
77b63aa0fc Since the switch to GPT disk labels, fsck for UFS/FFS has been
unable to automatically find alternate superblocks. This checkin
places the information needed to find alternate superblocks to the
end of the area reserved for the boot block.

Filesystems created with a newfs of this vintage or later will
create the recovery information. If you have a filesystem created
prior to this change and wish to have a recovery block created for
your filesystem, you can do so by running fsck in forground mode
(i.e., do not use the -p or -y options). As it starts, fsck will
ask ``SAVE DATA TO FIND ALTERNATE SUPERBLOCKS'' to which you should
answer yes.

Discussed with: kib, imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D11589
2017-08-09 05:17:21 +00:00
Renato Botelho
af71799848 Add missing parenthesis on error message
Approved by:	loos
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC (Netgate)
2017-08-08 22:40:26 +00:00
Ed Maste
5b240641ec Remove now-unused badsb declaration, missed in r322200
Sponsored by:	The FreeBSD Foundation
2017-08-08 18:31:40 +00:00
Warner Losh
e9e9182841 In debug mode, print the differences between the superblock and
alternate superblock when the values disagree and we're going to
reject it.

Differential Revision: https://reviews.freebsd.org/D11589
2017-08-07 21:23:59 +00:00
Warner Losh
bb10d553af Make it possible to ignore superblock mismatch. This will not fix such
a mismatch, but will allow fsck to continue when the last alternate
superblock gets corrupted somehow.

Also, remove searching for alternate super blocks. It should have been
removed two years ago with r276737 by imp@. Leave minor vestiges in
place in case someone wants to solve the hard problem of knowing where
altnernate superblocks live without access to data formerly stored in
disklabels.

Differential Revision: https://reviews.freebsd.org/D11589
2017-08-07 21:23:54 +00:00
Matt Joras
fdf2bc100e Selectively print "hwaddr" from ifconfig(8).
ifconfig(8) printing the hwaddr is only really useful if it differs from
the link layer address.

Reported by:	jhb
Reviewed by:	rpokala
Approved by:	rstone (mentor)
Differential Revision:	https://reviews.freebsd.org/D11777
2017-08-04 21:06:47 +00:00
Enji Cooper
d511b20a69 Add HAS_TESTS to all Makefiles that are currently using the
`SUBDIR.${MK_TESTS}+= tests` idiom.

This is a follow up to r321912.
2017-08-02 08:50:42 +00:00
Enji Cooper
4b330699f8 Convert traditional ${MK_TESTS} conditional idiom for including test
directories to SUBDIR.${MK_TESTS} idiom

This is being done to pave the way for future work (and homogenity) in
^/projects/make-check-sandbox .

No functional change intended.

MFC after:	1 weeks
2017-08-02 08:35:51 +00:00
Andrew Gallatin
a18f34fe77 Don't request CTLTYPE_OPAQUE if we can't print them.
The intent is to skip expensive opaque sysctls like tcp_pcblist unless
they are explicitly requested. Sysctl nodes like this don't show up in
sysctl -a, but they do generate output that winds up being dropped,
unless the user specifically requested  binary/hex output or opaques.

This reduces the runtime of sysctl in many circumstances on a loaded
system.  It also reduces the likelihood that simply gathering
diagnostics on a sick machine (stuck lock, etc) via sysctl -a might
push it over the edge into a total lockup.

Reviewed by:	jtl
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D11461
2017-07-31 14:56:35 +00:00
Rick Macklem
4261923e76 Add a new "-N" option to umount(8), that does a forced dismount of an NFS mount
point.

The new "-N" option does a forced dismount of an NFS mount point, but avoids
doing any checking of the mounted-on path, so that it will not get hung
when a vnode lock is held by another hung process on the mounted-on vnode.
The most common case of this is a "umount" with the "-f" option.
Other than avoiding checking the mounted-on path, it performs the same
forced dismount as a successful "umount -f" would do.

This commit includes a content change to the man page.

Tested by:	pho
Reviewed by:	kib
MFC after:	2 weeks
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D11735
2017-07-29 20:08:25 +00:00
Mark Johnston
cf8eb490f5 Fix style and wrap lines to 80 columns in savecore.c.
No functional change intended.

MFC after:	3 days
2017-07-24 21:51:41 +00:00
Mark Johnston
ab384d75db Revert r320918 and have mkdumpheader() handle version string truncation.
Reported by:	jhb
MFC after:	1 week
2017-07-15 20:53:08 +00:00
Kristof Provost
4d7709ddf6 pfctl parser tests
Copy the most important test cases from OpenBSD's corresponding
src/regress/sbin/pfctl, those that run pfctl on a test input file and check
correctness of its output. We have also added some new tests using the same
format.

The tests consist of a collection of input files (pf*.in) and
corresponding output files (pf*.ok). We run pfctl -nv on the input
files and check that the output matches the output files. If any
discrepancy is discovered during future development in the source
tree, we know that a regression bug has been introduced into the tree.

Submitted by:	paggas
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	https://reviews.freebsd.org/D11322
2017-07-15 19:22:01 +00:00
Mark Johnston
5aaf766710 Add a newline after the version string.
MFC after:	3 days
2017-07-12 18:29:25 +00:00
Mark Johnston
4e287bd860 Add a subroutine for comparing kerneldump identifiers.
MFC after:	2 weeks
2017-07-11 18:24:05 +00:00
Enji Cooper
32b7e40e69 Fix whitespace bugs
- Delete trailing whitespace.
- Replace 8 single column spaces with hard tabs.
- Delete lines with consisting purely of blank space.
- Add space between `return` and `(`, per style(9).

Special care was taken to not blindly replace 8 single column spaces
with tabs; doing so could break tools that do strict string comparisons
with camcontrol output.
2017-07-10 05:16:07 +00:00
Enji Cooper
db9d4c3972 Fix -Wuninitialized warning with gcc
Initialize mmc_data_byte to 0, as it could be used uninitialized
later on.

MFC with:	r320846
Reported by:	Jenkins (powerpc jobs)
2017-07-10 04:28:28 +00:00
Warner Losh
d55c777cdf New command 'mmcsdcmd' for camcontrol, to allow interacting with SD cards
Submitted by: Ilya Babulin
2017-07-09 17:02:52 +00:00
Edward Tomasz Napierala
1f3aded066 Fix "mount -uw /" when the filesystem type doesn't match.
This basically makes "mount -uw /" work when the filesystem
mounted on / is NFS, but the one configured in fstab(5) is UFS,
which can happen when you forget to modify fstab.

Note that the whole special case ("else if (argv[0][0] == '/'")
is probably not needed anyway.  I'll take a look at removing it
altogether; for now this is a minimally intrusive fix.

MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D11323
2017-07-08 11:06:27 +00:00
Warner Losh
bbbfb2a922 Bump date for today's commit. 2017-07-07 16:58:40 +00:00
Warner Losh
1e001b99a5 Improve wording for -E and -t flags. -E never writes the entire disk,
so don't imply that. Note that if BIO_DELETE isn't supported, the
operation will fail (as opposed to writing the entire disk with
zeros). Thin storage also benefits from trim. List more accurate
reason why trim helps flash-memory.
2017-07-07 16:54:18 +00:00
Xin LI
95595f99b9 - Use strlcat() instead of strncat().
- Use asprintf() and handle allocation errors.

Reviewed by:	kevlo
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D11486
2017-07-07 02:48:55 +00:00
Enji Cooper
01df7d10a5 Remove SUBDIR ordering/uniquifying in *bin/Makefile
After the addition of SUBDIR.yes, uniquifying/ordering the SUBDIRs doesn't
make a whole lot of sense, and it's in effect a half measure.

Ordering SUBDIR (after adding SUBDIR.yes to it) in bsd.subdir.mk is a
separate change that warrants more discussion/testing, because while
the SUBDIR_PARALLEL work largely fixed dependency ordering for SUBDIRs,
there might be downstream FreeBSD consumers that rely on the SUBDIR
ordering.

MFC after:	2 months
Reviewed by:	bdrewery
Differential Revision:	D11398
2017-07-06 04:15:30 +00:00
Warner Losh
4d81e14528 Fix sign of resid and add a mostly useless cast to cope with signed vs
unsigned check warnings from traditional unix code construsts bogusly
flagged as potentially unsafe.
2017-07-01 02:19:48 +00:00
Warner Losh
440f35093c Improve wdc error log pulling.
After review by the WDC engineers, improve how we pull down the
so-called 'e6' logs. The 'c6' logs are obsolete and support for them
has been removed because FreeBSD needed to pull them in chunks, which
is incompatible with the 0xc6 opcode implementation. Rather than leave
the code in place that produces bad log pulls, remove it.
2017-06-29 23:15:28 +00:00
Warner Losh
bbd508cae9 Report some aspects of namespaces and namespace support in identify
command.

Sponsored by: Netflix
Submitted by: Matt Williams (via D11330)
2017-06-27 20:24:44 +00:00
Warner Losh
970d454f63 Move 128-bit integer routines to util.c so they can be used by more
than just the log page code.

Sponsored by: Netflix, Inc
Submitted by: Matt Williams (via D11330)
2017-06-27 20:24:25 +00:00
Emmanuel Vadot
c2dbd123da ipfw: Note that bandwidth can take G suffix in the manpage
Reported by:	Jose Luis Duran (github)
2017-06-23 17:31:07 +00:00
Emmanuel Vadot
a61847217d ipfw: dummynet: Add 'G' and 'g' suffix for bandwidth configuration/display
MFC after:	2 weeks
Sponsored by:	Gandi.net
2017-06-23 14:00:28 +00:00
Kirk McKusick
aeb2785c30 Allow '_' in labels when specifying -L to newfs.
Reported by: Keve Nagy
Reviewed by: kib
PR: 220163
MFC after: 5 days
2017-06-20 21:26:42 +00:00
Alan Somers
2852e2b235 Require devd to be running for its ATF tests to run
The ATF tests communicate with the system's running devd

PR:		220169
Reported by:	gjb
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2017-06-20 19:34:21 +00:00
Alan Somers
91cfa6b8f9 devd(8): Remove pidfile on shutdown
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2017-06-20 19:32:39 +00:00
Bryan Drewery
c99b67a794 Utilize SYSROOT from r320119 in places where DESTDIR may be wanting WORLDTMP.
Since buildenv exports SYSROOT all of these uses will now look in
WORLDTMP by default.

sys/boot/efi/loader/Makefile
        A LIBSTAND hack is no longer required for buildenv.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-06-19 20:47:24 +00:00
Alan Somers
92b66dbe4d sbin/ipfw: strcpy, strncpy => strlcpy
Reported by:	Coverity
CID:		1356162, 1356166
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D10662
2017-06-13 14:57:48 +00:00
Konstantin Belousov
40373cf5b8 Remove msdosfs -o large support.
Its purpose was to translate the values for msdosfs inode numbers,
which is calculated from the msdosfs structures describing the file,
into the range representable by 32bit ino_t.  The translation acted
for filesystems larger than 128Gb, it reserved the range 0xf0000000
(FILENO_FIRST_DYN) to UINT32_MAX and remembered some arbitrary
translation of ino >= FILENO_FIRST_DYN into this range.  It consumed
memory that could be only freed by unmount, and the translation was
not stable across remounts.

With ino_t type extended to 64 bit, there is no such issue and values
can be returned without compaction to 32bit.  That is, for the native
environments, the translation layer is not necessary and adds
significant undeserved code complexity.  For compat ABIs which use
32bit ino_t, the vfs.ino64_trunc_error sysctl provides some measures
to soften the failure mode when inode numbers truncation is not safe.

Discussed with:	bde
Sponsored by:	The FreeBSD Foundation
2017-06-09 12:06:22 +00:00
Emmanuel Vadot
b3fc23dbfa ipfw.8: Note that the ipfw_nat kernel module must be loaded or that the
IPFIREWALL_NAT options must be in the kernel config in order to use in-kernel
nat.

MFC after:	3 days
2017-06-01 09:14:49 +00:00
Stephen J. Kiernan
bbeb726b93 parse.c parse_string
When parse_semi fails, free s before returning

parse.c parse_numeric_aggregate
The memory assigned to bufp is complicated, it can either be from the input
parameter buf or allocated locally. Introduce a new variable lbufp to track
when it is assigned locally and to free it when appropriate.

Submitted by:	Thomas Rix <trix@juniper.net>
Reviewed by:	jhb
Approved by:	sjg (mentor)
Obtained from:	Juniper Networks, Inc.
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9899
2017-05-31 21:31:15 +00:00
Stephen J. Kiernan
9a81ba0f24 Add MD_VERIFY option to enable O_VERIFY in open for vnode type.
Add -o [no]verify option to mdconfig (and document in man page.)
Implement GEOM attribute MNT::verified to ask md if the backing vnode is
  verified.
Check for MNT::verified in cd9660 mount to flag the mount as MNT_VERIFIED if
  the underlying device has been verified.

Reviewed by:	rwatson
Approved by:	sjg (mentor)
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D2902
2017-05-31 21:18:11 +00:00
Alan Somers
8a7fc69049 Fix integer overflow in "camcontrol format"
Reported by:	Coverity
CID:		1011426
MFC after:	1 week
Sponsored by:	Spectra Logic Corp
2017-05-31 14:59:03 +00:00
Edward Tomasz Napierala
3d6a5b1434 .Xr mount.conf(5) from boot(8).
MFC after:	2 weeks
2017-05-28 18:13:44 +00:00
Edward Tomasz Napierala
5b2d5e4fc2 Move mount.conf(8) to mount.conf(5); it's a kernel configuration file
and not an administrative utility.

MFC after:	2 weeks
2017-05-28 18:07:53 +00:00
Glen Barber
9a7af23f46 Update the "first appeared in" version in several manual pages.
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2017-05-24 17:47:49 +00:00
Konstantin Belousov
6992112349 Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints.  Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment.  Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.

ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks.  Unfortunately, not everything can be
fixed, especially outside the base system.  For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.

Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.

Struct xvnode changed layout, no compat shims are provided.

For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.

Update note: strictly follow the instructions in UPDATING.  Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.

Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb).  Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver.  Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem).  Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).

Sponsored by:	The FreeBSD Foundation (emaste, kib)
Differential revision:	https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
Andrey V. Elsukov
52772a8583 Allow zero port specification in table entries with type flow.
PR:		217620
MFC after:	1 week
2017-05-17 10:56:22 +00:00
Ed Maste
4dd362f93f newfs_msdos: clarify description of -T (timestamp) option
Submitted by:	Siva Mahadevan <smahadevan@freebsdfoundation.org>
Reported by:	Daniel Shahaf <danielsh apache org>
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
2017-05-16 19:03:26 +00:00
Ed Maste
28ef05f7c3 newfs_msdos: add -T (timestamp) option for reproducible builds
This includes some whitespace and minor bug fixes relative to NetBSD,
which will be submitted upstream at the conclusion of the makefs
msdos update.

NetBSD revs:
mkfs_msdos.c	1.11
mkfs_msdos.h	1.4
newfs_msdos.8	1.22
newfs_msdos.c	1.44

Submitted by:	Siva Mahadevan <smahadevan@freebsdfoundation.org>
Reviewed by:	emaste
Obtained from:	NetBSD
Sponsored by:	The FreeBSD Foundation
2017-05-16 17:04:50 +00:00
Ravi Pokala
ddae57504b Persistently store NIC's hardware MAC address, and add a way to retrive it
The MAC address reported by `ifconfig ${nic} ether' does not always match
the address in the hardware, as reported by the driver during attach. In
particular, NICs which are components of a lagg(4) interface all report the
same MAC.

When attaching, the NIC driver passes the MAC address it read from the
hardware as an argument to ether_ifattach(). Keep a second copy of it, and
create ioctl(SIOCGHWADDR) to return it. Teach `ifconfig' to report it along
with the active MAC address.

PR:		194386
Reviewed by:	glebius
MFC after:	1 week
Sponsored by:	Panasas
Differential Revision:	https://reviews.freebsd.org/D10609
2017-05-10 22:13:47 +00:00
Bryan Drewery
07676084ec DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-05-09 01:48:23 +00:00
Bryan Drewery
6106a50ee6 DIRDEPS_BUILD: Connect new directories.
Sponsored by:	Dell EMC Isilon
2017-05-09 01:48:14 +00:00
Rick Macklem
1362276303 Fix mount_nfs so that it doesn't create mounttab entries for NFSv4 mounts.
The NFSv4 protocol doesn't use the Mount protocol, so it doesn't make sense
to add an entry for an NFSv4 mount to /var/db/mounttab. Also, r308871
modified umount so that it doesn't remove any entry created by mount_nfs.
Reported on freebsd-current@.

Reported by:	clbuisson@orange.fr
MFC after:	2 weeks
2017-05-08 00:45:05 +00:00
Nick Hibma
cfbb427c9d Fix the output of very large rebind, renew and lease time options in
lease file.

Some routers set very large values for rebind time (Netgear) and these
are erroneously reported as negative in the leasefile. This was due to a
wrong printf format specification of %ld for an unsigned long on 32-bit
platforms.
2017-05-07 21:11:28 +00:00
Nick Hibma
223c44aec9 Fix handling of large DHCP expiry values.
They would overflow a signed 32-bit time_t on 32 bit architectures. This
was taken care of, but a compiler optimisation makes this behave
erratically. This could be resolved by adding a -fwrapv flag, but
instead we can check the value before adding the current timestamp to
it.

In the lease file values are still wrong though:

  option dhcp-rebinding-time -644245096;

PR:		218980
Reported by:	Bob Eager
MFC after:	2 weeks
2017-05-07 19:59:37 +00:00
Kenneth D. Merry
1e773aeb99 When editing a mode page on a tape drive, do not clear the device
specific parameter.

Tape drives include write protect (WP), Buffered Mode and Speed
settings in the device-specific parameter.  Clearing this
parameter on a mode select can have the effect of turning off
write protect or buffered mode, or changing the speed setting of
the tape drive.

Disks report DPO/FUA support via the device specific parameter
for MODE SENSE, but the bit is reserved for MODE SELECT.  So we
clear this for disks (and other non-tape devices) to avoid
potential errors from the target device.

sbin/camcontrol/modeedit.c:
	Clear the device-specific parameter in the mode page
	header if we're not operating on a tape drive.

MFC after:	3 days
Sponsored by:	Spectra Logic
2017-05-05 21:29:28 +00:00
Kenneth D. Merry
aefae9c7bb Bump the camcontrol(8) man page date.
MFC after:	3 days
X-MFC-with:	r317774
Sponsored by:	Spectra Logic
2017-05-03 21:04:32 +00:00
Kenneth D. Merry
36d0fa44e2 Add the ability to rescan or reset devices specified by peripheral
name and unit number in camcontrol(8).

Previously camcontrol(8) only supported rescanning or resetting
devices specified by bus:target:lun.  This is because for
rescanning at least, you don't have a peripheral name and unit
number (e.g. da4) for devices that don't exist yet.

That is still the case after this change, but in other cases, when
the device does exist in the CAM EDT (Existing Device Table), we
do a careful lookup of the bus/target/lun if the user supplies a
peripheral name and unit number to find the bus:target:lun and then
issue the requested reset or rescan.

The lookup is done without actually opening the device in question,
since a rescan is often done to make a device go away after it has
been pulled.  (This is especially true for busses/controllers, like
parallel SCSI controllers, that don't automatically detect changes
in topology.)  Opening a device that is no longer there to
determine the bus/target/lun might result in error recovery actions
when the user really just wanted to make the device go away.

sbin/camcontrol/camcontrol.c:
	In dorescan_or_reset(), if the use hasn't specified a
	numeric argument, assume he has specified a device.  Lookup
	the pass(4) instance for that device using the transport
	layer CAMGETPASSTHRU ioctl.  If that is successful, we can
	use the returned bus:target:lun to rescan or reset the
	device.

	Under the hood, resetting a device using XPT_RESET_DEV is
	actually sent via the pass(4) device anyway.  But this
	provides a way for the user to specify devices in a more
	convenient way, and can work on device rescans when the
	device is going away, assuming it still exists in the EDT.

sbin/camcontrol/camcontrol.8:
	Update the man page for the rescan and reset subcommands
	to reflect that you can now use a device name and unit
	number with them.

Sponsored by:	Spectra Logic
MFC after:	3 days
2017-05-03 20:57:52 +00:00
Alan Somers
b583a2c10d Fix memory leaks in camcontrol
Reported by:	Coverity
CID:		1331674, 1331675
Reviewed by:	ken
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D10588
2017-05-03 19:56:55 +00:00
Alan Somers
f24faa98dc Unbreak ifconfig for mlx4en(4) after r317755
ifconfig doesn't correctly infer mlx interfaces' module names, so it will
attempt to load the mlx(4) module even when not necessary.

Reported by:	rstone
MFC after:	3 weeks
X-MFC-With:	317755
Sponsored by:	Spectra Logic Corp
2017-05-03 19:53:01 +00:00
Alan Somers
6223cc336e Various Coverity fixes in ifconfig(8)
* Exit early if kldload(2) fails (1011259). This is the only change that
  affects ifconfig's behavior.
* Close memory and resource leaks (1305624, 1305205, 1007100)
* Mark usage() as _Noreturn (1305806, 1305750)
* Fix some dereference after null checks (1011474, 270774)

Reported by:	Coverity
CID:		1305624, 1305205, 1007100, 1305806, 1305750, 1011474,
CID:		270774, 1011259
Reviewed by:	cem
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D10587
2017-05-03 17:21:01 +00:00
Alan Somers
1d57432685 ifconfig displays ND6_IFF_NO_DAD as "IGNORELOOP"
PR:		218958
Reviewed by:	kristof
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D10543
2017-05-03 01:46:39 +00:00
Andrey V. Elsukov
421c583873 Add ipfw table all destroy support.
PR:		212669
MFC after:	1 week
2017-05-02 17:16:24 +00:00
Andrey V. Elsukov
16804dc779 In parse_range() validate both range values instead of checking
the top  value twice.

PR:		202295
MFC after:	1 week
2017-05-02 05:20:54 +00:00
Andrey V. Elsukov
e028ccdad8 Add sets support for ipfw table info/list/flush commands.
PR:		212668
MFC after:	1 week
2017-05-02 05:02:12 +00:00
Andrey V. Elsukov
df5be97c1a Properly initialize ipfw_range_tlv variable to fix possible EINVAL
in case when ipfw delete/zero/resetlog command issued for several rules
in the loop. Also reorder some variables by size.

PR:		218993
MFC after:	1 week
2017-05-02 01:03:59 +00:00
Kenneth D. Merry
d618624cbd Fix camcontrol timestamp setting and update the man page.
camcontrol timestamp -s would somtimes fail due to stack garbage.  Zero out
the timestamp parameters to fix it.

Fix another nearby bug, and update the man page.

sbin/camcontrol/timestamp.c:
	In set_timestamp(), bzero ts_p prior to creating the timestamp.
	Previously stack garbage could cause some tape drives to reject the
	timestamp.

	In set_timestamp(), check for failures from strptime().

sbin/camcontrol/camcontrol.8:
	Add the time argument to the -T option to camcontrol timestamp -s
	in the long description.

	Change the time/date format used in the camcontrol timestamp
	example to RFC 2822 format.  This fixes a time zone issue with the
	original example by specifying the time zone as -0600.  Otherwise,
	the time zone seems to default to standard time in the current
	locale, which makes the time, when reported back from the drive,
	1 hour off from the intended setting.  This also fixes a duplicate
	day of the week ("Wednesday Wed") in the previous example.

Submitted by:	Sam Klopsch
MFC after:	3 days
Sponsored by:	Spectra Logic
2017-05-01 18:53:47 +00:00
Alan Somers
a80379c6d9 Fix a comment that's been wrong ever since this file was imported in 1997 2017-05-01 01:42:26 +00:00
Mark Felder
f8824f7be7 Document in ifconfig(8) that gre(4) accepts tunnel commands
- Also ensure wording is consistent for gif and gre

Reviewed by:	wblock
Differential Revision:	https://reviews.freebsd.org/D5667
2017-04-29 15:35:30 +00:00
Edward Tomasz Napierala
461ef81d0e Advertise kldxref(8) a little better.
MFC after:	2 weeks
2017-04-27 19:48:00 +00:00
Alexander Motin
5e50c20ea1 Fix withered handling of r280687, broken by r286719.
MFC after:	1 week.
2017-04-27 19:03:08 +00:00
Brooks Davis
a7dc31283a Remove the NATM framework including the en(4), fatm(4), hatm(4), and
patm(4) devices.

Maintaining an address family and framework has real costs when we make
infrastructure improvements.  In the case of NATM we support no devices
manufactured in the last 20 years and some will not even work in modern
motherboards (some newer devices that patm(4) could be updated to
support apparently exist, but we do not currently have support).

With this change, support remains for some netgraph modules that don't
require NATM support code. It is unclear if all these should remain,
though ng_atmllc certainly stands alone.

Note well: FreeBSD 11 supports NATM and will continue to do so until at
least September 30, 2021.  Improvements to the code in FreeBSD 11 are
certainly welcome.

Reviewed by:	philip
Approved by:	harti
2017-04-24 21:21:49 +00:00
Marius Strobl
247cea8f9c In fill_ip6(), the value of the pointer av changes before it is
free(3)ed. Thus, introduce a new variable to track the original
value.

Submitted by:		Tom Rix
Differential Revision:	https://reviews.freebsd.org/D9962
2017-04-23 21:17:59 +00:00
Pedro F. Giffuni
f671769766 fsck_ffs: Unsign some variables and make use of reallocarray(3).
Instead of casting listmax and numdirs to unsigned values just define
them as unsigned and avoid the casts. Use reallocarray(3).

While here, fs_ncg is already unsigned so the cast is unnecessary.

Reviewed by:	mckusick
MFC after:	2 weeks
2017-04-22 14:50:11 +00:00
Alexander Motin
d8880fd450 Always allow setting number of iterations for the first time.
Before this change it was impossible to set number of PKCS#5v2 iterations,
required to set passphrase, if it has two keys and never had any passphrase.
Due to present metadata format limitations there are still cases when number
of iterations can not be changed, but now it works in cases when it can.

PR:		218512
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D10338
2017-04-21 07:16:07 +00:00
Patrick Kelsey
2f8c6c0a58 Fix userland tools that don't check the format of routing socket
messages before accessing message fields that may not be present,
removing dead/duplicate/misleading code along the way.

Document the message format for each routing socket message in
route.h.

Fix a bug in usr.bin/netstat introduced in r287351 that resulted in
pointer computation with essentially random 16-bit offsets and
dereferencing of the results.

Reviewed by:	ae
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D10330
2017-04-16 19:17:10 +00:00
Enji Cooper
6f11c9ca7c Switch back to non-IEC units for 1024 bytes
I was swayed a little too quickly when I saw the wiki page discussing
kB vs KiB. Switch back as none of the code in base openly uses
IEC units via humanize_number(3) (which was my next step), and there's
a large degree of dislike with IEC vs more SI-like units.

MFC after:	7 weeks
Submitted by:	jhb, rgrimes
Sponsored by:	Dell EMC Isilon
2017-04-15 06:53:07 +00:00
Enji Cooper
f09cb4f208 savecore: fix space calculation with respect to minfree in check_space(..)
- Use strtoll(3) instead of atoi(3), because atoi(3) limits the
  representable data to INT_MAX. Check the values received from
  strtoll(3), trimming trailing whitespace off the end to maintain
  POLA.
- Use `KiB` instead of `kB` when describing free space, total space,
  etc. I am now fully aware of `KiB` being the IEC standard for 1024
  bytes and `kB` being the IEC standard for 1000 bytes.
- Store available number of KiB in `available` so it can be more
  easily queried and compared to ensure that there are enough KiB to
  store the dump image on disk.
- Print out the reserved space on disk, per `minfree`, so end-users
  can troubleshoot why check_space(..) is reporting that there isn't
  enough free space.

MFC after:	7 weeks
Reviewed by:	Anton Rang <rang@acm.com> (earlier diff), cem (earlier diff)
Tested with:	positive/negative cases (see review); make tinderbox
Sponsored by:	Dell EMC Isilon
Differential Revision:	D10379
2017-04-14 19:41:48 +00:00
Konstantin Belousov
f4247773fa In fsck_ffs pass1, prevent the inosused variable from wrapping.
The loop that scans the used inode map when soft updates is in use
assumes that the inosused variable is signed.  However, ino_t is
unsigned, so the loop invariant is incorrect and the check for
inosused wrapping to < 0 can never be true.

Instead of checking for wrap after the fact just prevent it from
happening in the first place.

PR:	218592
Submitted by:	Todd Miller <todd.miller@courtesan.com>
Reviewed by:	mckusick
MFC after:	1 week
2017-04-14 15:22:00 +00:00