Commit Graph

9117 Commits

Author SHA1 Message Date
Andrey V. Elsukov
978f2d1728 Add "tcpmss" opcode to match the TCP MSS value.
With this opcode it is possible to match TCP packets with specified
MSS option, whose value corresponds to configured in opcode value.
It is allowed to specify single value, range of values, or array of
specific values or ranges. E.g.

 # ipfw add deny log tcp from any to any tcpmss 0-500

Reviewed by:	melifaro,bcr
Obtained from:	Yandex LLC
MFC after:	1 week
Sponsored by:	Yandex LLC
2019-06-21 10:54:51 +00:00
Xin LI
0b253f2ba4 In ask(): override default option if any of alwaysyes/alwaysno/rdonly is
set.

MFC after:	2 weeks
2019-06-15 07:23:06 +00:00
Xin LI
1e3ffe6590 Blankspace. No actual code change.
MFC after:	2 weeks
2019-06-15 06:51:46 +00:00
Kirk McKusick
e924cb6ff9 Clarify that the -r and -R options can be used only to create level 0 dumps.
Suggested by: phk
MFC after:    3 days
2019-06-14 06:10:15 +00:00
Warner Losh
07810343ee Increase the timeout for READ NATIVE MAX
READ NATIVE MAX can take longer than a second if the queued NCQ I/Os
take longer than a second to drain.
2019-06-13 05:19:36 +00:00
Xin LI
bf6ed41692 Avoid out of boundary access when checking invalid long filenames.
Obtained from:	OpenBSD (dir.c,v 1.25)
MFC after:	3 days
2019-06-11 22:21:29 +00:00
Xin LI
669d33ef98 preen should work independently with alwaysyes and alwaysno.
PR:		238375
MFC after:	2 weeks
2019-06-07 01:38:51 +00:00
Xin LI
51a1c26a18 Don't increment cl after increment.
MFC after:	3 days
2019-06-04 07:02:20 +00:00
Kyle Evans
7c08a497ba bectl(8): Don't accept jid=0 from jail_getid
This will trivially exist, but we don't want it - none of our jailed BEs
will have jid=0.

MFC after:	3 days
2019-06-02 14:05:51 +00:00
Mark Johnston
8e9105dbae acpi_dock(4): Notify devd(8) on dock status change.
PR:		238138
Submitted by:	Muhammad Kaisar Arkhan <hi@yukiisbo.red>
MFC after:	2 weeks
2019-05-31 15:44:33 +00:00
Kyle Evans
515fa27bb0 bectl(8): Address Coverity complaints
CID 1400451: case 0 is missing a break/return and falling through to the
default case.  waitpid(0, ...) makes little sense in the child, we likely
wanted to terminate immediately.

CID 1400453: size argument uses sizeof(char **) instead of sizeof(char *)
and is assigned to a char **; sizeof's match but "this isn't a portable
assumption".

CID:	1400451, 1400453
MFC after:	3 days
2019-05-28 16:12:16 +00:00
Andrey V. Elsukov
09899450ed Remove unused token that was added in r348235.
MFC after:	2 weeks
2019-05-27 06:34:36 +00:00
Andrey V. Elsukov
05ab1ef64e Add missing and or-flush options to "ipfw table <NAME> create"
command to simplify firewall reloading.

The `missing` option suppresses EEXIST error code, but does check that
existing table has the same parameters as new one. The `or-flush` option
implies `missing` option and additionally does flush for table if it
is already exist.

Submitted by:	lev
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D18339
2019-05-24 11:06:24 +00:00
Kyle Evans
22554a341e bectl(8): Add a test for jail/unjail of numeric BE names
Fixed by r348215, bectl ujail first attempts the trivial fetch of a jid by
passing the first argument to 'ujail' to jail_getid(3) in case a jid/name
have been passed in instead of a BE name. For numerically named BEs, this
was doing the wrong thing: instead of failing to locate the jid specified
and falling back to mountpath search, jail_getid(3) would return the input
as-is.

While here, I've fixed bectl_jail_cleanup which still used a hard-coded pool
name that was overlooked w.r.t. other work that was in-flight around the
same time.

MFC after:	3 days
2019-05-24 01:53:45 +00:00
Conrad Meyer
8298529226 EKCD: Add Chacha20 encryption mode
Add Chacha20 mode to Encrypted Kernel Crash Dumps.

Chacha20 does not require messages to be multiples of block size, so it is
valid to use the cipher on non-block-sized messages without the explicit
padding AES-CBC would require.  Therefore, allow use with simultaneous dump
compression.  (Continue to disallow use of AES-CBC EKCD with compression.)

dumpon(8) gains a -C cipher flag to select between chacha and aes-cbc.
It defaults to chacha if no -C option is provided.  The man page documents this
behavior.

Relnotes:	sure
Sponsored by:	Dell EMC Isilon
2019-05-23 20:12:24 +00:00
Kyle Evans
55ece394c2 bectl(8): add description for create subcommand
In commit r345845, a portion of documentation for the create subcommand was
removed. Specifically, for creating a snapshot of an existing boot
environment. bectl even has a test-case for this functionality.

Removing the sub-command description was discussed in PR 235850.

This patch brings back the second "create" description that was originally
in place. Albeit, with a few wording/clarifying changes.

Submitted by:	Rob Fairbanks <rob.fx907 gmail com>
Reviewed by:	kevans
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D20249
2019-05-22 23:07:40 +00:00
Mark Johnston
48faa24b09 Update the example added in r348082 to specify a dump device priority.
Event:	Waterloo Hackathon 2019
2019-05-22 03:52:39 +00:00
Mark Johnston
73cc16949a Provide an example of using dhclient-script(5) to configure netdump.
Reviewed by:	cem
MFC after:	1 week
Event:		Waterloo Hackathon 2019
Differential Revision:	https://reviews.freebsd.org/D20345
2019-05-22 03:49:38 +00:00
Kirk McKusick
bfc5d3f9c2 This revision began as a simple change to eliminate an uninitialized warning
found by Coverity. However, upon closer inspection the implementation of
fsck_ffs's fsck_readdir() and dircheck() functions is both nearly impossible
to follow and fails to check / fix directories in several cases. So, this
revision is an entire rewrite of these two functions to clarify what they
are doing and also to get something that works properly.

Referred by:  cem
Reviewed by:  kib, David G Lawrence
MFC after:    3 days
CID 1401317:  namlen may be used uninitialized
2019-05-21 22:24:38 +00:00
Brooks Davis
ffda67901e Change ed(4), ep(4), and fxp(4) examples to em(4).
ed(4) and ep(4) have been removed. fxp(4) remains popular in older
systems, but isn't as future proof as em(4).

Reviewed by:	bz, jhb
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D20311
2019-05-18 21:01:36 +00:00
Conrad Meyer
276b25f172 Add DragonFly's partition number to fdisk(8) and diskmbr.h
This change doesn't make any attempt to add support for these slices to the
relevent GEOM classes.  Just register the number in fdisk and the canonical
list of kernel macros (diskmbr.h).

Obtained from:	DragonFlyBSD (794d80aa519b394b3174f20776a) (small subset of)
2019-05-18 00:22:28 +00:00
Scott Long
8212cecdde Better formatting for the logpage section 2019-05-17 18:15:47 +00:00
Kyle Evans
6a68e95de8 ifconfig(8): Add kld mappings for ipsec/enc
Additionally, providing mappings makes the comparison for already loaded
modules a little more strict. This should have been done at initial
introduction, but there was no real reason- however, it proves necessary for
enc which has a standard enc -> if_enc mapping but there also exists an
'enc' module that's actually CAM. The mapping lets us unambiguously
determine the correct module.

Discussed with:	ae
MFC after:	4 days
2019-05-10 13:18:22 +00:00
Kyle Evans
56f76a10c6 ifconfig(8): Partial revert of r347241
r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet
can autoload the correct module on use. It also inadvertently made bogus
some previously valid uses of sizeof().

Revert back to ifkind on the stack for simplicity sake. This reduces the
diff from the previous version of ifmaybeload for easiser auditing.
2019-05-09 12:58:33 +00:00
Kyle Evans
251a32b5b2 tun/tap: merge and rename to tuntap
tun(4) and tap(4) share the same general management interface and have a lot
in common. Bugs exist in tap(4) that have been fixed in tun(4), and
vice-versa. Let's reduce the maintenance requirements by merging them
together and using flags to differentiate between the three interface types
(tun, tap, vmnet).

This fixes a couple of tap(4)/vmnet(4) issues right out of the gate:
- tap devices may no longer be destroyed while they're open [0]
- VIMAGE issues already addressed in tun by kp

[0] emaste had removed an easy-panic-button in r240938 due to devdrn
blocking. A naive glance over this leads me to believe that this isn't quite
complete -- destroy_devl will only block while executing d_* functions, but
doesn't block the device from being destroyed while a process has it open.
The latter is the intent of the condvar in tun, so this is "fixed" (for
certain definitions of the word -- it wasn't really broken in tap, it just
wasn't quite ideal).

ifconfig(8) also grew the ability to map an interface name to a kld, so
that `ifconfig {tun,tap}0` can continue to autoload the correct module, and
`ifconfig vmnet0 create` will now autoload the correct module. This is a
low overhead addition.

(MFC commentary)

This may get MFC'd if many bugs in tun(4)/tap(4) are discovered after this,
and how critical they are. Changes after this are likely easily MFC'd
without taking this merge, but the merge will be easier.

I have no plans to do this MFC as of now.

Reviewed by:	bcr (manpages), tuexen (testing, syzkaller/packetdrill)
Input also from:	melifaro
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D20044
2019-05-08 02:32:11 +00:00
Conrad Meyer
6b6e2954dd List-ify kernel dump device configuration
Allow users to specify multiple dump configurations in a prioritized list.
This enables fallback to secondary device(s) if primary dump fails.  E.g.,
one might configure a preference for netdump, but fallback to disk dump as a
second choice if netdump is unavailable.

This change does not list-ify netdump configuration, which is tracked
separately from ordinary disk dumps internally; only one netdump
configuration can be made at a time, for now.  It also does not implement
IPv6 netdump.

savecore(8) is already capable of scanning and iterating multiple devices
from /etc/fstab or passed on the command line.

This change doesn't update the rc or loader variables 'dumpdev' in any way;
it can still be set to configure a single dump device, and rc.d/savecore
still uses it as a single device.  Only dumpon(8) is updated to be able to
configure the more complicated configurations for now.

As part of revving the ABI, unify netdump and disk dump configuration ioctl
/ structure, and leave room for ipv6 netdump as a future possibility.
Backwards-compatibility ioctls are added to smooth ABI transition,
especially for developers who may not keep kernel and userspace perfectly
synced.

Reviewed by:	markj, scottl (earlier version)
Relnotes:	maybe
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D19996
2019-05-06 18:24:07 +00:00
Alexander Motin
1aed499575 Decode Deallocate Logical Block Features.
MFC after:	1 week
2019-05-05 15:47:21 +00:00
Kirk McKusick
0061238fb0 This update eliminates a kernel stack disclosure bug in UFS/FFS
directory entries that is caused by uninitialized directory entry
padding written to the disk. It can be viewed by any user with read
access to that directory. Up to 3 bytes of kernel stack are disclosed
per file entry, depending on the the amount of padding the kernel
needs to pad out the entry to a 32 bit boundry. The offset in the
kernel stack that is disclosed is a function of the filename size.
Furthermore, if the user can create files in a directory, this 3
byte window can be expanded 3 bytes at a time to a 254 byte window
with 75% of the data in that window exposed. The additional exposure
is done by removing the entry, creating a new entry with a 4-byte
longer name, extracting 3 more bytes by reading the directory, and
repeating until a 252 byte name is created.

This exploit works in part because the area of the kernel stack
that is being disclosed is in an area that typically doesn't change
that often (perhaps a few times a second on a lightly loaded system),
and these file creates and unlinks themselves don't overwrite the
area of kernel stack being disclosed.

It appears that this bug originated with the creation of the Fast
File System in 4.1b-BSD (Circa 1982, more than 36 years ago!), and
is likely present in every Unix or Unix-like system that uses
UFS/FFS. Amazingly, nobody noticed until now.

This update also adds the -z flag to fsck_ffs to have it scrub
the leaked information in the name padding of existing directories.
It only needs to be run once on each UFS/FFS filesystem after a
patched kernel is installed and running.

Submitted by: David G. Lawrence <dg@dglawrence.com>
Reviewed by:  kib
MFC after:    1 week
2019-05-03 21:54:14 +00:00
Andrew Gallatin
35961dce98 Select lacp egress ports based on NUMA domain
This change creates an array of port maps indexed by numa domain
for lacp port selection. If we have lacp interfaces in more than
one domain, then we select the egress port by indexing into the
numa port maps and picking a port on the appropriate numa domain.

This is behavior is controlled by the new ifconfig use_numa flag
and net.link.lagg.use_numa sysctl/tunable (both modeled after the
existing use_flowid), which default to enabled.

Reviewed by:	bz, hselasky, markj (and scottl, earlier version)
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D20060
2019-05-03 14:43:21 +00:00
Ian Lepore
be1ef9be42 Update the manpage text to show the output generated by the first-stage
bootloader these days (x86 instead of i386).
2019-04-30 17:42:05 +00:00
Andrey V. Elsukov
761618de05 Handle HAVE_PROTO flag and print "proto" keyword for O_IP4 and O_IP6
opcodes when it is needed.
This should fix the problem, when printed by `ipfw show` rule could not
be added due to missing "proto" keyword.

MFC after:	2 weeks
2019-04-29 09:52:53 +00:00
Andrey V. Elsukov
aee793eec9 Add GRE-in-UDP encapsulation support as defined in RFC8086.
This GRE-in-UDP encapsulation allows the UDP source port field to be
used as an entropy field for load-balancing of GRE traffic in transit
networks. Also most of multiqueue network cards are able distribute
incoming UDP datagrams to different NIC queues, while very little are
able do this for GRE packets.

When an administrator enables UDP encapsulation with command
`ifconfig gre0 udpencap`, the driver creates kernel socket, that binds
to tunnel source address and after udp_set_kernel_tunneling() starts
receiving of all UDP packets destined to 4754 port. Each kernel socket
maintains list of tunnels with different destination addresses. Thus
when several tunnels use the same source address, they all handled by
single socket.  The IP[V6]_BINDANY socket option is used to be able bind
socket to source address even if it is not yet available in the system.
This may happen on system boot, when gre(4) interface is created before
source address become available. The encapsulation and sending of packets
is done directly from gre(4) into ip[6]_output() without using sockets.

Reviewed by:	eugen
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D19921
2019-04-24 09:05:45 +00:00
Steven Hartland
3bed0179ee Add ATA power mode support to camcontrol
Add the ability to report ATA device power mode with the cmmand 'powermode'
to compliment the existing ability to set it using idle, standby and sleep
commands.

MFC after:	2 weeks
Sponsored by:	Multiplay
2019-04-23 07:46:38 +00:00
Benedict Reuschling
da343996fa Typo fix in ipfw.8: amd -> and
There is an (obvious) typo in the following sentence:

"Please note, that keep-state amd limit imply implicit check-state for ..."

Replace the "amd" with "and", bump .Dd.

PR:			237438
Submitted by:		michael@galassi.us
MFC after:		3 days
2019-04-21 18:27:13 +00:00
Kristof Provost
7296d6c9bf pfctl: Fix ifgroup check
We cannot just assume that any name which ends with a letter is a group
That's not been true since we allowed renaming of network interfaces. It's also
not true for things like epair0a.

Try to retrieve the group members for the name to check, since we'll get ENOENT
if the group doesn't exist.

MFC after:	1 week
Event:		Aberdeen hackathon 2019
2019-04-19 10:52:54 +00:00
Poul-Henning Kamp
5ddaf8458e Close filedescriptors when done with them. 2019-04-19 06:49:46 +00:00
Ed Maste
d76eef3430 cap_fileargs: chase r346315, update fileargs_init in consumers
Reported by:	ci.freebsd.org (8 times so far)
MFC after:	3 weeks
MFC with:	r346315
Sponsored by:	The FreeBSD Foundation
2019-04-17 16:18:14 +00:00
Xin LI
dad02d7d08 Don't cast result from malloc().
MFC after:	2 weeks
2019-04-15 06:33:05 +00:00
Kirk McKusick
d483391306 Followup to -r344552 in which fsck_ffs checks for a size past the
last allocated block of the file and if that is found, shortens the
file to reference the last allocated block thus avoiding having it
reference a hole at its end.

This update corrects an error where fsck_ffs miscalculated the last
logical block of the file when the file contained a large hole.

Reported by:  Jamie Landeg-Jones
Tested by:    Peter Holm
MFC after:    2 weeks
Sponsored by: Netflix
2019-04-13 13:31:06 +00:00
Ilya Bakulin
0660cfa0c4 Add new fields to mmc_data in preparation to SDIO CMD53 block mode support
SDIO command CMD53 (IO_RW_EXTENDED) allows data transfers using blocks of 1-2048 bytes,
with a maximum of 511 blocks per request.
Extend mmc_data structure to properly describe such requests,
and initialize the new fields in kernel and userland consumers.

No actual driver changes happen yet, these will follow in the separate changes.

Reviewed by:	bz
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D19779
2019-04-10 19:49:35 +00:00
Konstantin Belousov
7bead17ddc Exercise some care before sending SIGHUP to mountd.
Reviewed by:	antoine, emaste, oshogbo
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D19847
2019-04-08 18:16:49 +00:00
Xin LI
0e6eb62d96 Write string constant differently to improve readability.
Reported by:	rgrimes
Reviewed by:	rgrimes, emaste
MFC after:	13 days
Differential Revision:	https://reviews.freebsd.org/D19829
2019-04-06 03:42:15 +00:00
Xin LI
d325f3c243 Fix build.
MFC after:	2 weeks
X-MFC-With:	r345900
2019-04-05 02:37:10 +00:00
Xin LI
d78b6f1ee8 Implement checking of .' and ..' entries of subdirectory.
Reviewed by:		pfg
Obtained from:		Android b6ee08aadb%5E%21/
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D19824
2019-04-05 02:21:16 +00:00
Xin LI
fbf8a5605f Restore lfcl when LOSTDIR's chain was corrupted and overwritten
with invalid value.

Obtained from:	Android 4d6d6f8a36%5E%21/
MFC after:	2 weeks
2019-04-04 23:34:03 +00:00
Xin LI
2bf0ee64f9 Restore the ability of checking and fixing next free
cluster in FSINFO that was lost in r203872.

Obtained from:	NetBSD
MFC after:	2 weeks
2019-04-04 23:16:36 +00:00
Mateusz Piotrowski
2b9dde098f bectl.8: Bump date after r345845
Approved by:	kevans
2019-04-03 13:59:35 +00:00
Mateusz Piotrowski
77688bff1e bectl.8: Clean up & clarify the create subcommand
- Improve formatting
- Use consistent variable names
- Improve the description of the create subcommand (1)

PR:		235850 (1)
Submitted by:	kevans (1)
Reported by:	ler (1)
Reviewed by:	kevans
Approved by:	src (kevans)
Differential Revision:	https://reviews.freebsd.org/D19666
2019-04-03 13:46:43 +00:00
Xin LI
f806eb62a4 Assert that q can't be NULL. 'empty' is always non-NULL when DIREMPTY
is set earlier.

MFC after:	1 month
2019-04-03 07:09:28 +00:00
Kyle Evans
e1ee62302a libbe: Fix zfs_is_mounted check w/ snapshots
'be_destroy' can destroy a boot environment (by name) or a given snapshot.
If the target to be destroyed is a dataset, check if it's mounted. We don't
want to check if the origin dataset is mounted when destroying a snapshot.

PR:		236043
Submitted by:	Rob Fairbanks <rob.fx907 gmail com>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D19650
2019-04-01 17:44:20 +00:00
Pawel Jakub Dawidek
e6b0d5eb9f Introduce new event SIZECHANGE within GEOM system to inform about GEOM
providers mediasize changes.

While here, use GEOM nomenclature to describe providers instead of calling
them device nodes.

Obtained from:	Fudo Security
Tested in:	AWS
2019-03-30 07:24:34 +00:00
Xin LI
9ace37176e Distinguish between lseek errors and read errores.
MFC after:	2 weeks
2019-03-28 18:20:47 +00:00
Ed Maste
98b1cf29cf init: pedantic correction to "can't exec" script warning
Direct /etc/rc exec was introduced in r337321, with a fallback to
passing it to sh if direct exec fails.  "Can't exec" is slightly
misleading in this case (the script is still executed, just not
directly).
2019-03-26 19:38:25 +00:00
Warner Losh
3ace9199b4 Make WD and WDC aliases for HGST.
HGST was bought by WDC. Over the years, it has sold different drives
branded as HGST, WD or WDC. All of them need the HGST workaround of
sending 4k-sized packets (or multiples of 4k). And the ones that don't
really need this aren't broken by this change. Submitter is the vendor
who has tested these changes on a number of drives. I've simplified it
slightly, since we don't need additional vendors for this at this
time.

Submitted by: JacobBurley via github on behalf of WDC
Pull Request: https://github.com/freebsd/freebsd/pull/391
2019-03-21 06:27:58 +00:00
Alan Somers
123af6ec70 Rename fuse(4) to fusefs(4)
This makes it more consistent with other filesystems, which all end in "fs",
and more consistent with its mount helper, which is already named
"mount_fusefs".

Reviewed by:	cem, rgrimes
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19649
2019-03-20 21:48:43 +00:00
Kyle Evans
938b7a44d9 bectl(8): change jail command to execute jail(8)
The jail(8) command provides a variety of jail pseudo-parameters that are
useful to consumers of bectl, mount.devfs being the most-often-requested
paramater by bectl users.

command, exec.start, nopersist, and persist may not be specified via -o to
bectl. The command/exec.start remains passed as it always has at the end of
bectl, and persistence is dictated by -b/-U bectl jail arguments.

Submitted by:	Wes Maag <jwmaag gmail com>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D19282
2019-03-19 17:38:54 +00:00
Andrey V. Elsukov
9883abca1f Remove extra spaces.
MFC after:	1 month
2019-03-19 11:16:42 +00:00
Andrey V. Elsukov
d18c1f26a4 Reapply r345274 with build fixes for 32-bit architectures.
Update NAT64LSN implementation:

  o most of data structures and relations were modified to be able support
    large number of translation states. Now each supported protocol can
    use full ports range. Ports groups now are belongs to IPv4 alias
    addresses, not hosts. Each ports group can keep several states chunks.
    This is controlled with new `states_chunks` config option. States
    chunks allow to have several translation states for single alias address
    and port, but for different destination addresses.
  o by default all hash tables now use jenkins hash.
  o ConcurrencyKit and epoch(9) is used to make NAT64LSN lockless on fast path.
  o one NAT64LSN instance now can be used to handle several IPv6 prefixes,
    special prefix "::" value should be used for this purpose when instance
    is created.
  o due to modified internal data structures relations, the socket opcode
    that does states listing was changed.

Obtained from:	Yandex LLC
MFC after:	1 month
Sponsored by:	Yandex LLC
2019-03-19 10:57:03 +00:00
Andrey V. Elsukov
d6369c2d18 Revert r345274. It appears that not all 32-bit architectures have
necessary CK primitives.
2019-03-18 14:00:19 +00:00
Andrey V. Elsukov
d7a1cf06f3 Update NAT64LSN implementation:
o most of data structures and relations were modified to be able support
  large number of translation states. Now each supported protocol can
  use full ports range. Ports groups now are belongs to IPv4 alias
  addresses, not hosts. Each ports group can keep several states chunks.
  This is controlled with new `states_chunks` config option. States
  chunks allow to have several translation states for single alias address
  and port, but for different destination addresses.
o by default all hash tables now use jenkins hash.
o ConcurrencyKit and epoch(9) is used to make NAT64LSN lockless on fast path.
o one NAT64LSN instance now can be used to handle several IPv6 prefixes,
  special prefix "::" value should be used for this purpose when instance
  is created.
o due to modified internal data structures relations, the socket opcode
  that does states listing was changed.

Obtained from:	Yandex LLC
MFC after:	1 month
Sponsored by:	Yandex LLC
2019-03-18 12:59:08 +00:00
Andrey V. Elsukov
5c04f73e07 Add NAT64 CLAT implementation as defined in RFC6877.
CLAT is customer-side translator that algorithmically translates 1:1
private IPv4 addresses to global IPv6 addresses, and vice versa.
It is implemented as part of ipfw_nat64 kernel module. When module
is loaded or compiled into the kernel, it registers "nat64clat" external
action. External action named instance can be created using `create`
command and then used in ipfw rules. The create command accepts two
IPv6 prefixes `plat_prefix` and `clat_prefix`. If plat_prefix is ommitted,
IPv6 NAT64 Well-Known prefix 64:ff9b::/96 will be used.

  # ipfw nat64clat CLAT create clat_prefix SRC_PFX plat_prefix DST_PFX
  # ipfw add nat64clat CLAT ip4 from IPv4_PFX to any out
  # ipfw add nat64clat CLAT ip6 from DST_PFX to SRC_PFX in

Obtained from:	Yandex LLC
Submitted by:	Boris N. Lytochkin
MFC after:	1 month
Relnotes:	yes
Sponsored by:	Yandex LLC
2019-03-18 11:44:53 +00:00
Andrey V. Elsukov
002cae78da Add SPDX-License-Identifier and update year in copyright.
MFC after:	1 month
2019-03-18 10:50:32 +00:00
Andrey V. Elsukov
b11efc1eb6 Modify struct nat64_config.
Add second IPv6 prefix to generic config structure and rename another
fields to conform to RFC6877. Now it contains two prefixes and length:
PLAT is provider-side translator that translates N:1 global IPv6 addresses
to global IPv4 addresses. CLAT is customer-side translator (XLAT) that
algorithmically translates 1:1 IPv4 addresses to global IPv6 addresses.
Use PLAT prefix in stateless (nat64stl) and stateful (nat64lsn)
translators.

Modify nat64_extract_ip4() and nat64_embed_ip4() functions to accept
prefix length and use plat_plen to specify prefix length.

Retire net.inet.ip.fw.nat64_allow_private sysctl variable.
Add NAT64_ALLOW_PRIVATE flag and use "allow_private" config option to
configure this ability separately for each NAT64 instance.

Obtained from:	Yandex LLC
MFC after:	1 month
Sponsored by:	Yandex LLC
2019-03-18 10:39:14 +00:00
Mateusz Piotrowski
bf43c6d1fc camcontrol.8: Bump date after r345051
Reviewed by:	bcr
Approved by:	bcr (doc)
Approved by:	krion (mentor, implicit), mat (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D19555
2019-03-12 09:43:11 +00:00
Warner Losh
b9dd559a32 Add -l to camcontrol readcap.
The -l flag sends only the READ CAPACITY (16) sevice action. Normally
we send the READ CAPACITY (10) command, and only send RC16 when the
capacity is larger than 2TB (since that's the max RC10 can
report). However, some badly programmed drives report different
numbers for RC10 and RC16. This can be hard to diagnose, but generally
there's a "Logical block address out of range" error when RC16 reports
a larger number than RC10 and the RC10 number is the correct one. By
comparing the output of readcap with and without the -l argmuent, one
can determine if there's a mismatch and if the DA_Q_NO_RC16 quirk is
needed.

Reviewed by: ken@
Differential Revision: https://reviews.freebsd.org/D19536
2019-03-12 04:57:05 +00:00
Wolfram Schneider
e7ff892f3f explain ``fsck -f'' more in detail
PR:	223491
Approved by: mckusick, 0mp, imp
Differential Revision:	https://reviews.freebsd.org/D19437
2019-03-08 10:03:16 +00:00
Bjoern A. Zeeb
21231a7aa6 Update for IETF draft-ietf-6man-ipv6only-flag.
All changes are hidden behind the EXPERIMENTAL option and are not compiled
in by default.

Add ND6_IFF_IPV6_ONLY_MANUAL to be able to set the interface into no-IPv4-mode
manually without router advertisement options.  This will allow developers to
test software for the appropriate behaviour even on dual-stack networks or
IPv6-Only networks without the option being set in RA messages.
Update ifconfig to allow setting and displaying the flag.

Update the checks for the filters to check for either the automatic or the manual
flag to be set.  Add REVARP to the list of filtered IPv4-related protocols and add
an input filter similar to the output filter.

Add a check, when receiving the IPv6-Only RA flag to see if the receiving
interface has any IPv4 configured.  If it does, ignore the IPv6-Only flag.

Add a per-VNET global sysctl, which is on by default, to not process the automatic
RA IPv6-Only flag.  This way an administrator (if this is compiled in) has control
over the behaviour in case the node still relies on IPv4.
2019-03-06 23:31:42 +00:00
John Baldwin
2e43efd0bb Drop "All rights reserved" from my copyright statements.
Reviewed by:	rgrimes
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D19485
2019-03-06 22:11:45 +00:00
Andriy Voskoboinyk
38979c4b45 Allow to build ifconfig(8) without wireless support
The change removes SIOC[GS]IEEE80211 handling from ifconfig(8)
if WITHOUT_WIRELESS_SUPPORT=yes is set in src.conf(5).

Reviewed by:	bz
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D19289
2019-03-04 03:47:06 +00:00
Kirk McKusick
72ef1cb896 Properly calculate the last used logical block of a file when checking
inodes that reference directories. While here tighten the check for
comparing the last logical block with the end of the file.

Reported by:  Peter Holm
Tested by:    Peter Holm
Sponsored by: Netflix
2019-03-02 21:30:01 +00:00
Kirk McKusick
886e9f061c The size of the UFS soft-updates journal must be a multiple of the
filesystem block size. When a size is specified with the -S flag
to tunefs(8), round it up to the filesystem block size.

Reported by:  Peter Holm
Tested by:    Peter Holm
Sponsored by: Netflix
2019-03-02 21:22:56 +00:00
Guangyuan Yang
65847dc90a Fix typos and caps for ipfw(8) man page.
MFC after:	3 days
PR:		236030
Submitted by:	olgeni
2019-03-01 19:06:13 +00:00
Steven Hartland
c092a1dbc3 Fix incorrect / unused sector_count for identify requests
Fix incorrect / unused sector_count for identify requests from camcontrol.

Submitted by:	Alexey Dokuchaev
Reported by:	Alexey Dokuchaev
MFC after:	1 week
Sponsored by:	Multiplay
Differential Revision:	https://reviews.freebsd.org/D19408
2019-03-01 14:39:15 +00:00
Tom Rhodes
bdf56516d2 Grammar tweaks in ipfw manual page. 2019-02-28 20:43:03 +00:00
Warner Losh
e96f6eda1b Add SPDX tag. 2019-02-28 02:29:48 +00:00
Simon J. Gerraty
eb12b8ea5e Add verifying manifest loader for mac_veriexec
This tool will verify a signed manifest and load contents into
mac_veriexec for storage

Sponsored by:	Juniper Networks
Differential Revision:	D16575
2019-02-26 06:17:23 +00:00
Alan Somers
d309dcbcd3 ifconfig: eliminate trailing whitespace
Eliminate trailing whitespace on inet, inet6, and groups lines. I think the
"list txpower" command will still show some, but I'm not able to test that.

PR: 153731
Reported-by: Nikolay Denev <ndenev@gmail.com>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19004
2019-02-26 03:34:47 +00:00
Kirk McKusick
ac4b20a0a7 After a crash, a file that extends into indirect blocks may end up
shorter than its size resulting in a hole as its final block (which
is a violation of the invarients of the UFS filesystem).

Soft updates will always ensure that the file size is correct when
writing inodes to disk for files that contain only direct block
pointers. However soft updates does not roll back sizes for files
with indirect blocks that it has set to unallocated because their
contents have not yet been written to disk. Hence, the file can
appear to have a hole at its end because the block pointer has been
rolled back to zero when its inode was written to disk. Thus,
fsck_ffs calculates the last allocated block in the file. For files
that extend into indirect blocks, fsck_ffs checks for a size past
the last allocated block of the file and if that is found, shortens
the file to reference the last allocated block thus avoiding having
it reference a hole at its end.

Submitted by: Chuck Silvers <chs@netflix.com>
Tested by:    Chuck Silvers <chs@netflix.com>
MFC after:    1 week
Sponsored by: Netflix
2019-02-25 21:58:19 +00:00
Vladimir Kondratyev
f99e7b1aed evdev: export event device properties through sysctl interface
A big security advantage of Wayland is not allowing applications to read
input devices all the time. Having /dev/input/* accessible to the user
account subverts this advantage.

libudev-devd was opening the evdev devices to detect their types (mouse,
keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible.
With the kernel exposing this information as sysctls (kern.evdev.input.*),
we can work w/o /dev/input/* access, preserving the Wayland security model.

Submitted by:		Greg V <greg@unrelenting.technology>
Reviewed by:		wulf, imp
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D18694
2019-02-24 18:47:04 +00:00
Maxim Sobolev
221e5d2dd5 Further refine r336195: do not even attempt to verify/update interface's
MTU if we've set it once and there were no changes on the DHCP server
side since the last refresh. This is consistent I believe with how dhclient
handles other settings like IP address, mask etc.

Approved by:	cem, eugen
Differential Revision:	https://reviews.freebsd.org/D18546
2019-02-23 23:31:13 +00:00
Warner Losh
f428a90ad9 Rework logpage extensibility.
Move from using a linker set to a constructor function that's
called. This simplifies the code and is slightly more obvious.  We now
keep a list of page decoders rather than having an array we managed
before. Commands will move to something similar in the future.

Reviewed by: jhb@
Differential Revision: https://reviews.freebsd.org/D19275
2019-02-22 15:15:36 +00:00
Kirk McKusick
7bcd1fab5a Ensure that inode updates are properly flushed out during the first
pass of fsck_ffs. Some changes, such as check-hash corrections were
being lost.

Reported by: Michael Tuexen (tuexen@)
Tested by:   Michael Tuexen (tuexen@)
MFC after:   3 days
2019-02-19 20:12:12 +00:00
Kyle Evans
c9b6ff9c98 mdmfs(8): use -o reserve with malloc-backed md(4)
Mentioned in mdconfig(8), malloc-backed md(4) can be unstable unless
required memory is allocated up front with -o reserve. Furthermore, panics
have been observed with md used in fstab on 12.0-RELEASE. Choose the stable
route and pass -o reserve.

Submitted by:	Paul Vixie
MFC after:	1 week
2019-02-16 23:57:38 +00:00
Warner Losh
95e310720d Remove write-only s_flag. 2019-02-16 00:15:02 +00:00
Enji Cooper
794022b04a Fix up concurrent test zpool setup and teardown
Set up zpools with a more unique name, stash the zpool name away in a file pointed
to by `$ZPOOL_NAME_FILE` (which is relative to a per-testcase generated temporary
directory), then remove the file based on `$ZPOOL_NAME_FILE` in the cleanup
routines.

This is a more concurrency-safe solution and will allow the testcases to be safely
executed in parallel.

Reviewed by:	kevans, jtl
Approved by:	jtl (mentor)
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D19024
2019-02-12 23:35:46 +00:00
Patrick Kelsey
997667302f Fix the fix added in r343287 for spurious HFSC bandwidth check errors
The logic added in r343287 to avoid false-positive
sum-of-child-bandwidth check errors for HFSC queues has a bug in it
that causes the upperlimit service curve of an HFSC queue to be pulled
down to its parent's linkshare service curve if it happens to be above
it.

Upon further inspection/reflection, this generic
sum-of-child-bandwidths check does not need to be fixed for HFSC - it
needs to be skipped.  For HFSC, the equivalent check is to ensure the
sum of child linkshare service curves are at or below the parent's
linkshare service curve, and this check is already being performed by
eval_pfqueue_hfsc().

This commit reverts the affected parts of r343287 and adds new logic
to skip the generic sum-of-child-bandwidths check for HFSC.

MFC after:	1 day
Sponsored by:	RG Nets
Differential Revision:	https://reviews.freebsd.org/D19124
2019-02-11 22:58:43 +00:00
Brooks Davis
f95509a489 mdmfs: Fix many bugs in automatic md(4) creation.
This code allocated a correctly sized buffer, read past the end of the
source buffer, writing off the end of the target buffer, and then writing
a '\0' terminator past the end of the target buffer (in the wrong place).
It then leaked the buffer.

Switch to a statically sized buffer on the stack and update the source
pointer and
length before use so the correct things are copied.

Fix a logic error in the checks that the format of the line is as
expected and move on out of an assert.

Remove an unneeded close(). fclose() closes the descriptor.

Found with:	CheriABI
Obtained from:	CheriBSD
Reviewed by:	kib, jhb, markj
Differential Revision:	https://reviews.freebsd.org/D19122
2019-02-11 21:31:26 +00:00
Kyle Evans
6286a6438e bectl(8): commit missing test modifications from r343993
X-MFC-With:	r343993
2019-02-11 04:00:42 +00:00
Kyle Evans
77b4126ce6 bectl(8): Add -o flag to destroy to clean up the origin snapshot of BE
We can't predict when destruction of origin is needed, and currently we have
a precedent for not prompting for things. Leave the decision up to the user
of bectl(8) if they want the origin snapshot to be destroyed or not.

Emits a warning when -o isn't used and an origin snapshot is left to be
cleaned up, for the time being. This is handy when one drops the -o flag but
really did want to clean up the origin.

A couple of -e ignore's have been sprinkled around the test suite for places
that we don't care that the origin's not been cleaned up. -o functionality
tests will be added in the future, but are omitted for now to reduce
conflicts with work in flight to fix bits of the tests.

Reported by:	Shawn Webb
MFC after:	1 week
2019-02-11 04:00:01 +00:00
Conrad Meyer
39f37df26e gbde(8) - simplify randomisation with arc4random_buf
Submitted by:	David CARLIER <devnexen AT gmail.com>
Differential Revision:	https://reviews.freebsd.org/D18678
2019-02-11 00:11:02 +00:00
Andriy Voskoboinyk
2a0f9d5416 ifconfig(8): display 802.11n rates correctly for 'roam:rate' parameter
MFC after:	5 days
2019-02-10 21:32:39 +00:00
Kristof Provost
4c8fb952b5 pfctl: Fix ifa_grouplookup()
Setting the length of the request got lost in r343287, which means SIOCGIFGMEMB
gives us the required length, but does not copy the names of the group members.
As a result we don't get a correct list of group members, and 'set skip on
<ifgroup>' broke.

This produced all sorts of very unexpected results, because we would end up
applying 'set skip' to unexpected interfaces.

X-MFC-with:	r343287
2019-02-10 21:22:55 +00:00
Guangyuan Yang
c68d0f8b3d Remove -R option which was added to sysctl(8) man page per r244106, but it is not implemented.
MFC after:	3 days
Submitted by:	Alfonso Siciliano <alfix86@gmail.com>
Reviewed by:	0mp, imp
Differential Revision: 	https://reviews.freebsd.org/D19012
2019-02-09 04:36:02 +00:00
Jilles Tjoelker
3b08e0fcf3 dhclient: Return non-zero status when script exits due to a signal
r343896 made it such that a non-zero exit status was passed through, but was
still wrong if the script exits on a signal. POSIX does not say what the
WEXITSTATUS macro returns in this case and in practice 0 is a common value.

Instead, translate the wait status into 8 bits the same way as the shell
calculates $?.

Reviewed by:	kib, Nash Kaminski
MFC after:	1 week
2019-02-08 23:03:28 +00:00
Konstantin Belousov
95f237c2f6 Correctly return exit status from the exited process.
This is also OpenBSD rev. 1.117, as pointed out by
Ryan Moeller <ryan@ixsystems.com>.

Submitted by:	Nash Kaminski <nashkaminski@gmail.com>
MFC after:	1 week
2019-02-08 07:36:08 +00:00
Bryan Drewery
10e3bebf9e Fix build of r343877
MFC after:	2 weeks
X-MFC-with:	r343877
Pointyhat to:	bdrewery
2019-02-07 21:41:27 +00:00
Bryan Drewery
2b3d664738 ipfw table list: Fix showing header outside of 'all'.
Properly pass down is_all to table_show_list().  This restores the behavior
before r272840 so that only 'ipfw table all list' shows the headers.

MFC after:	2 weeks
Relnotes:	yes
2019-02-07 21:05:44 +00:00
Andriy Voskoboinyk
ec835c9dec recoverdisk(1): fclose() file supplied via '-r readlist' parameter when
it's no longer needed

PR:		204952
Reported by:	David Binderman <dcb314@hotmail.com>
MFC after:	5 days
2019-02-07 14:40:28 +00:00
Warner Losh
52467047aa Regularize the Netflix copyright
Use recent best practices for Copyright form at the top of
the license:
1. Remove all the All Rights Reserved clauses on our stuff. Where we
   piggybacked others, use a separate line to make things clear.
2. Use "Netflix, Inc." everywhere.
3. Use a single line for the copyright for grep friendliness.
4. Use date ranges in all places for our stuff.

Approved by: Netflix Legal (who gave me the form), adrian@ (pmc files)
2019-02-04 21:28:25 +00:00
Andriy Voskoboinyk
b90dad3524 ifconfig(8): actually, non-11n rates should be divided by 2...
MFC after:	1 week
MFC with:	343698
2019-02-03 04:41:00 +00:00