]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoRemove tests for obsolete compilers in the build system
Eric van Gyzen [Tue, 12 May 2020 15:22:40 +0000 (15:22 +0000)]
Remove tests for obsolete compilers in the build system

Assume gcc is at least 6.4, the oldest xtoolchain in the ports tree.
Assume clang is at least 6, which was in 11.2-RELEASE.  Drop conditions
for older compilers.

Reviewed by: imp (earlier version), emaste, jhb
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D24802

(cherry picked from commit fac6dee9eb58b2b558fec2aea749460ca623f6d6)

2 years agogcc9: quiet Waddress-of-packed-member for user build
Ryan Libby [Sat, 21 Dec 2019 02:43:49 +0000 (02:43 +0000)]
gcc9: quiet Waddress-of-packed-member for user build

Disable the warning for WARNS <= 3.  This is lame, but it's what we
already do for the clang build.

Reviewed by: dim
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22889

(cherry picked from commit fc41af14c8298c88d5a2bee85ecf1864a3d37a51)

2 years agoRemove obsolete, non-use of CLANG_NO_IAS.
Brooks Davis [Fri, 18 Oct 2019 00:00:17 +0000 (00:00 +0000)]
Remove obsolete, non-use of CLANG_NO_IAS.

CLANG_NO_IAS was removed in r351661.

(cherry picked from commit a1d5358777feafeb3b0bf977e018c9545f5315f7)

2 years agoRemove CLANG_NO_IAS definition
Ed Maste [Sun, 1 Sep 2019 16:47:48 +0000 (16:47 +0000)]
Remove CLANG_NO_IAS definition

CLANG_NO_IAS is not used anywhere in the tree.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6c30aa54c3f580b72a5171b69bc541fba31831b8)

2 years agogptzfsboot: remove CLANG_NO_IAS
Ed Maste [Thu, 15 Aug 2019 18:43:01 +0000 (18:43 +0000)]
gptzfsboot: remove CLANG_NO_IAS

Many components under stand/ had CLANG_NO_IAS added when Clang's
Integrated Assembler did not handle .codeNN directives.  Clang gained
support quite some time ago, so we can build stand/ with IAS.

In some cases there were small differences in generated object output.
In the case of gptzfsboot however using GNU as or Clang IAS to assemble
gptldr.S resulted in identical final gptzfsboot binary output.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D11115

(cherry picked from commit 0a062e5ff6522fa7bac1c2e9c9f686eb55ca998c)

2 years agostand: remove CLANG_NO_IAS from pxeldr
Ed Maste [Thu, 15 Aug 2019 17:59:22 +0000 (17:59 +0000)]
stand: remove CLANG_NO_IAS from pxeldr

Many components under stand/ had CLANG_NO_IAS added when Clang's
Integrated Assembler (IAS) did not handle .codeNN directives.  Clang
gained support quite some time ago, and we can now build stand/ with
IAS.  In most cases IAS- and GNU as-assembled boot components were
identical, and CLANG_NO_IAS was already removed from other components.

Clang IAS produces different output for some components, including
pxeldr, so CLANG_NO_IAS was not previously removed for those.

In the case of pxeldr the difference is that IAS adds a size override
prefix (67h) to three instructions to specify a 32-bit address, even
though the two high bytes are zero and the address fits in 16 bits.
this wastes three bytes per instruction and causes some additional nop
npadding to be required elsewhere in the object, but pxeboot is not
size-constrained so it doesn't matter.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit aa2dd958b489d590be9573f1bd05ec5b8a12f016)

2 years agostand: remove CLANG_NO_IAS from cdboot
Ed Maste [Thu, 15 Aug 2019 17:32:39 +0000 (17:32 +0000)]
stand: remove CLANG_NO_IAS from cdboot

Many components under stand/ had CLANG_NO_IAS added when Clang's
Integrated Assembler (IAS) did not handle .codeNN directives.  Clang
gained support quite some time ago, and we can now build stand/ with
IAS.  In most cases IAS- and GNU as-assembled boot components were
identical, and CLANG_NO_IAS was already removed from other components.

Clang IAS produces different output for some components, including
cdboot, so CLANG_NO_IAS was not previously removed for those.

In the case of cdboot the difference is that IAS adds a size override
prefix (67h) to many instructions to specify a 32-bit address, even
though the two high bytes are zero.  This wastes three bytes per
instance, but as cdboot is not size-constrained it doesn't matter.
Padding is also different in one case; Clang used two one-byte nops
while GNU as used a single two-byte xchg %eax, %eax.  In any case, there
is no functional change.

Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 1596e9a43cbfef904232a3321136e2ae480565f9)

2 years agostand: remove CLANG_NO_IAS from boot2
Ed Maste [Thu, 15 Aug 2019 14:54:18 +0000 (14:54 +0000)]
stand: remove CLANG_NO_IAS from boot2

Many components under stand/ had CLANG_NO_IAS added when Clang's
Integrated Assembler (IAS) did not handle .codeNN directives.  Clang
gained support quite some time ago, and we can now build stand/ with
IAS.  In most cases IAS- and GNU as-assembled boot components were
identical, and CLANG_NO_IAS was already removed from other components.

Clang IAS produces different output for some components, including
boot2, so CLANG_NO_IAS was not previously removed for those.

In the case of boot2 the difference is that IAS produces a larger
encoding for one instruction (the testb at the beginning of read).

GNU as produces:

    2e    f6 06 b0 08       80

while IAS includes an address size override prefix (67) and produces:

    2e 67 f6 05 b3 08 00 00 80

This results in three fewer NOPs elsewhere in boot2 but no functional
change, so switch to IAS for boot2.

(We can separately pursue improved 16-bit IAS support with the LLVM
developers.)

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 3a6c85abcbc3fbe2e0388a8708b36b9aac4b7bb1)

2 years agostand: remove CLANG_NO_IAS from zfsldr
Ed Maste [Tue, 26 Mar 2019 20:32:05 +0000 (20:32 +0000)]
stand: remove CLANG_NO_IAS from zfsldr

Many components under stand/ had CLANG_NO_IAS added when Clang's
Integrated Assembler (IAS) did not handle .codeNN directives.  Clang
gained support quite some time ago, and we can now build stand/ with
IAS.

Note that in some cases there are small differences in the generated
output, so CLANG_NO_IAS should be removed only after testing (or after
finding no differences in the output).  For zfsldr I compared objdump
output between GNU as- and Clang IAS-built zfsldr and .text was
identical (changes were limited to the object's ELF headers and debug
info).

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 698194ab249ffd23422048dc2157042fd5442288)

2 years agostand: remove CLANG_NO_IAS from btx and gptboot
Ed Maste [Tue, 20 Nov 2018 16:54:42 +0000 (16:54 +0000)]
stand: remove CLANG_NO_IAS from btx and gptboot

Many components under stand/ had CLANG_NO_IAS added when Clang's
Integrated Assembler (IAS) did not handle .codeNN directives.  Clang
gained support quite some time ago, and we can now build stand/ with
IAS.

Note that in some cases there are small differences in the generated
output, so CLANG_NO_IAS should be removed only after testing (or after
finding no differences in the output).

PR: 205250, 233094
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 02c4bf4391ec7296f5a002c139576ae8797853d1)

2 years agoRetire CLANG_NO_IAS34
Ed Maste [Thu, 1 Nov 2018 23:11:47 +0000 (23:11 +0000)]
Retire CLANG_NO_IAS34

CLANG_NO_IAS34 was introduced in r276696 to allow then-HEAD kernels to
be built with clang 3.4 in FreeBSD 10.  As FreeBSD 11 and later includes
a version of Clang with a sufficiently capable integrated assembler we
do not need the workaround any longer.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ea96b3de2b3e4492e6bba3ab35961e3531a006bd)

2 years agoCirrus-CI: reduce VM memory to 8G
Ed Maste [Tue, 31 Aug 2021 00:50:34 +0000 (20:50 -0400)]
Cirrus-CI: reduce VM memory to 8G

Cirrus-CI now provides a task memory use graph, and it is clear we do
not need to provision the VM with 24GB.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit bbf70270551d8defb427316e5d0e0f368b9aac96)

2 years agoRevert "arm: Bump KSTACK_PAGES default to match i386/amd64"
Kevin Bowling [Wed, 1 Sep 2021 20:06:27 +0000 (13:06 -0700)]
Revert "arm: Bump KSTACK_PAGES default to match i386/amd64"

This reverts commit b684d812fcb04b2997fd755405a92c36b9f6e30e.

It causes an issue on a pfsense routing workload where memory
fragmentation prevents the necessary consecutive pages from being
readily available.

Reported by: pfsense (mjg, scottl)
Approved by: ian
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D31244

(cherry picked from commit 5647f85ade3ae1db042560a3354b6a9945d619a4)

2 years agoFix a common typo in man pages and src comments
Gordon Bergling [Sat, 28 Aug 2021 17:24:27 +0000 (19:24 +0200)]
Fix a common typo in man pages and src comments

- s/desciptor/descriptor/

(cherry picked from commit b1603638e38b3d8c23da6599e389db9a9218c240)

2 years agopf tests: Test ALTQ on top of if_bridge
Kristof Provost [Wed, 25 Aug 2021 09:08:38 +0000 (11:08 +0200)]
pf tests: Test ALTQ on top of if_bridge

Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31676

(cherry picked from commit 062463698eeafc7f75ce22541a244238f37ef2e2)

2 years agoif_bridge: add ALTQ support
Luiz Otavio O Souza [Wed, 25 Aug 2021 09:07:44 +0000 (11:07 +0200)]
if_bridge: add ALTQ support

Similar to the recent addition of ALTQ support to if_vlan.

Reviewed by: donner
Obtained from: pfsense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31675

(cherry picked from commit eb680a63de1dbf5c974f483975dcb2c60ec6fa08)

2 years agopf tests: ALTQ priority test
Kristof Provost [Thu, 26 Aug 2021 08:25:57 +0000 (10:25 +0200)]
pf tests: ALTQ priority test

Test that ALTQ can prioritise one type of traffic over another. Do this
by establishing a slow link and saturating it with ICMP echos.
When prioritised TCP connections reliably go through. When not
prioritised TCP connections reliably fail.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit cd46399b9ccf04f6ec00a532e52c8b1edb007af7)

2 years agopf tests: test ALTQ CBQ on top of if_vlan
Kristof Provost [Mon, 23 Aug 2021 14:58:50 +0000 (16:58 +0200)]
pf tests: test ALTQ CBQ on top of if_vlan

The main purpose of this test is to verify that we can use ALTQ on top
of if_vlan, but while we're here we also exercise the CBQ code. There's
already a basis test for HFSC, so it makes sense to test another
algorithm while we test if_vlan.

Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31649

(cherry picked from commit e62175df4ec2c8fe2aa2e372f683ddb933768e62)

2 years agoif_vlan: add the ALTQ support to if_vlan.
Luiz Otavio O Souza [Sat, 21 Aug 2021 09:41:03 +0000 (11:41 +0200)]
if_vlan: add the ALTQ support to if_vlan.

Inspired by the iflib implementation, allow ALTQ to be used with if_vlan
interfaces.

Reviewed by: donner
Obtained from: pfsense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31647

(cherry picked from commit 2e5ff01d0a1fabc757252f9c28ad5cddc98a652d)

2 years agoisci(4): Fix a common typo in src comments
Gordon Bergling [Sun, 29 Aug 2021 07:55:10 +0000 (09:55 +0200)]
isci(4): Fix a common typo in src comments

- s/exlusive/exclusive/

(cherry picked from commit 2dfcc3a91dd4d21c16269b7add3141c99dfa48ab)

2 years agolibsa: Fix a typo in source code comments
Gordon Bergling [Sun, 29 Aug 2021 08:09:58 +0000 (10:09 +0200)]
libsa: Fix a typo in source code comments

- s/mininum/minimum/

(cherry picked from commit 005fe24f2a4c873a96f446604e0453cf99e9bcd7)

2 years agofwohci: Cast bitfield to uint32_t before passing it to roundup2().
John Baldwin [Wed, 17 Feb 2021 21:12:06 +0000 (13:12 -0800)]
fwohci: Cast bitfield to uint32_t before passing it to roundup2().

The fallback for __align_up() used by roundup2() uses __typeof__()
which doesn't work for bitfields.  This fixes the build on GCC which
uses the fallback.

Reviewed by: arichardson, markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D28599

(cherry picked from commit 50a61f8db532676d7dc37410540fff7209b7c072)
(cherry picked from commit ae0219c10fe3a2ea9caa7bc88ddc7d0a7e988efd)

2 years agoExpose clang's alignment builtins and use them for roundup2/rounddown2
Alex Richardson [Wed, 3 Feb 2021 15:27:17 +0000 (15:27 +0000)]
Expose clang's alignment builtins and use them for roundup2/rounddown2

This makes roundup2/rounddown2 type- and const-preserving and allows
using it on pointer types without casting to uintptr_t first. Not
performing pointer-to-integer conversions also helps the compiler's
optimization passes and can therefore result in better code generation.
When using it with integer values there should be no change other than
the compiler checking that the alignment value is a valid power-of-two.

I originally implemented these builtins for CHERI a few years ago and
they have been very useful for CheriBSD. However, they are also useful
for non-CHERI code so I was able to upstream them for Clang 10.0.

Rationale from the clang documentation:
Clang provides builtins to support checking and adjusting alignment
of pointers and integers. These builtins can be used to avoid relying
on implementation-defined behavior of arithmetic on integers derived
from pointers. Additionally, these builtins retain type information
and, unlike bitwise arithmetic, they can perform semantic checking on
the alignment value.

There is also a feature request for GCC, so GCC may also support it in
the future: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98641

Reviewed By: brooks, jhb, imp
Differential Revision: https://reviews.freebsd.org/D28332

(cherry picked from commit 8fa6abb6f4f64f4f23e2920e2aea7996566851a4)

2 years agoiflib: fix potential NULL dereference
Kristof Provost [Tue, 31 Aug 2021 12:11:22 +0000 (14:11 +0200)]
iflib: fix potential NULL dereference

iflib_softirq_alloc_generic() can be called with a NULL irq parameter
(as done by for example the bnxt and ixl drivers). If
iflib_irq_set_affinity() then returns an error we'd try to dereference
the NULL irq pointer.

Check irq, and pass '-1' (which taskqgroup_attach() expects) if we don't
have an irq.

Direct commit to stable/12, because this issue does not exist on main
and stable/13.

Reviewed by:    kbowling
Sponsored by:   Rubicon Communications, LLC ("Netgate")
Differential Revision:  https://reviews.freebsd.org/D31758

2 years agoSilence more gtest warnings, now in fusefs tests
Dimitry Andric [Fri, 27 Aug 2021 21:39:23 +0000 (23:39 +0200)]
Silence more gtest warnings, now in fusefs tests

Follow-up d396c67f26b0 by also silencing warnings about deprecated
implicit copy constructors in the fusefs tests, which use googletest.

Fixes: d396c67f26b0

(cherry picked from commit 5a3a8cb01ab8ef4aa16a1950b1ef804070ce1ac6)

2 years agoFix null pointer subtraction in mergesort()
Dimitry Andric [Fri, 27 Aug 2021 17:45:43 +0000 (19:45 +0200)]
Fix null pointer subtraction in mergesort()

Clang 13 produces the following warning for this function:

lib/libc/stdlib/merge.c:137:41: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
        if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
                                               ^ ~~~~~~~~~

This is meant to check whether the size and base parameters are aligned
to the size of an int, so use our __is_aligned() macro instead.

Also remove the comment that indicated this "stupid subtraction" was
done to pacify some ancient and unknown Cray compiler, and which has
been there since the BSD 4.4 Lite Lib Sources were imported.

(cherry picked from commit 4e5d32a445f90d37966cd6de571978551654e3f3)

2 years agopfctl: build fix
Kristof Provost [Tue, 24 Aug 2021 11:21:05 +0000 (13:21 +0200)]
pfctl: build fix

Fix the build issue introduced in e59eff9ad328 (pfctl: fix killing states by ID)

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 9ce320820e6d760df11a88de11fbae024c18d23c)

2 years agopf tests: test killing states by ID
Kristof Provost [Tue, 24 Aug 2021 10:36:57 +0000 (12:36 +0200)]
pf tests: test killing states by ID

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit bbf832f34479d19bff0fa8dc43b48ab5553cc85e)

2 years agopfctl: fix killing states by ID
Kristof Provost [Tue, 24 Aug 2021 10:24:28 +0000 (12:24 +0200)]
pfctl: fix killing states by ID

Since the conversion to the new DIOCKILLSTATESNV the kernel no longer
exists the id and creatorid to be big-endian.
As a result killing states by id (i.e. `pfctl -k id -k 12345`) no longer
worked.

Reported by: Özkan KIRIK
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit e59eff9ad3285838730acf48f6d066cec0e53114)

2 years agosound(4): Fix some common typos in comments
Gordon Bergling [Thu, 26 Aug 2021 15:15:55 +0000 (17:15 +0200)]
sound(4): Fix some common typos in comments

- s/doens't/doesn't/
- s/apropriate/appropriate/
- s/intepretation/interpretation/

(cherry picked from commit 58d868c88d21b46d3d6d40a2920e7ba8996723b8)

2 years agoinet(3): Fix a few common typos in source code comments
Gordon Bergling [Sat, 28 Aug 2021 16:53:02 +0000 (18:53 +0200)]
inet(3): Fix a few common typos in source code comments

- s/funtion/function/

(cherry picked from commit 586c9dc37470a2b862b50c041d70229026dd530a)

2 years agoinet6(4): Fix a few common typos in source code comments
Gordon Bergling [Sat, 28 Aug 2021 16:53:59 +0000 (18:53 +0200)]
inet6(4): Fix a few common typos in source code comments

- s/reshedule/reschedule/

(cherry picked from commit 10e0082fff4ec9392db2763ce3b095bc010526df)

2 years agoaltq: Fix panics on rmc_restart()
Kristof Provost [Sat, 21 Aug 2021 11:42:27 +0000 (13:42 +0200)]
altq: Fix panics on rmc_restart()

rmc_restart() is called from a timer, but can trigger traffic. This
means the curvnet context will not be set.
Use the vnet associated with the interface we're currently processing to
set it. We also have to enter net_epoch here, for the same reason.

Reviewed by: mjg
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31642

(cherry picked from commit 159258afb50ad57f7ed27fe86ded83a7b3a26f90)

2 years agonfsstat(1): Fix a typo in an error message
Gordon Bergling [Mon, 23 Aug 2021 07:21:28 +0000 (09:21 +0200)]
nfsstat(1): Fix a typo in an error message

- s/priviledged/privileged/

(cherry picked from commit 72a92f91f466fdb73071ec28982b9f4d4cf9b672)

2 years agokern: mountroot: avoid fd leak in .md parsing
Kyle Evans [Tue, 20 Jul 2021 10:23:11 +0000 (05:23 -0500)]
kern: mountroot: avoid fd leak in .md parsing

parse_dir_md() opens /dev/mdctl but only closes the resulting fd on
success, not upon failure of the ioctl or when we exceed the md unit
max.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #62

(cherry picked from commit 23ecfa9d5bc4f04eb58e26018c2d15f032d5d742)

2 years agofreebsd-update: create a ZFS boot environment on install
Dave Fullard [Fri, 16 Jul 2021 04:02:48 +0000 (23:02 -0500)]
freebsd-update: create a ZFS boot environment on install

Updated freebsd-update to allow it to create boot environments using
bectl should the system support it. The bectl utility was updated in
r352211 (490e13c1403f) to support a 'check' to determine if the system
supports boot environments.  If UFS is used, the bectl check will fail
then no attempt will be made to create the boot environment.

If freebsd-update is run inside a jail, no attempt will be made to
create a boot environment.

The boot environment function will create a new environment using the
format: current FreeBSD kernel version and date/timestamp, example:

12.0-RELEASE-p10_2019-10-03_185233

This functionality can be disabled by setting 'CreateBootEnv' in
freebsd-update.conf to 'no'.

(cherry picked from commit f28f138905416c45ebaa6429f44a0b88a72f54b1)

2 years agoRevert "Do a sweep and remove most WARNS=6 settings"
Dimitry Andric [Sun, 29 Aug 2021 13:28:30 +0000 (15:28 +0200)]
Revert "Do a sweep and remove most WARNS=6 settings"

This reverts commit befc47822966, as it caused various CI build errors,
and we never merged the prerequisite commit fe815331bb40 ("build:
provide a default WARNS for all in-tree builds"). The latter is rather
intrusive, so I will avoid it.

Direct commit to stable/12 since the CI bots are broken.

2 years agoCleanup compiler warning flags in lib/libefivar/Makefile
Dimitry Andric [Thu, 26 Aug 2021 18:53:18 +0000 (20:53 +0200)]
Cleanup compiler warning flags in lib/libefivar/Makefile

There is no need to set -Wno-unused-parameter twice, and instead of
appending to CFLAGS, append to CWARNFLAGS instead. While here, add
-Wno-unused-but-set-variable for the sake of clang 13.0.0.

(cherry picked from commit f643997a1761689ef9108d69b86d42881ea0ab1c)

2 years agogoogletest: Silence warnings about deprecated implicit copy constructors
Dimitry Andric [Thu, 26 Aug 2021 20:06:49 +0000 (22:06 +0200)]
googletest: Silence warnings about deprecated implicit copy constructors

Our copy of googletest is rather stale, and causes a number of -Werror
warnings about implicit copy constructor definitions being deprecated,
because several classes have user-declared copy assignment operators.
Silence the warnings until we either upgrade or remove googletest.

(cherry picked from commit d396c67f26b079c2808002c07212d9df9818a11b)

2 years agoDo a sweep and remove most WARNS=6 settings
Kyle Evans [Thu, 1 Oct 2020 01:10:51 +0000 (01:10 +0000)]
Do a sweep and remove most WARNS=6 settings

Repeating the default WARNS here makes it slightly more difficult to
experiment with default WARNS changes, e.g. if we did something absolutely
bananas and introduced a WARNS=7 and wanted to try lifting the default to
that.

Drop most of them; there is one in the blake2 kernel module, but I suspect
it should be dropped -- the default WARNS in the rest of the build doesn't
currently apply to kernel modules, and I haven't put too much thought into
whether it makes sense to make it so.

(cherry picked from commit 7cc42f6d25ef2e19059d088fa7d4853fe9afefb5)

2 years agoEnable rc.d/jail within jails
Dan Langille [Sun, 15 Aug 2021 16:53:16 +0000 (12:53 -0400)]
Enable rc.d/jail within jails

Jails with jails is a supported. This change allows the script to run
upon startup with a jail. Without this, jails are not automatically
started within jails.

(cherry picked from commit 35cf9fecbd80f56e39524f480240acfd953c93e1)

2 years agoext2fs(5): Correct a typo in an error message
Gordon Bergling [Sun, 22 Aug 2021 05:58:22 +0000 (07:58 +0200)]
ext2fs(5): Correct a typo in an error message

- s/talbes/tables/

(cherry picked from commit 47f880ebeb3092b1b7bbc6d75e82532e43bbf010)

2 years agoiflib: Improve mapping of TX/RX queues to CPUs
Patrick Kelsey [Mon, 26 Apr 2021 04:25:59 +0000 (00:25 -0400)]
iflib: Improve mapping of TX/RX queues to CPUs

iflib now supports mapping each (TX,RX) queue pair to the same CPU
(default), to separate CPUs, or to a pair of physical and logical CPUs
that share the same L2 cache.  The mapping mechanism supports unequal
numbers of TX and RX queues, with the excess queues always being
mapped to consecutive physical CPUs.  When the platform cannot
distinguish between physical and logical CPUs, all are treated as
physical CPUs.  See the comment on get_cpuid_for_queue() for the
entire matrix.

The following device-specific tunables influence the mapping process:
dev.<device>.<unit>.iflib.core_offset       (existing)
dev.<device>.<unit>.iflib.separate_txrx     (existing)
dev.<device>.<unit>.iflib.use_logical_cores (new)

The following new, read-only sysctls provide visibility of the mapping
results:
dev.<device>.<unit>.iflib.{t,r}xq<n>.cpu

When an iflib driver allocates TX softirqs without providing reference
RX IRQs, iflib now binds those TX softirqs to CPUs using the above
mapping mechanism (that is, treats them as if they were TX IRQs).
Previously, such bindings were left up to the grouptaskqueue code and
thus fell outside of the iflib CPU mapping strategy.

Reviewed by: kbowling
Tested by: olivier, pkelsey
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D24094

(cherry picked from commit ca7005f1893d199b7c28d5b159e1bdbb55e74543)

2 years agovmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1
Ka Ho Ng [Mon, 2 Aug 2021 09:54:40 +0000 (17:54 +0800)]
vmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1

In hw.vmm.create sysctl handler the maximum length of vm name is
VM_MAX_NAMELEN. However in vm_create() the maximum length allowed is
only VM_MAX_NAMELEN - 1 chars. Bump the length of the internal buffer to
allow the length of VM_MAX_NAMELEN for vm name.

Reviewed by: grehan
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31372

(cherry picked from commit df95cc76affbbf114c9ff2e4ee011b6f162aa8bd)

2 years agotmpfs: Fix error being cleared after commit c12118f6cec0
Ka Ho Ng [Tue, 24 Aug 2021 16:35:29 +0000 (00:35 +0800)]
tmpfs: Fix error being cleared after commit c12118f6cec0

In tmpfs_link() error was erroneously cleared in commit c12118f6cec0.

Sponsored by: The FreeBSD Foundation
MFC with: c12118f6cec0

(cherry picked from commit a48416f844e3007b4e9f6df125e25cf3a1daad62)

2 years agotmpfs: Fix styles
Ka Ho Ng [Tue, 24 Aug 2021 13:09:21 +0000 (21:09 +0800)]
tmpfs: Fix styles

A lot of return statements were in the wrong style before this commit.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c12118f6cec0ca5f720be6c06d6c59d551461e5a)

2 years agosound: Add an example of basic sound application
Goran Mekić [Wed, 4 Aug 2021 10:04:54 +0000 (18:04 +0800)]
sound: Add an example of basic sound application

This is an example demonstrating the usage of the OSS-compatible APIs
provided by the sound(4) subsystem. It reads frames from a dsp node and
writes them to the same dsp node.

Reviewed by: hselasky, bcr
Differential revision: https://reviews.freebsd.org/D30149

(cherry picked from commit 21d854658801f6ddb91de3a3c3384e90f5d920f2)

2 years agointel ethernet: Use ether_gen_addr(9)
Kevin Bowling [Fri, 20 Aug 2021 14:45:30 +0000 (07:45 -0700)]
intel ethernet: Use ether_gen_addr(9)

Use ether_gen_addr(9) for VF MAC generation

Reviewed by: Intel Networking (erj), kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31616

(cherry picked from commit 0e5811a2a9a1b4a7e0c79b73e3b9b9d15d481577)

2 years agocrunch: drop WARNS override
Kyle Evans [Thu, 19 Aug 2021 06:33:13 +0000 (01:33 -0500)]
crunch: drop WARNS override

crunchide and crunchgen now build fine with default WARNS

(cherry picked from commit d59c5e023d558161e4f519b88d5209d8bab18bc7)

2 years agocrunchgen: fix remaining issues under WARNS=6
Kyle Evans [Thu, 19 Aug 2021 06:22:16 +0000 (01:22 -0500)]
crunchgen: fix remaining issues under WARNS=6

Entirely variables that should be static, save for one 'no previous
declaration' in mkskel.sh.

(cherry picked from commit bfd70233c3e2bc5c29db6f96fb90b58439908d29)

2 years agocrunchide: static'ify remaining non-exported functions
Kyle Evans [Thu, 19 Aug 2021 06:29:02 +0000 (01:29 -0500)]
crunchide: static'ify remaining non-exported functions

(cherry picked from commit 7ff87026d65c77f90391ead3f2fc752223d16e01)

2 years agocrunchide: address complaints from WARNS=6
Kyle Evans [Thu, 19 Aug 2021 06:17:36 +0000 (01:17 -0500)]
crunchide: address complaints from WARNS=6

- One (1) constify
- One (1) argument is unused
- One (1) local shadows a global
- Various globals that should be static

(cherry picked from commit dd7c7ff192d07912fb7f5874868649c3aa05944a)

2 years agocrunchgen: sprinkle some const-poisoning around
Kyle Evans [Thu, 19 Aug 2021 06:13:13 +0000 (01:13 -0500)]
crunchgen: sprinkle some const-poisoning around

(cherry picked from commit db7f7446b5bcb26c7aaf13c8151b4ae8051c5732)

2 years agopkg: use specific CONFSNAME_${file} for FreeBSD.conf
Kyle Evans [Thu, 18 Feb 2021 04:10:46 +0000 (22:10 -0600)]
pkg: use specific CONFSNAME_${file} for FreeBSD.conf

Setting CONFSNAME directly is a little more complicated for downstream
consumers, as any additional CONFS that are added here will inherit the
group name by default.  This is perhaps arguably a design flaw in CONFS
because inheriting NAME will never give a good result when additional
files are added, but this is a low-effort change.

While we're here, pull FreeBSD.conf.${branch} out into a PKGCONF
variable so one can just drop a new repo config in entirely with a new
naming scheme. CONFSNAME gets set based on chopping anything off after
".conf", so that, e.g.:

- FooBSD.conf => FooBSD.conf
- FooBSD.conf.internal => FooBSD.conf

(cherry picked from commit d35164539b14a6d14fb587e58a0c7a1668d7643a)

2 years agopkg: allow multiple add arguments again
Kyle Evans [Thu, 18 Feb 2021 03:41:53 +0000 (21:41 -0600)]
pkg: allow multiple add arguments again

While pkg(7) add only handles a single 'add' argument, pkg-add(8) fully
handles multiple arguments.

Stop rejecting it, just turn off local-bootstrap mode and proceed to
remote bootstrap if we need it.

While we're here, check if the first argument to pkg add is even a pkg
package. If it's not, also do remote bootstrap instead. Future work
could improve this altogether by picking out a pkg package out of many
and local bootstrap then pass the rest through to the newly installed
pkg.

(cherry picked from commit 40b9f924b189ce8fa871db600b4abc99b03c6a65)

2 years agomalloc(9): Document/complete aligned variants
Adam Fenn [Mon, 2 Aug 2021 20:33:31 +0000 (15:33 -0500)]
malloc(9): Document/complete aligned variants

Comments on a pending kvmclock driver suggested adding a
malloc_aligned() to complement malloc_domainset_aligned(); add it now,
and document both.

(cherry picked from commit 6162cf885c00a0893a0961415f1829942343dcc1)
(cherry picked from commit 04cc0c393c317b6d5e28c8dc80cd1b5ea071f28f)

2 years agodevclass_alloc_unit: move "at" hint test to after device-in-use test
Adam Fenn [Mon, 2 Aug 2021 16:27:17 +0000 (11:27 -0500)]
devclass_alloc_unit: move "at" hint test to after device-in-use test

Only perform this expensive operation when the unit number is a
potential candidate (i.e. not already in use), thereby reducing device
scan time on systems with many devices, unit numbers, and drivers.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #61

(cherry picked from commit 8ca384eb1d429aae866f53abfadafc71ab009dc6)

2 years agoApply clang fix for assertion failure compiling multimedia/minitube
Dimitry Andric [Sat, 21 Aug 2021 21:03:37 +0000 (23:03 +0200)]
Apply clang fix for assertion failure compiling multimedia/minitube

Merge commit 79f9cfbc21e0 from llvm git (by Yaxun (Sam) Liu):

  Do not merge LocalInstantiationScope for template specialization

  A lambda in a function template may be recursively instantiated. The recursive
  lambda will cause a lambda function instantiated multiple times, one inside another.
  The inner LocalInstantiationScope should not be marked as MergeWithParentScope
  since it already has references to locals properly substituted, otherwise it causes
  assertion due to the check for duplicate locals in merged LocalInstantiationScope.

  Reviewed by: Richard Smith

  Differential Revision: https://reviews.llvm.org/D98068

Reported by: yuri
PR: 257978

(cherry picked from commit efa485d5c390b745f53761da9159721243c48b7b)

2 years agortsold: make it work on if_vlan interfaces
Luiz Otavio O Souza [Thu, 19 Aug 2021 09:48:04 +0000 (11:48 +0200)]
rtsold: make it work on if_vlan interfaces

Reviewed by: kp
Obtained from: pfsense
MFC after: 1 week

(cherry picked from commit 1a4d7030bbfec0f830e87bf7c2810f049f8ca8ac)

2 years agolagg: don't update link layer addresses on destroy
Luiz Otavio O Souza [Tue, 17 Aug 2021 14:23:50 +0000 (16:23 +0200)]
lagg: don't update link layer addresses on destroy

When the lagg is being destroyed it is not necessary update the
lladdr of all the lagg members every time we update the primary
interface.

Reviewed by: scottl
Obtained from: pfSense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31586

(cherry picked from commit c138424148f900dc449c757869453120ae3277f3)

2 years agoipfw: use unsigned int for dummynet bandwidth
Luiz Otavio O Souza [Tue, 17 Aug 2021 07:54:40 +0000 (09:54 +0200)]
ipfw: use unsigned int for dummynet bandwidth

This allows the maximum value of 4294967295 (~4Gb/s) instead of previous
value of 2147483647 (~2Gb/s).

Reviewed by: np, scottl
Obtained from: pfSense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31582

(cherry picked from commit 20ffd88ed54fe3fd098ac30bd221275b2a14f52c)

2 years agoinit: execute /etc/rc.final after all user processes have terminated
Kyle Evans [Tue, 20 Jul 2021 10:40:30 +0000 (05:40 -0500)]
init: execute /etc/rc.final after all user processes have terminated

This can be useful for, e.g., unmounting filesystems that were needed
for shutdown.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #63

(cherry picked from commit 4d1597691916240b9023ee9f15e249503abf67fd)

2 years agokenv: allow listing of static kernel environments
Kyle Evans [Sun, 20 Jun 2021 19:36:10 +0000 (14:36 -0500)]
kenv: allow listing of static kernel environments

The early environment is typically cleared, so these new options
need the PRESERVE_EARLY_KENV kernel config(8) option. These environments
are reported as missing by kenv(1) if the option is not present in the
running kernel.

(cherry picked from commit db0f26439357b78863e61985acd1e5acf75ce73d)

2 years agokern: add an option for preserving the early kenv
Kyle Evans [Sun, 20 Jun 2021 19:29:31 +0000 (14:29 -0500)]
kern: add an option for preserving the early kenv

Some downstream configurations do not store secrets in the
early (loader/static) environments and desire a way to preserve these
for diagnostic reasons.  Provide an option to do so.

(cherry picked from commit 7a129c973b5ba0fa916dfa658d523bec66dbd02d)

2 years agokenv: s/dump/list/ to clarify meaning
Kyle Evans [Mon, 21 Jun 2021 03:11:26 +0000 (22:11 -0500)]
kenv: s/dump/list/ to clarify meaning

The contents of the kenv will be dumped to stdout, while dump could have
also meant 'discard'. Call it 'list' instead.

(cherry picked from commit 46438b5366f9405beb6f76474a5aae822352f012)

2 years agoe1000: Update intel shared code
Kevin Bowling [Thu, 19 Aug 2021 14:59:34 +0000 (07:59 -0700)]
e1000: Update intel shared code

Sync the e1000 shared code with DPDK shared code
"cid-gigabit.2020.06.05.tar.gz released by ND"

Primary focus was on client platforms (ich8lan). More work remains here
but we need an Intel contact for client networking.

Reviewed by: grehan, Intel Networking (erj, earlier rev)
Obtained from: DPDK <http://git.dpdk.org/dpdk/tree/drivers/net/e1000/base>
MFC after: 1 week
Sponsored by: me
Differential Revision: https://reviews.freebsd.org/D31547

(cherry picked from commit fc7682b17f3738573099b8b03f5628dcc8148adb)

2 years agodhclient: support supersede statement for option 54
Fabian Kurtz [Wed, 18 Aug 2021 17:12:48 +0000 (10:12 -0700)]
dhclient: support supersede statement for option 54

PR: 217978
Reported by: Franco Fichtner <franco@opnsense.org>
Reviewed by: markj
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31503

(cherry picked from commit 0a539a0f005e8acbe4974ede30aa928099c988b9)

2 years agogre: simplify RSS ifdefs
Franco Fichtner [Wed, 18 Aug 2021 17:05:29 +0000 (10:05 -0700)]
gre: simplify RSS ifdefs

Use the early break to avoid else definitions. When RSS gains a
runtime option previous constructs would duplicate and convolute
the existing code.

While here init flowid and skip magic numbers and late default
assignment.

Reviewed by: melifaro, kbowling
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31584

(cherry picked from commit bb250fae9e9e278b681cf3a71ced718700ecf74c)

2 years agoiflib: emulate counters in netmap mode
Stephan de Wit [Wed, 18 Aug 2021 07:17:43 +0000 (00:17 -0700)]
iflib: emulate counters in netmap mode

When iflib devices are in netmap mode the driver
counters are no longer updated making it look from
userspace tools that traffic has stopped.

Reported by: Franco Fichtner <franco@opnsense.org>
Reviewed by: vmaffione, iflib (erj, gallatin)
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31550

(cherry picked from commit 66fa12d8fb61485780f32f0226e79d3389567496)

2 years agoAllow the pseudo-errnos to be returned as well in boot loader
Warner Losh [Fri, 28 Aug 2020 17:49:56 +0000 (17:49 +0000)]
Allow the pseudo-errnos to be returned as well in boot loader

Expose the pseudo-errno values in _STANDALONE is defined so that code
in the boot loader can make use of them. Nothing uses them today, but
the zstd support that's coming will need them.

(cherry picked from commit 0c35b860913807d4937098d5238c5f4363fb6362)

2 years agorpc(3): Correct a few common typos in source code comments
Gordon Bergling [Sun, 22 Aug 2021 06:16:09 +0000 (08:16 +0200)]
rpc(3): Correct a few common typos in source code comments

- s/therfore/therefor/
- s/activte/active/

Obtained from: NetBSD

(cherry picked from commit 0d55bc8eb2ab9508c43e135616ca887ed719ea9a)

2 years agobhyve: Fix vq_getchain() error handling bugs in various device models
Mark Johnston [Tue, 24 Aug 2021 18:13:00 +0000 (14:13 -0400)]
bhyve: Fix vq_getchain() error handling bugs in various device models

Reviewed by: grehan, khng
Approved by: so
Security: CVE-2021-29631
Security: FreeBSD-SA-21:13.bhyve

(cherry picked from commit 71fbc6faed62e8eb5864f7c40839740f5e9f5558)

2 years agoFix multiple OpenSSL vulnerabilities.
Gordon Tetlow [Tue, 24 Aug 2021 18:03:46 +0000 (11:03 -0700)]
Fix multiple OpenSSL vulnerabilities.

Approved by: so
Security: SA-21:16.openssl
Security: CVE-2021-3711
Security: CVE-2021-3712

(cherry picked from commit be158ffe54dcc4a633652685afc5e37894e10ea0)

2 years agoFix libfetch out of bounds read.
Gordon Tetlow [Tue, 24 Aug 2021 17:59:01 +0000 (10:59 -0700)]
Fix libfetch out of bounds read.

Approved by: so
Security: SA-21:15.libfetch
Security: CVE-2021-36159

(cherry picked from commit 3be62d49ae2b6f9050f39fe74210c88f35901fa5)

2 years agoFix remote code execution in ggatec(8).
Gordon Tetlow [Tue, 24 Aug 2021 17:40:49 +0000 (10:40 -0700)]
Fix remote code execution in ggatec(8).

Approved by:    so
Security:       SA-21:14.ggatec
Security:       CVE-2021-29630

(cherry picked from commit 515216929c40169cc72b62466ff9238682661613)

2 years agoipfw: fix possible data race between jump cache reading and updating.
Andrey V. Elsukov [Tue, 17 Aug 2021 08:08:28 +0000 (11:08 +0300)]
ipfw: fix possible data race between jump cache reading and updating.

Jump cache is used to reduce the cost of rule lookup for O_SKIPTO and
O_CALLRETURN actions. It uses rules chain id to check correctness of
cached value. But due to the possible race, there is the chance that
one thread can read invalid value. In some cases this can lead to out
of bounds access and panic.

Use thread fence operations to constrain the reordering of accesses.
Also rename jump_fast and jump_linear functions to jump_cached and
jump_lookup_pos respectively.

Submitted by: Arseny Smalyuk
Obtained from: Yandex LLC
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D31484

(cherry picked from commit 322e5efda8578bb9c0a0ab0ef785cd1e1c222c85)

2 years agonetinet6 tests: build fix
Kristof Provost [Tue, 24 Aug 2021 13:29:36 +0000 (15:29 +0200)]
netinet6 tests: build fix

Add missing '\'.
Direct commit to stable/12 due to mismerge.

Sponsored by:   Rubicon Communications, LLC ("Netgate")

2 years agonetinet tests: delete an interface with pending lookups
Kristof Provost [Tue, 17 Aug 2021 14:19:29 +0000 (16:19 +0200)]
netinet tests: delete an interface with pending lookups

This has been known to trigger panics. It currently doesn't, but we may
as well have a test for it.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit e86469075c5e391cc86e5bcd4f252712a69de37e)

2 years agoAdd arp/ndp tests in addition to rtsock ll tests.
Alexander V. Chernikov [Sat, 20 Feb 2021 18:20:24 +0000 (18:20 +0000)]
Add arp/ndp tests in addition to rtsock ll tests.

(cherry picked from commit f17f94cd1b99c61faa08aa988b47805c53b78ac7)

2 years agontb_transport(4): Mark callouts MP-safe.
Alexander Motin [Tue, 10 Aug 2021 20:30:12 +0000 (16:30 -0400)]
ntb_transport(4): Mark callouts MP-safe.

The only thing around NTB using Giant lock is NewBus, and these callouts
have nothing to do with it.

MFC after: 2 weeks

(cherry picked from commit c6902e7796bc78df011131a2b8b024faed884b8f)

2 years agoixgbe: Avoid sbuf_trim(9) in sysctl handler
Kevin Bowling [Mon, 23 Aug 2021 16:21:39 +0000 (09:21 -0700)]
ixgbe: Avoid sbuf_trim(9) in sysctl handler

This was an error, we cannot use sbuf_trim(9) in the
ixgbe_sbuf_fw_version function because it also gets called in
the context of sbuf_new_for_sysctl(9). sbuf(9) explains the interaction
with drain functions as used by sbuf_new_for_sysctl(9).

Reviewed by: imp
Fixes: 7660e4ea5cb7
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D31633

(cherry picked from commit 5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc)

2 years agoigc: sync igc_txrx with igb(4)
Kevin Bowling [Sat, 31 Jul 2021 15:00:16 +0000 (08:00 -0700)]
igc: sync igc_txrx with igb(4)

Reviewed by: grehan
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31227

(cherry picked from commit d02e436353d292e6fd50f70ea80507095543764e)

2 years agoe1000: always enable PCSD when RSS hashing
Kevin Bowling [Mon, 16 Aug 2021 17:17:34 +0000 (10:17 -0700)]
e1000: always enable PCSD when RSS hashing

To enable RSS hashing in the NIC, the PCSD bit must be set.

By default, this is never set when RXCSUM is disabled - which
causes problems higher up in the stack.

While here improve the RXCSUM flag assignments when enabling or
disabling IFCAP_RXCSUM.

See also: https://lists.freebsd.org/pipermail/freebsd-current/2020-May/076148.html

Reviewed by: markj, Franco Fichtner <franco@opnsense.org>,
Stephan de Wit <stephan.dewt@yahoo.co.uk>
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31501
Co-authored-by: Stephan de Wit <stephan.dewt@yahoo.co.uk>
Co-authored-by: Franco Fichtner <franco@opnsense.org>
(cherry picked from commit 69e8e8ea3d4be9da6b5bc904a444b51958128ff5)

2 years agolibpfctl: Fix endianness issues
Kristof Provost [Fri, 20 Aug 2021 11:43:15 +0000 (13:43 +0200)]
libpfctl: Fix endianness issues

Several fields are supplied in big-endian format, so we need to convert
them before we display them.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 719b5397c2887bc0619bb6ffb38f67f37bbf13c6)

2 years agoarm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS
Mateusz Guzik [Wed, 21 Jul 2021 03:34:32 +0000 (05:34 +0200)]
arm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS

Stat collection using counter(9) is quite expensive on this platform and
these counters are normally not needed.

In particular we see about 1.5% bump in packet rate using Cortex-A9

Reviewed by: ian
Sponsored by: Rubicon Communications, LLC ("Netgate")
Different Revision: https://reviews.freebsd.org/D31592

(cherry picked from commit aec8ad8a9e6aba2d73c98bd41f2994744aae3d01)

2 years agopf: assert dir state on pf_test{,6}
Mateusz Guzik [Tue, 17 Aug 2021 18:16:09 +0000 (20:16 +0200)]
pf: assert dir state on pf_test{,6}

The intent is to line up various enums so that branching in the lines of:

idx = (dir == PF_IN ? PF_SK_WIRE : PF_SK_STACK);

is avoided.

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 3e875f952af05697807139b460e5124eb5f6137b)

2 years agopf: save on branching in the common case in pf_test
Mateusz Guzik [Tue, 17 Aug 2021 18:04:31 +0000 (20:04 +0200)]
pf: save on branching in the common case in pf_test

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5091ca26507b83ebd5ce677dd26bd10e4bad4153)

2 years agoigc(4): Introduce new driver for the Intel I225 Ethernet controller.
Peter Grehan [Mon, 23 Aug 2021 11:46:49 +0000 (21:46 +1000)]
igc(4): Introduce new driver for the Intel I225 Ethernet controller.

This controller supports 2.5G/1G/100MB/10MB speeds, and allows
tx/rx checksum offload, TSO, LRO, and multi-queue operation.

The driver was derived from code contributed by Intel, and modified
by Netgate to fit into the iflib framework.

Thanks to Mike Karels for testing and feedback on the driver.

Reviewed by: bcr (manpages), kbowling, scottl, erj
Relnotes: yes
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30668

For stable/12, CTLFLAG_NEEDGIANT removed and if_foreach_llmaddr() replaced with
if_multiaddr_array().

(cherry picked from commit 517904de5ccac643589c71ac0d2751797f89e4f9)

2 years agoufs_dirhash: Correct a typo in a comment
Gordon Bergling [Fri, 20 Aug 2021 07:59:18 +0000 (09:59 +0200)]
ufs_dirhash: Correct a typo in a comment

- s/memry/memory/

(cherry picked from commit 464a166c27bb8947d5de1f617170ef6813587cc3)

2 years agoOptimize res_find().
Alexander Motin [Mon, 9 Aug 2021 01:34:33 +0000 (21:34 -0400)]
Optimize res_find().

When the device name is provided, we can simply run strncmp() for each
line to quickly skip unrelated ones, that is much faster than sscanf()
and only then strcmp().

MFC after: 2 weeks

(cherry picked from commit 696fca3fd491972e615195f2ce94598b9c469cac)

2 years agosigtimedwait: Use a unique wait channel for sleeping
Mark Johnston [Mon, 16 Aug 2021 17:15:25 +0000 (13:15 -0400)]
sigtimedwait: Use a unique wait channel for sleeping

When a sigtimedwait(2) caller goes to sleep, it uses a wait channel of
p->p_sigacts with the proc lock as the interlock.  However, p_sigacts
can be shared between processes if a child is created with
rfork(RFSIGSHARE | RFPROC).  Thus we can end up with two threads
sleeping on the same wait channel using different locks, which is not
permitted.

Fix the problem simply by using a process-unique wait channel, following
the example of sigsuspend.  The actual wait channel value is irrelevant
here, sleeping threads are awoken using sleepq_abort().

Reported by: syzbot+8c417afabadb50bb8827@syzkaller.appspotmail.com
Reported by: syzbot+1d89fc2a9ef92ef64fa8@syzkaller.appspotmail.com
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c4feb1ab0ae0c0e779af372e4c5f3b9e0d3e1388)

2 years agoftpd: delete dead code
Alan Somers [Tue, 27 Jul 2021 18:14:00 +0000 (12:14 -0600)]
ftpd: delete dead code

Delete code killed by SVN r13139 in 1996.  Little chance that it would
still compile today.

PR: 257317
Reported by: Alan Shearer <sakison@gmail.com>
Sponsored by: Axcient

(cherry picked from commit 674400eb20b65369a88b1cb778d729bc297832c9)

2 years agoiostat: fix rounding errors in iostat -x
Alan Somers [Thu, 8 Jul 2021 16:16:32 +0000 (10:16 -0600)]
iostat: fix rounding errors in iostat -x

Better to round numbers instead of flooring them.

Sponsored by: Axcient

(cherry picked from commit 61631b24a1347a23cafe0657fba894622b1606e2)

2 years agoEscape any '.' characters in sysctl node names
Alan Somers [Wed, 21 Jul 2021 21:11:00 +0000 (15:11 -0600)]
Escape any '.' characters in sysctl node names

ZFS creates some sysctl nodes that include a pool name, and '.' is an
allowed character in pool names.  But it's the separator in the sysctl
tree, so it can't be included in a sysctl name.  Replace it with "%25".
Handily, "%" is illegal in ZFS pool names, so there's no ambiguity
there.

PR: 257316
Sponsored by: Axcient
Reviewed by: freqlabs
Differential Revision: https://reviews.freebsd.org/D31265

(cherry picked from commit 6c9506559080da2914749bf611225d7c0a153609)

2 years agokbdmux(4): Make callout handler mpsafe.
Alexander Motin [Sun, 8 Aug 2021 22:19:08 +0000 (18:19 -0400)]
kbdmux(4): Make callout handler mpsafe.

Both callout and taskqueue now have drain() routines not requiring
external locking.  It allows to remove TASK flag and manual drain,
so the only thing remaining for lock to protect inside the callout
handler is ks_inq_length zero comparison, that can be lockless.

MFC after: 2 weeks

(cherry picked from commit e5018628e76a27e0f61ca03e2aa2247b3c62a158)

2 years agoApply upstream clang fix for assertion failure compiling devel/capnproto
Dimitry Andric [Sat, 21 Aug 2021 14:26:51 +0000 (16:26 +0200)]
Apply upstream clang fix for assertion failure compiling devel/capnproto

Merge commit 48c70c1664aa from llvm git (by Richard Smith):

  Extend memset-to-zero optimization to C++11 aggregate functional casts
  Aggr{...}.

  We previously missed these cases due to not stepping over the additional
  AST nodes representing their syntactic form.

Direct commit to stable/12, as both main and stable/13 already have this
fix as part of clang 12.0.1.

Reported by: fernape
PR: 257961

2 years agokern: ether_gen_addr: randomize on default hostuuid, too
Kyle Evans [Fri, 16 Apr 2021 01:11:35 +0000 (20:11 -0500)]
kern: ether_gen_addr: randomize on default hostuuid, too

Currently, this will still hash the default (all zero) hostuuid and
potentially arrive at a MAC address that has a high chance of collision
if another interface of the same name appears in the same broadcast
domain on another host without a hostuuid, e.g., some virtual machine
setups.

Instead of using the default hostuuid, just treat it as a failure and
generate a random LA unicast MAC address.

Reviewed by: bz, gbe, imp, kbowling, kp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29788

(cherry picked from commit 2d741f33bd07bf94a59635db3c7b9e070a8a6e55)

2 years agoman: document ether_gen_addr(9)
Kyle Evans [Fri, 16 Apr 2021 01:08:27 +0000 (20:08 -0500)]
man: document ether_gen_addr(9)

This KPI is used to assign a MAC address to an interface that doesn't
already have one assigned.

Reviewed by: bcr, gnn, imp, kbowling, kp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29787

(cherry picked from commit e58a65ccdac352712e19a60fffa57a86afabbde9)

2 years agoFix a typo that was introduced while fixing a typo
Gordon Bergling [Sat, 14 Aug 2021 12:30:59 +0000 (14:30 +0200)]
Fix a typo that was introduced while fixing a typo

- s/enrtry/entry/

(cherry picked from commit 646f3a36c8df0e54e71332038ede594965daac6e)

2 years agoFix a common typo in source code comments
Gordon Bergling [Sat, 14 Aug 2021 12:17:48 +0000 (14:17 +0200)]
Fix a common typo in source code comments

- s/aligment/alignment/

(cherry picked from commit a1581cd73594bbbde638859c31226c2c21be1ab3)