]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoOFED: migrate LinuxKPI net_device/ifnet macros into ofed
Bjoern A. Zeeb [Wed, 26 May 2021 17:51:24 +0000 (17:51 +0000)]
OFED: migrate LinuxKPI net_device/ifnet macros into ofed

The LinuxKPI net_device actually is an ifnet; in order to further
clean that up so we can extend "net_device" migrate the few macros
left into ofed and make sure the header is included in all files
which need access to the macros.

Sponsored by: The FreeBSD Foundation
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D30477

(cherry picked from commit 825b7d4c9d1d7cb0c79ffe002bc1bd58f28e1a67)

3 years agomlx4: replace LinuxKPI macros with ifnet functions
Bjoern A. Zeeb [Wed, 26 May 2021 17:47:02 +0000 (17:47 +0000)]
mlx4: replace LinuxKPI macros with ifnet functions

The LinuxKPI net_device actually is an ifnet;  in order to further
clean that up so we can extend "net_device" replace the few macros
inline in mlx4.

Sponsored by: The FreeBSD Foundation
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D30476

(cherry picked from commit 60afad6fc307815ad2b70a9974d908b6d5d50674)

3 years agoLinuxKPI/OFED/mlx4: cleanup netdevice.h some more
Bjoern A. Zeeb [Wed, 26 May 2021 12:27:26 +0000 (12:27 +0000)]
LinuxKPI/OFED/mlx4: cleanup netdevice.h some more

This removes all unused bits from linux/netdevice.h and migrates two
inline functions into the mlx4 and ofed code respectively.

This gets the mlx4/ofed (struct ifnet) specific bits down to 7 lines
in netdevice.h.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, kib
Differential Revision: https://reviews.freebsd.org/D30461

(cherry picked from commit c35034b338eb4de6fb42fd855865bce21c81a225)

3 years agoLinuxKPI: add addrconf_addr_solict_mult()
Bjoern A. Zeeb [Mon, 24 May 2021 17:49:12 +0000 (17:49 +0000)]
LinuxKPI: add addrconf_addr_solict_mult()

Introduce net/addrconf.h with an implementation to
addrconf_addr_solict_mult() used by WiFi drivers.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30416

(cherry picked from commit 095f018e4915bf63447ecd6be3beae0dd1a5ff52)

3 years agoLinuxKPI: add Exponentially Weighted Moving Average implementation
Bjoern A. Zeeb [Mon, 24 May 2021 17:42:25 +0000 (17:42 +0000)]
LinuxKPI: add Exponentially Weighted Moving Average implementation

Add DECLARE_EWMA() which expands to a per-name EWMA implementation
as used by multiple wireless drivers.

Sposnored by: The FreeBSD Foundation
Reviewed by: hselasky, cperciva, dwmalone
Differential Revision: https://reviews.freebsd.org/D30415

(cherry picked from commit 32f753f27032849de685c15c471034cbc945a544)

3 years agoLinuxKPI: add linux/bsearch.h for sort(9)
Bjoern A. Zeeb [Mon, 24 May 2021 17:52:02 +0000 (17:52 +0000)]
LinuxKPI: add linux/bsearch.h for sort(9)

Add linux/bsearch.h which only includes libkern.h as the sort(9)
functions seem to be compatible.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30417

(cherry picked from commit f4a145b136ad88f7a9f38e3f7732bc5a8b5cb517)

3 years agoLinuxKPI: byteorder.h
Bjoern A. Zeeb [Mon, 24 May 2021 17:54:16 +0000 (17:54 +0000)]
LinuxKPI: byteorder.h

Add a few more le<n>_{tp,add}_cpu*() #defines/functions found in
wireless drivers.  While here fill most of the combinatorics gaps
and also add the remaining combinations [1].

Suggested by: emaste [1] (for one part)
Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30418

(cherry picked from commit 5aeeab54b0e1042b09dcea43540994c1ce43eebd)

3 years agoLinuxKPI: cache.h add SMP_CACHE_BYTES
Bjoern A. Zeeb [Mon, 24 May 2021 17:56:53 +0000 (17:56 +0000)]
LinuxKPI: cache.h add SMP_CACHE_BYTES

Add a definition for SMP_CACHE_BYTES and while here include sys/param.h
for CACHE_LINE_SIZE as otherwise code might not compile standalone.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30419

(cherry picked from commit e21652c13c7c161efac7fd0b247c73914312212a)

3 years agoLinuxKPI: compiler.h add three more defines
Bjoern A. Zeeb [Mon, 24 May 2021 17:59:13 +0000 (17:59 +0000)]
LinuxKPI: compiler.h add three more defines

Add fallthrough, ____cacheline_aligned_in_smp, and smp_mb() to
linux/compiler.h.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30420

(cherry picked from commit da717031c9fd914343e19ba87f19c7a9a7006721)

3 years agoLinuxKPI: add cpu.h for cpumask_*()
Bjoern A. Zeeb [Mon, 24 May 2021 18:01:59 +0000 (18:01 +0000)]
LinuxKPI: add cpu.h for cpumask_*()

Add linux/cpu.h for cpumask_*() functions found in wireless drivers
and make sure cpu_online_mask is always initialised.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30421

(cherry picked from commit 5fce802722cd4435a748d89043615324db4efe5e)

3 years agoLinuxKPI: add devcoredump.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:04:31 +0000 (18:04 +0000)]
LinuxKPI: add devcoredump.h

Add linux/devcoredump.h with stub implementation of dev_coredumpv()
and dev_coredumpsg() which only free the passed in SG table as needed
for iwlwifi.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30423

(cherry picked from commit 29923fea032a6ac7c0defd74d0b23468b16fda93)

3 years agoLinuxKPI: add dev_crit() to linux/device.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:07:31 +0000 (18:07 +0000)]
LinuxKPI: add dev_crit() to linux/device.h

Sponsored by: The FreeBSD Foundation
Reviewed by: emaste, hselasky
Differential Revision: https://reviews.freebsd.org/D30424

(cherry picked from commit e7a0b685405f8d51597079e3531f313d9e44b4a4)

3 years agoLinuxKPI: add ether_addr_equal_unaligned()
Bjoern A. Zeeb [Mon, 24 May 2021 18:09:37 +0000 (18:09 +0000)]
LinuxKPI: add ether_addr_equal_unaligned()

Replace the implementation for ether_addr_equal() with
ether_addr_equal_unaligned() and add a define for ether_addr_equal()
pointing to the now ether_addr_equal_unaligned() implementation.
This way ether_addr_equal_unaligned() cannot be broken by accident [1].

Suggested by: emaste [1]
Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30425

(cherry picked from commit 834227ba6e80dc0899d2372ae8986241f5658c4e)

3 years agoLinuxKPI: net/if_inet6.h add struct inet6_dev { }
Bjoern A. Zeeb [Mon, 24 May 2021 18:11:56 +0000 (18:11 +0000)]
LinuxKPI: net/if_inet6.h add struct inet6_dev { }

Add a dummy struct inet6_dev {}; to net/if_inet6.h.  This is currently
not used for anything but in a declaration.  Just needs to be there.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30426

(cherry picked from commit ff09f9133f2fb80f705c2c742fc34291b05140af)

3 years agoLinuxKPI: add irq_set_affinity_hint()
Bjoern A. Zeeb [Mon, 24 May 2021 18:14:37 +0000 (18:14 +0000)]
LinuxKPI: add irq_set_affinity_hint()

Add an implementation for irq_set_affinity_hint() to linux/interrupt.h
and include linux/hardirq.h for synchronize_irq() as needed by
wireless drivers.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30427

(cherry picked from commit 602e4e433d3e7dbb03d4fd30a4720a02cdeca6aa)

3 years agoLinuxKPI: add linux/{ip,tcp,udp}.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:17:30 +0000 (18:17 +0000)]
LinuxKPI: add linux/{ip,tcp,udp}.h

Add header files for struct and accessors for IPv4, UDP, and TCP.
Only parts of the fields of the structs have been seen while working
on wireless drivers.  The remaining field names are filled up with
the FreeBSD field names for now.  If you have insights into their
correct naming in Linux, feel free to adjust.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30428

(cherry picked from commit b26fb63f2b96fddf640260dc4a5acd703c7d425c)

3 years agoLinuxKPI: ipv6.h add missing #include
Bjoern A. Zeeb [Mon, 24 May 2021 18:21:55 +0000 (18:21 +0000)]
LinuxKPI: ipv6.h add missing #include

Include linux/bitops.h for a definition of BITS_PER_LONG so that this
file can be used independently.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30429

(cherry picked from commit 762efb2d6dd67f7b999d40b10d58828efb473236)

3 years agoLinuxKPI: add time_is_after_jiffies() definition
Bjoern A. Zeeb [Mon, 24 May 2021 18:24:13 +0000 (18:24 +0000)]
LinuxKPI: add time_is_after_jiffies() definition

This is used by wireless drivers.  Use the time_after() macro as
done for the "after_eq" version.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30430

(cherry picked from commit 8620fe4c10922b12492155d97b913deb6c5d82c6)

3 years agoLinuxKPI: change BUILD_BUG_ON()
Bjoern A. Zeeb [Mon, 24 May 2021 18:26:41 +0000 (18:26 +0000)]
LinuxKPI: change BUILD_BUG_ON()

BUILD_BUG_ON() can be used inside functions where the definition to
CTASSERT() (_Static_assert()) seems to not work.
Go back to an old-style CTASSERT() implementation but also add a
variable dclaration to avoid "unsued typedef" errors and dummy-use
the variable to avoid "unusued variable" errors.  Given it is all
self-contained in a block and not used outside this should be
optimised away.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30431

(cherry picked from commit 1082490cd867a4d443862523c37ce947735342d0)

3 years agoLinuxKPI: add ktime_get_boottime_ns() implementation to ktime.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:30:33 +0000 (18:30 +0000)]
LinuxKPI: add ktime_get_boottime_ns() implementation to ktime.h

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30432

(cherry picked from commit 18d303b05f28acf005dad3f2ffbbec4895181dde)

3 years agoLinuxKPI: add LINUXKPI_PARAM_charp()
Bjoern A. Zeeb [Mon, 24 May 2021 18:32:11 +0000 (18:32 +0000)]
LinuxKPI: add LINUXKPI_PARAM_charp()

Add yet another version of the various module_param_named() use cases.
This one deals with "charp".

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30433

(cherry picked from commit c1661d59e68e29a817c870f421a6871563039dbb)

3 years agoLinuxKPI: add more #defines to pci.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:36:18 +0000 (18:36 +0000)]
LinuxKPI: add more #defines to pci.h

Add more definitions for various PCI uses to linux/pci.h.  Almost all
are defined to their FreeBSD counterparts which are described there.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30434

(cherry picked from commit fc1d840901b1aefe22924d772781e2c835edb096)

3 years agoLinuxKPI: add prandom_u32() as used by wireless drivers.
Bjoern A. Zeeb [Mon, 24 May 2021 18:38:58 +0000 (18:38 +0000)]
LinuxKPI: add prandom_u32() as used by wireless drivers.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30435

(cherry picked from commit 10096cb60619984eefc628471f219d4723867bb1)

3 years agoLinuxKPI: add rcu_dereference_check()
Bjoern A. Zeeb [Mon, 24 May 2021 18:40:42 +0000 (18:40 +0000)]
LinuxKPI: add rcu_dereference_check()

Add a define for rcu_dereference_check() to rcu_dereference_protected()
which ignores the check argument.  Our lockdep compat implementation
for use cases found in iwlwifi would return 1 anyway.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30436

(cherry picked from commit fa58da02f708a22200a89032b8eaf35e1c8ef4a6)

3 years agoLinuxKPI: add kfree_sensitive() using zfree().
Bjoern A. Zeeb [Mon, 24 May 2021 18:43:33 +0000 (18:43 +0000)]
LinuxKPI: add kfree_sensitive() using zfree().

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30437

(cherry picked from commit abcac97f8202d91b61ae4846794ba60166a56cfe)

3 years agoLinuxKPI: extract stringify() in their own header file
Bjoern A. Zeeb [Mon, 24 May 2021 18:53:28 +0000 (18:53 +0000)]
LinuxKPI: extract stringify() in their own header file

Add linux/stringify.h as directly included by drivers.  Remove the
definitions from compiler.h and include the new header in places
where the stringify macros are already used without linuxkpi.

I have adjusted the Copyright of the new file according to the commit
originaly adding the macros (99e690772adbcb78c9e8441bedcf1913d72ea72f).

Sposnored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30440

(cherry picked from commit 43b4c00643bacb9d1ba3aa1022648104bc7ff4a2)

3 years agoLinuxKPI: add kernel_ulong_t typedef in linux/kernel.h.
Bjoern A. Zeeb [Mon, 24 May 2021 18:47:49 +0000 (18:47 +0000)]
LinuxKPI: add kernel_ulong_t typedef in linux/kernel.h.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30438

(cherry picked from commit 5878c7c7b090c8579316ae4479e962684d49a499)

3 years agoLinuxKPI: add guid_t for ACPI consumers.
Bjoern A. Zeeb [Mon, 24 May 2021 18:50:10 +0000 (18:50 +0000)]
LinuxKPI: add guid_t for ACPI consumers.

Add a placeholder struct for guid_t which is needed by ACPI consumers
in at least one wireless driver.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30439

(cherry picked from commit cae1683120e2bf8e39901d29a17c473401653985)

3 years agoLinuxKPI: treat firmware file names more lenient
Bjoern A. Zeeb [Wed, 31 Mar 2021 15:25:01 +0000 (15:25 +0000)]
LinuxKPI: treat firmware file names more lenient

A lot of firmware files have a "-" in the name.  That "-" is a problem
when dealing with shell variables or loader (e.g., auto-loading .ko).
It may thus often be convenient to generate firmware kernel object files
with s/-/_/g in the name.  In order to automatically find them from
drivers using LinuxKPI also substitue the '-' for a '_' like we do
for '/' and '.' already.

Reviewed by: hselasky, manu (ok)
Differential Revision: https://reviews.freebsd.org/D29514

(cherry picked from commit 37c3241a43160dd236bd4767fce46e846cb17227)

3 years agomlx5: remove dependency on ifnet specifics of linux/netdevice.h
Bjoern A. Zeeb [Tue, 30 Mar 2021 15:58:55 +0000 (15:58 +0000)]
mlx5: remove dependency on ifnet specifics of linux/netdevice.h

Rename the last remaining bits depending on ifnet from linux/netdevice.h
instead of using the compat macros. This helps clearing up
struct netdevice being struct ifnet from linux/netdevice.h.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, kib
Differential Revision: https://reviews.freebsd.org/D29497

(cherry picked from commit 4ded022d3b8948e92c8f8353364ff2c79d720e68)

3 years agoLinuxKPI/OFED: (re)move inetdevice.h implementation
Bjoern A. Zeeb [Fri, 26 Mar 2021 17:52:24 +0000 (17:52 +0000)]
LinuxKPI/OFED: (re)move inetdevice.h implementation

The two functions in linux/inetdevice.h are highly FreeBSD/ifnet
specific.  This is a result of struct net_device being mapped to
struct ifnet.

The only known consumer of these functions are two files in the
ofed/infiniband code.

As a first step of cleaning up copy linux/inetdevice.h to
rdma/ib_addr_freebsd.h. (It stayed a separate file to preserve
copyright and license of the original file; otherwise it could be
merged into ib_addr.h where more EPOCH/vnet/.. are already used).

Slightly rename the function to not conflict with LinuxKPI
in the future.

Remove the three last, now unneeded includes of inetdevice.h and
zap linux/inetdevice.h to an empty header file with only the forward
include to netdevice.h remaining.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, kib
Differential Revision: https://reviews.freebsd.org/D29434

(cherry picked from commit 7069b4c6a4e516e1435d8beb7a436d88193156d3)

3 years agocxgbe: remove unused linux headers
Bjoern A. Zeeb [Fri, 26 Mar 2021 16:10:25 +0000 (16:10 +0000)]
cxgbe: remove unused linux headers

Remove unused #includes of LinuxKPI headers noticed while trying to
solve LinuxKPI struct net_device and related functions.
Neither netdevice.h nor inetdevice.h nor notifier.h seem to be needed.
This takes cxgbe(4) out of the picture of D29366.

Sponsored by: The FreeBSD Foundation
Reviewed by: np
Differential Revision: https://reviews.freebsd.org/D29432

(cherry picked from commit 0a7b99553f5c1e68868e3cbaccb3160eb1a7d1d6)

3 years agoqlnxr: remove netdevice.h
Bjoern A. Zeeb [Fri, 26 Mar 2021 17:17:10 +0000 (17:17 +0000)]
qlnxr: remove netdevice.h

Remove unused #includes of a LinuxKPI header noticed while trying to
solve LinuxKPI struct net_device and related functions.
This takes qlnxr out of the picture of D29366.

Sponsored by: The FreeBSD Foundation
(cherry picked from commit 6c8dd7c863f111a22c8548ebf5d7e889117a964d)

3 years agomlx4: remove no longer needed header
Bjoern A. Zeeb [Fri, 26 Mar 2021 15:28:24 +0000 (15:28 +0000)]
mlx4: remove no longer needed header

Remove linux/inetdevice.h as neither of the two inline functions there
are used here.

Sposored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29428

(cherry picked from commit 5a461a86cf5bb0ac4ffde3caf03df0386ddad6cc)

3 years agoLinuxKPI: netdevice notifier callback argument
Bjoern A. Zeeb [Sun, 21 Mar 2021 21:18:34 +0000 (21:18 +0000)]
LinuxKPI: netdevice notifier callback argument

Introduce struct netdev_notifier_info as a container to pass
net_device to the callback functions.
Adjust netdev_notifier_info_to_dev() to return the net_device field.

Add explicit casts from ifp to ni->dev even though currently
struct net_device is defined to struct ifnet.  This is needed in
preparation for untangling this and improving the net_device compat
code.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29365

(cherry picked from commit fdcfe8a298e23bef9588cafad2672e0c5f48a327)

3 years agoLinuxKPI: add net_ratelimit()
Bjoern A. Zeeb [Tue, 23 Mar 2021 17:00:22 +0000 (17:00 +0000)]
LinuxKPI: add net_ratelimit()

Add a net_ratelimit() compat implementation based on ppsratecheck().
Add a sysctl to allow tuning of the number of messages.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29399

(cherry picked from commit bc042266b2bfc3f52f685df7ccdd6e857b4b9da9)

3 years agoqlnxr: remove duplicate defines
Bjoern A. Zeeb [Tue, 23 Mar 2021 14:31:37 +0000 (14:31 +0000)]
qlnxr: remove duplicate defines

upper_32_bits() and lower_32_bits() are defined twice in this file.
With the extra conditinal removed on LinuxKPI in 3b1ecc9fa1b5
they are also included from there already.  Use the LinuxKPI version
and remove the two local ones.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29392

(cherry picked from commit 5df6f7a8405899fac795f227de96ebadd10d60af)

3 years agoLinuxKPI: remove < 5.0 version support
Bjoern A. Zeeb [Tue, 23 Mar 2021 14:24:49 +0000 (14:24 +0000)]
LinuxKPI: remove < 5.0 version support

We are not aware of any out-of-tree consumers anymore
which would need KPI support for before Linux version 5.
Update the two in-tree consumers to use the new KPI.
This allows us to remove the extra version check and
will also give access to {lower,upper}_32_bits() unconditionally.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, rlibby, rstone
X-MFC: to 13 only
Differential Revision: https://reviews.freebsd.org/D29391

(cherry picked from commit 3b1ecc9fa1b57ca7a1c86661e9a323bc41c97ecc)

3 years agoLinuxKPI: add lockdep_map
Bjoern A. Zeeb [Tue, 23 Mar 2021 16:51:08 +0000 (16:51 +0000)]
LinuxKPI: add lockdep_map

Add stubs for struct lockdep_map and three accessor functions
used by iwlwifi.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D29398

(cherry picked from commit f1069375d97384754a9e8ee8bc21a32d3ad10987)

3 years agoLinuxKPI: add pci_ids.h
Bjoern A. Zeeb [Tue, 23 Mar 2021 17:13:15 +0000 (17:13 +0000)]
LinuxKPI: add pci_ids.h

brcm80211 include pci_ids.h directly while historically we were tracking
IDs in pci.h.  Move the current set of IDs from pci.h to pci_ids.h and
while here add IDs for Realtek and Broadcom as well as a network class
as needed by their wireless drivers.

We still include pci_ids.h from pci.h so this should not change anything.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29400

(cherry picked from commit 5a402a3ae3975abb573ca9b53ff8cfe204c3771f)

3 years agoLinuxKPI: if_ether additions
Bjoern A. Zeeb [Tue, 23 Mar 2021 16:44:56 +0000 (16:44 +0000)]
LinuxKPI: if_ether additions

Add various protocol IDs found in various wireless drivers.
Also add ETH_FRAME_LEN and struct ethhdr.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29397

(cherry picked from commit 3cce818c46f58c0089d34a00478c3b7fa3b57c09)

3 years agoLinuxKPI: add more linux-specific errno
Bjoern A. Zeeb [Tue, 23 Mar 2021 16:37:35 +0000 (16:37 +0000)]
LinuxKPI: add more linux-specific errno

Add ERFKILL and EBADE found in iwlwifi and brcmfmac wireless drivers.
While here add a comment above the block of error numbers above 500 to
document expectations.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D29396

(cherry picked from commit 4b0632cfc5c86587668b1d5d2ddc26d445072b03)

3 years agoofed/linuxkpi: use proper accessor function
Bjoern A. Zeeb [Sun, 21 Mar 2021 21:07:45 +0000 (21:07 +0000)]
ofed/linuxkpi: use proper accessor function

In the notifier event callback function rather than casting directly
to the expected type use the proper accessor function as the mlx drivers
already do.
This is preparational work to allow us to improve the struct net_device
is struct ifnet compat code shortcut in the future.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29364

(cherry picked from commit a29bbfe6c6e41691bdd3bd0e5be89089523485d6)

3 years agolinuxkpi: add ieee80211_node.h to headers to include before LIST_HEAD
Bjoern A. Zeeb [Thu, 18 Mar 2021 22:23:15 +0000 (22:23 +0000)]
linuxkpi: add ieee80211_node.h to headers to include before LIST_HEAD

ieee80211_node.h uses LIST_HEAD() which LinuxKPI redefines and this
can lead to problems (see comment there).  Make sure the net80211
header file is handled correctly by adding it to the list of files
to include before re-defining the macro.
Also add header files needed as dependencies.

Sponsored by: The FreeBSD Foundation
Reviewed by: philip, hselasky
Differential Revision: https://reviews.freebsd.org/D29336

(cherry picked from commit de8a7cc703f1d3eab293d53fbc8269e1aca3a6ab)

3 years agoLinuxKPI: add support for crc32_le()
Bjoern A. Zeeb [Wed, 10 Mar 2021 15:01:10 +0000 (15:01 +0000)]
LinuxKPI: add support for crc32_le()

Add support for crc32_le() as a wrapper around crc32_raw().

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29187

(cherry picked from commit 0c7b75f12840a31206ae24acca1f5ee35c8e341d)

3 years agoifconfig: 80211, add line break after key info
Bjoern A. Zeeb [Tue, 23 Mar 2021 15:08:46 +0000 (15:08 +0000)]
ifconfig: 80211, add line break after key info

Beauty correction for verbose mode or in case we print multiple key
information to not continue with the next options directly after
as we did so far, e.g.:
AES-CCM 2:128-bit
AES-CCM 3:128-bit powersavemode ...

Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D29393

(cherry picked from commit 5ba4c8de15210bbc026c41b77b23d5af06613fe6)

3 years agonet80211: prefix get_random_bytes() with net80211_
Bjoern A. Zeeb [Thu, 18 Mar 2021 22:15:00 +0000 (22:15 +0000)]
net80211: prefix get_random_bytes() with net80211_

Both linux/random.h and net80211 have a function named
get_random_bytes().  With overlapping files included these collide.
Arguably the function could be renamed in linuxkpi but the generic
name should also not be used in net80211 so rename it there.

Sponsored by: The FreeBSD Foundation
Reviewed by: philip, adrian
Differential Revision: https://reviews.freebsd.org/D29335

(cherry picked from commit af7d9f8e31c4c185f277b27059e470ec8a5627a7)

3 years agolib80211: Start adding 11ac ETSI bits to regdomain.xml
Bjoern A. Zeeb [Sun, 18 Jul 2021 00:32:41 +0000 (00:32 +0000)]
lib80211: Start adding 11ac ETSI bits to regdomain.xml

This change currently (partially) duplicates AC1 freqbands as AC2
as they are not fully overlapping.
It then adds the 11ac netband to the "etsi" domain including
"indoor" and "dfs" flags, which we can deal with, as well as
appropriate (round down) maxpower values.
Comments are left for the actual frequency bands as we do use the
centerfreq for the first/last (chansep sized) channel in the
freqband and their "id" name, which can be confusing.

Reviewed by: philip, adrian
Differential Revision: https://reviews.freebsd.org/D25999

(cherry picked from commit 2ad93dade70a9c98174fc87d0cd24fd54bd0d120)

3 years agonet80211: split up ieee80211_probereq()
Bjoern A. Zeeb [Sun, 18 Jul 2021 00:32:19 +0000 (00:32 +0000)]
net80211: split up ieee80211_probereq()

Factor out ieee80211_probereq_ie() and ieee80211_probereq_ie_len()
and make the length dynamic rather than static max.  The latter is
needed as our current fixed length was longer than some "hw scan",
e.g. that of ath10k, will take.  This way we can pass what we have.
Should this not be sufficient in the future we might have to deal
with filtering and much more error handling.

This also removes a duplicate calculation for ieee80211_ie_wpa [1].

c338cf2c6d5eacdee813191d5976aa531d450ee7 split up ieee80211_probereq_ie().
For HW scans we usually do not want to add a SSID to the IEs.
During that split we allocate memory based on the length which will
always include the length of the SSID and only later we reduced the
length but never updated the value passed back to the caller.
Split the SSID handling up and reduce the length before malloc().
This not only makes us not over-allocate in these situatoins but also
fixes the length returned to the caller and with that usually directly
passed to firmware.

Repoprted by: Martin Husemann <martin NetBSD.org> [1]
Sponsored by: Rubicon Communications, LLC ("Netgate")
Sponsored by: The FreeBSD Foundation (update for alloc)
Reviewed by: adrian, martin NetBSD.org (earlier version)
Reviewed by: philip
Differential Revision: https://reviews.freebsd.org/D26545
Differential Revision: https://reviews.freebsd.org/D30813

(cherry picked from commit c338cf2c6d5eacdee813191d5976aa531d450ee7)
(cherry picked from commit 243b95978debac3db06df6d26ca9f8d84f6cbd83)

3 years agonet80211: ratectl header guard against multiple inclusions
Bjoern A. Zeeb [Sun, 7 Mar 2021 17:35:58 +0000 (17:35 +0000)]
net80211: ratectl header guard against multiple inclusions

Add missing #ifndef/#define/#endif guards against multiple inclusions
to ieee80211_ratectl.h as they are missing.

(cherry picked from commit 3fca90af438ac4232d6b33ee4874297089997dd6)

3 years agonet80211: rx_stats add 160Mhz channel width.
Bjoern A. Zeeb [Sun, 28 Feb 2021 19:24:22 +0000 (19:24 +0000)]
net80211: rx_stats add 160Mhz channel width.

Add the missing receive stat(u)s flag for 160Mhz channel width.
While here correct the comment for c_phytype to reference the correct
flags.

(cherry picked from commit a9cc796fa73de2e80a2d989ba7c2c5a7c7ce9f2e)

3 years agotermios: add more speeds
Bjoern A. Zeeb [Wed, 10 Mar 2021 22:17:07 +0000 (22:17 +0000)]
termios: add more speeds

A lot of small arm64 gadgets are using 1500000 as console speed.
While cu can perfectly deal with this some 3rd party software, e.g.,
comms/conserver-con add speeds based on B<n> being defined.
Having it defined here simplifies enhancing other software.

Obtained from: NetBSD sys/sys/termios.h 1.36
Reviewed by: philip (,okayed by imp)
Differential Revision: https://reviews.freebsd.org/D29209

(cherry picked from commit 0209400ceaed553a3f06a5f3759de992ddb58037)

3 years agopci: enhance printf for leaked MSI[-X] vectors
Bjoern A. Zeeb [Tue, 23 Mar 2021 15:47:24 +0000 (15:47 +0000)]
pci: enhance printf for leaked MSI[-X] vectors

When debugging leaked MSI/MSI-X vectors through LinuxKPI I found
the informational printf unhelpful.  Rather than just stating we
leaked also tell how many MSI or MSI-X vectors we leak.

Sponsored by: The FreeBSD Foundation
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D29394

(cherry picked from commit a9f0367b04b385e7bed47914662badf5ab18bc88)

3 years agoprocctl(PROC_ASLR_STATUS): fix vmspace leak
Konstantin Belousov [Wed, 14 Jul 2021 23:40:04 +0000 (02:40 +0300)]
procctl(PROC_ASLR_STATUS): fix vmspace leak

(cherry picked from commit 0bdb2cbf9d7c4366a0668b4563c8630538a50086)

3 years agoUse sleepq_signal(SLEEPQ_DROP) in cv_signal().
Alexander Motin [Sat, 10 Jul 2021 00:52:40 +0000 (20:52 -0400)]
Use sleepq_signal(SLEEPQ_DROP) in cv_signal().

Same as wakeup_one()/wakeup_any() commit before it reduces the lock
hold time and so contention.

MFC after: 1 week

(cherry picked from commit 63ca9ea4f34d887b66c7b9f1710f5e4be543ebed)

3 years agox86: use ANSI C definition style for trap_fatal
Konstantin Belousov [Sat, 10 Jul 2021 10:59:32 +0000 (13:59 +0300)]
x86: use ANSI C definition style for trap_fatal

PR: 257062

(cherry picked from commit 55e63ed307fb099722cf6d30a18c9badab9b5d03)

3 years agoamd64 pmap: unexpand the NBPDR macro definition
Konstantin Belousov [Sat, 10 Jul 2021 11:07:41 +0000 (14:07 +0300)]
amd64 pmap: unexpand the NBPDR macro definition

(cherry picked from commit fdc71fa112d66c7c0aba9ff80adc7b8bb22ea6ca)

3 years agoamd64 locore.S: trim .globl list from symbols gone for long time
Konstantin Belousov [Sat, 10 Jul 2021 11:04:31 +0000 (14:04 +0300)]
amd64 locore.S: trim .globl list from symbols gone for long time

(cherry picked from commit 9dc715230ccab1c3ad17f076379d29a017059030)

3 years agoamd64 mpboot.S: fix typo in comment
Konstantin Belousov [Sat, 10 Jul 2021 11:06:44 +0000 (14:06 +0300)]
amd64 mpboot.S: fix typo in comment

(cherry picked from commit 71463a34ab3f65ff109b529f2fae93b694b73fdd)

3 years agoamd64 locore.S: add FF copyright for LA57 work
Konstantin Belousov [Sat, 10 Jul 2021 11:05:19 +0000 (14:05 +0300)]
amd64 locore.S: add FF copyright for LA57 work

(cherry picked from commit 63664df72036dc8ee99bd83fecc91faf167fa232)

3 years agoloader: Don't reserve space for symbols twice.
Warner Losh [Mon, 12 Jul 2021 21:17:05 +0000 (15:17 -0600)]
loader: Don't reserve space for symbols twice.

The current code bumps lastaddr twice for the symbol table
location. However, the first bump is bogus and results in wasted
space. Remove it.

PR: 110995
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31017

(cherry picked from commit 297e9f364b5aa243572ee52b1faef9b3542c1c9e)

3 years agoloader: update autoboot description and move to loader.conf.5
Daniel Gerzo [Mon, 12 Jul 2021 21:13:03 +0000 (15:13 -0600)]
loader: update autoboot description and move to loader.conf.5

Document "NO" special value for the autoboot_delay and move the
description to loader.conf.5.

imp reworked some of the wording from danger's patch.

Reviewed by: imp
PR: 85128
Differential Revision: https://reviews.freebsd.org/D11887

(cherry picked from commit 71f6aea4150c66784cbad42c1e1ff908d909c2ec)

3 years agoMINIMAL: remove debugging and some loadable network modules
Helge Oldach [Sun, 11 Jul 2021 16:21:11 +0000 (10:21 -0600)]
MINIMAL: remove debugging and some loadable network modules

Remove deugging stuff, since it's arguably not needed in a minimal
setup. Also vlan, tuntap and gif since they can be loaded.

imp didn't include the part of the patch that removed xen guest support.
Xen guest is relatively small and has no way of being loaded.

Reviewed by: imp
PR: 229564
MFC After: 3 days

(cherry picked from commit b21f19c9e0b7f3c923d845e9e31c0552f0162a62)

3 years agonanobsd: enhance fill_pkg.sh
Lev A. Serebryakov [Sun, 11 Jul 2021 15:04:39 +0000 (09:04 -0600)]
nanobsd: enhance fill_pkg.sh

NanoBSD has helper script "fill_pkg.sh" which links all packages and
ther dependencies from "package dump" (like /usr/ports/packages/All) to
specified director. fill_pkg.sh has some limitations:

1) It needs ports tree, which should have exactly same versions as
   "package dump".
2) It requires full paths to needed ports, including "/usr/ports" part.
3) It has assumptions about Nano Package Dir (it assumes, that it
   specified rtelative to current directory).
4) It does not have any diagnostics (almost).

This PR enhances "fill_pkg.sh" script in several ways:

1) Nano package dir could be absolute path.
2) Script understands four ways to specify "root" ports/packages:
   (a) Absolute directory with port (old one)
   (b) Relative directory with port, relative to ${PORTSDIR} or /usr/ports
   (c) Absolute path to file with package (with .tbz suffix)
   (d) Name of package in dump dir, with or without .tbz suffix

   These ways can be mixed in one call. Dependencies for
   packages are obtained with 'pkg_info -r' call, and are searched for
   in same directory as "parent" package. Dependencies for ports are
   obtained in old way from port's Makefile.
3) Three levels of diagnostic (and -v option, could be repeated) are added.
4) All path variables are enclosed in quotes, to make script work with paths,
   containing spaces.

Note: imp merged in the changes to fill_pkg.sh since this has been a PR.

PR: 151695
Reviewed by: imp@
MFC After: 3 days
Differential Revision: https://reviews.freebsd.org/D31101

(cherry picked from commit 36cfb5d50f8e8856695780a6792fb7e81816e9ee)

3 years agoloader: support.4th resets the read buffer incorrectly
John Hood [Sun, 11 Jul 2021 14:44:12 +0000 (08:44 -0600)]
loader: support.4th resets the read buffer incorrectly

Large nextboot.conf files (over 80 bytes) are not read correctly by the
Forth loader, causing file parsing to abort, and nextboot configuration
fails to apply.

Simple repro:

nextboot -e foo=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
shutdown -r now

That will cause the bug to cause a parse failure but shouldn't otherwise
affect the boot.  Depending on your loader configuration, you may also
have to set beastie_disable and/or reduce the number of modules loaded
to see the error on a small console screen.  12.0 or CURRENT users will
also have to explicitly use the Forth loader instead of the Lua loader.
The error will look something like:

Warning: syntax error on file /boot/loader.conf.local
foo="xxxxxxxxxxxxxxnextboot_enable="YES"
                                    ^
/boot/support.4th has crude file I/O buffering, which uses a buffer
'read_buffer', defined to be 80 bytes by the 'read_buffer_size'
constant.  The loader first tastes nextboot.conf, reading and parsing
the first line in it for nextboot_enable="YES".  If this is true, then
it reopens the file and parses it like other loader .conf files.

Unfortunately, the file I/O buffering code does not fully reset the
buffer state in the reset_line_reading word.  If the last file was read
to the end, that doesn't matter; the file buffer is treated as empty
anyway.  But in the nextboot.conf case, the loader will not read to the
end of file if it is over 80 bytes, and the file buffer may be reused
when reading the next file.  When the file is reread, the corrupt text
may cause file parsing to abort on bad syntax (if the corrupt line has
<>2 quotes in it), the wrong variable to be set, no variable to be set
at all, or (if the splice happens to land at a line ending) something
approximating normal operation.

The bug is very old, dating back to at least 2000 if not before, and is
still present in 12.0 and CURRENT r345863 (though it is now hidden by
the Lua loader by default).

Suggested one-line attached.  This does change the behavior of the
reset_line_reading word, which is exported in the line-reading
dictionary (though the export is not documented in loader man pages).
But repo history shows it was probably exported for the PNP support
code, which was never included in the loader build, and was removed 5
months ago.

One thing that puzzles me: how has this bug gone unnoticed/unfixed for
nearly 2 decades?  I find it hard to believe that nobody's tried to do
something interesting with nextboot, like load a kernel and filesystem,
which is what I'm doing.

PR: 239315
Reviewed by: imp

(cherry picked from commit 9c1c02093b90ae49745a174eb26ea85dd1990eec)

3 years agomk: LZMA_SUPPORT is unused
Warner Losh [Sat, 10 Jul 2021 16:52:12 +0000 (10:52 -0600)]
mk: LZMA_SUPPORT is unused

Retire LZMA_SUPPORT. It's unused since r332995.

Reviewed by: delphij
PR: 244302
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31088

(cherry picked from commit d8514fa6f1b0b9824b169c5ab66f37713b303c57)

3 years agoarm: remove fslsdma from GENERIC
MIHIRA Sanpei Yoshiro [Fri, 9 Jul 2021 17:12:39 +0000 (11:12 -0600)]
arm: remove fslsdma from GENERIC

The fslsdma device requires sdma_fw, but that's not included in
GENERIC. That firmware is not in the FreeBSD tree at the moment, but
could easily be.

The license for the firmware can be found in the linux firmware repo:
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/commit/?id=3123d78e09d2f815de4d94aa35c07b3c0469c80e
and looks to be a BSD license + no reverse engineer.

We can add this back after the firmware is imported, made a port, or
whose automatic loading can be made to happen.

Reviewed by: imp (with ian finding the license)
PR: 237466
MFC after: 1 week

(cherry picked from commit 9e3761d126c5c019d6c935e83989928eb1a0e76e)

3 years agodevmatch: don't announce autoloading so much
Warner Losh [Thu, 8 Jul 2021 19:53:18 +0000 (13:53 -0600)]
devmatch: don't announce autoloading so much

devmatch rc script would announce it was loading a module multiple
times. It used kldload -n so it really wasn't loading it that many
times, but the message is confusing. Use kldstat to see if we need to
load the module before saying we do. This fixes the vast majority of the
problems. It may be possible to race devmatch with a user invocation and
devd, though quite hard. In that case we'll announce things twice, but
still only load it once. No attempt is made to fix this.

PR: 232782
MFC After: 2 weeks
Sponsored by: Netflix

(cherry picked from commit 5549c6a62f0f4fc5d7e80973b28ebcf7f556edf8)

3 years agodevmatch: Be tolerant of .ko being present.
Warner Losh [Thu, 8 Jul 2021 19:44:21 +0000 (13:44 -0600)]
devmatch: Be tolerant of .ko being present.

We document that we did not need .ko on the module names in
devmatch_blocklist, but we really needed them. Keep the documentation
the same, but strip the .ko when we need to use the names so you can
specify either.

PR: 256240
MFC After: 2 weeks
Sponsored by: Netflix

(cherry picked from commit b29ebb9c65b350e78aedfc790bfcaf9717059b70)

3 years agodevmatch: defer until after kld
Helge Oldach [Wed, 7 Jul 2021 20:43:35 +0000 (14:43 -0600)]
devmatch: defer until after kld

devmatch loads a number of things automatically. Allow the list of
things to load to happen first in case those drivers affect what would
be loaded. Normally, this will produce the same results, but there's
some special cases that may not when drivers are loaded that report
other drivers missing, like virtio_pci.

PR: 253287
Reviewed by: imp
MFC After: 2 weeks

(cherry picked from commit f68e3ea831b76a8927eed7f7abfea55ee5a193c4)

3 years agopf: bound DIOCGETSTATESV2 memory use
Kristof Provost [Thu, 8 Jul 2021 13:01:19 +0000 (15:01 +0200)]
pf: bound DIOCGETSTATESV2 memory use

Rather than allocating however much memory userspace asks for we only
allocate enough for a handful of states, and copy to userspace for each
completed row.
We start out with enough space for 16 states (per row), but grow that as
required. In most configurations we expect at most a handful of states
per row (more than that would have other negative effects on packet
processing performance).

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

(cherry picked from commit 3fc12ae042040192aa43984106a75663aaa9e0f5)

3 years agolibpfctl: migrate to DIOCGETSTATESV2
Kristof Provost [Tue, 6 Jul 2021 11:05:19 +0000 (13:05 +0200)]
libpfctl: migrate to DIOCGETSTATESV2

Stop using the *NV version to retrieve states, as its performance is
unacceptably bad.

For 1,000,000 states the nvlist version needed ~100 seconds to retrieve
the states, the new version needs ~3 seconds.

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

(cherry picked from commit be70c7a50d324dd56f3a0d37d8372e7855dd580b)

3 years agopf: add DIOCGETSTATESV2
Kristof Provost [Tue, 6 Jul 2021 10:12:12 +0000 (12:12 +0200)]
pf: add DIOCGETSTATESV2

Add a new version of the DIOCGETSTATES call, which extends the struct to
include the original interface information.

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

(cherry picked from commit c6bf20a2a46dc36bf881ac594454f71379828a9a)

3 years agodummynet: reduce console spam
Luiz Otavio O Souza [Thu, 11 Feb 2016 13:35:01 +0000 (07:35 -0600)]
dummynet: reduce console spam

Only print this warning when boot verbose is enabled.
This can get pretty annoying (and useless) in some systems.

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

(cherry picked from commit c5dd8bac0b96e11da02181bd1dbee677e270842d)

3 years agopf: pf_killstates() never fails, so remove the return value
Kristof Provost [Thu, 8 Jul 2021 08:54:16 +0000 (10:54 +0200)]
pf: pf_killstates() never fails, so remove the return value

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

(cherry picked from commit 34641052826c718566b994b75cd2bddb53a21583)

3 years agopf: Handle errors returned by pf_killstates()
Kristof Provost [Mon, 5 Jul 2021 12:21:03 +0000 (14:21 +0200)]
pf: Handle errors returned by pf_killstates()

Happily this wasn't a real bug, because pf_killstates() never fails, but
we should check the return value anyway, in case it does ever start
returning errors.

Reported by: clang --analyze
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit fa96701c8abbc29aad7f8f8d6b823bd7f89c6c15)

3 years agopf: Remove unneeded NULL check
Kristof Provost [Mon, 5 Jul 2021 12:02:06 +0000 (14:02 +0200)]
pf: Remove unneeded NULL check

pidx is never NULL, and is used unconditionally later on in the
function.
Add an assertion, as documentation for the requirement to provide an idx
pointer.

Reported by: clang --analyze
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 8cceacc0f1ee6a77c5f0566b8e6b0f054160fb20)

3 years agorc.d: connect sysctl_lastload
Eugene Grosbein [Thu, 20 May 2021 04:51:31 +0000 (11:51 +0700)]
rc.d: connect sysctl_lastload

Add recently added sysctl_lastload.

(cherry picked from commit 20eb969793921dce9e524d19fc02b84cabd98f74)

3 years agoipfw: reload sysctl.conf variables if needed
Eugene Grosbein [Mon, 17 May 2021 21:03:15 +0000 (04:03 +0700)]
ipfw: reload sysctl.conf variables if needed

Currently ipfw has multiple components that are not parts
of GENERIC kernel like dummynet etc. They can bring in important
sysctls if enabled with rc.conf(5) and loaded with ipfw startup script
by means of "required_modules" after initial consult
with /etc/sysctl.conf at boot time. Here is an example of one
increasing limit for dummynet hold queues that defaults to 100:

net.inet.ip.dummynet.pipe_slot_limit=1000

This makes it possible to use ipfw/dummynet rules such as:

ipfw pipe 1 config bw 50Mbit/s queue 1000

Such rule is rejected unless above sysctl is applied.
Another example is a group of net.inet.ip.alias.* sysctls
created after libalias.ko loaded as dependency of ipfw_nat.

This is not a problem if corresponding code compiled in custom kernel
so sysctls exist when sysctl.conf is read early or kernel modules
loaded with a loader. This change makes it work also for GENERIC
and modules loaded by means of rc.conf(5) settings.

(cherry picked from commit f5b5de1a3210234f3a6864c88a2d3e11ac2dbf04)

3 years agorc.d: unbreak sysctl lastload
Eugene Grosbein [Wed, 19 May 2021 13:02:31 +0000 (20:02 +0700)]
rc.d: unbreak sysctl lastload

/etc/rc.d/securelevel is supposed to run /etc/rc.d/sysctl lastload
late at boot time to apply /etc/sysctl.conf settings that fail
to apply early. However, this does not work in default configuration
because of kern_securelevel_enable="NO" by default.

Add new script /etc/rc.d/sysctl_lastload that starts unconditionally.

Reported by: Marek Zarychta

(cherry picked from commit f4b38c360e63a6e66245efedbd6c070f9c0aee55)

3 years agoUPDATING: Not unusual side effect of the awk bug fixed in 3e804463521
Warner Losh [Fri, 16 Jul 2021 04:03:24 +0000 (22:03 -0600)]
UPDATING: Not unusual side effect of the awk bug fixed in 3e804463521

You might not be able to build the kernel if you have an awk between Jul
10th and today. It does not affect all platforms due to the nature of
the bug (so amd64 is unaffected in stable/13 or current, but is affected
in stable/12. i386 seems to be affected everywhere).

Sponsored by: Netflix

3 years agoawk: revert upstream's attempt to disallow hex strings
Warner Losh [Thu, 15 Jul 2021 22:46:06 +0000 (16:46 -0600)]
awk: revert upstream's attempt to disallow hex strings

Upstream one-true-awk decided to disallow hex strings as numbers. This
is in line with awk's behavior prior to C99, and allowed by the POSIX
standard. The standard, however, allows them to be treated as numbers
because that's what the standard said in the 2001 through 2004 editions.
Since 2001, the nawk in FreeBSD has treated them as numbers, so restore
that behavior, allowed by the standard.

A number of scripts in the FreeBSD tree depend on this interpretation,
including scripts to build the kernel which had mysteriously started
failing for some people and not others. By re-allowing 0x hex numbers,
this fixes those scripts and restores POLA.

Upstream issue: https://github.com/onetrueawk/awk/issues/126
Sponsored by: Netflix
Reviewed by: kevans
MFC After: asap due to regression alrady merged to stable
Differential Revision: https://reviews.freebsd.org/D31199

(cherry picked from commit d4d252c49976de33d0a2926df733744d0b8d95fa)

3 years agonfscl: Improve "Consider increasing kern.ipc.maxsockbuf" message
Rick Macklem [Wed, 30 Jun 2021 22:15:41 +0000 (15:15 -0700)]
nfscl: Improve "Consider increasing kern.ipc.maxsockbuf" message

When the setting of kern.ipc.maxsockbuf is less than what is
desired for I/O based on vfs.maxbcachebuf and vfs.nfs.bufpackets,
a console message of "Consider increasing kern.ipc.maxsockbuf".
is printed.

This patch modifies the message to provide a suggested value
for kern.ipc.maxsockbuf.
Note that the setting is only needed when the NFS rsize/wsize
is set to vfs.maxbcachebuf.

While here, make nfs_bufpackets global, so that it can be used
by a future patch that adds a sysctl to set the NFS server's
maximum I/O size.  Also, remove "sizeof(u_int32_t)" from the maximum
packet length, since NFS_MAXXDR is already an "overestimate"
of the actual length.

(cherry picked from commit c5f4772c66d2eb31b84a84a89c8a284043f03452)

3 years agopf: add pf_find_state_all_exists
Mateusz Guzik [Thu, 8 Jul 2021 13:11:57 +0000 (15:11 +0200)]
pf: add pf_find_state_all_exists

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

(cherry picked from commit 19d6e29b872232c47190344f3dfded2f73edd8ae)

3 years agopf: padalign global locks found in pf.c
Mateusz Guzik [Mon, 5 Jul 2021 09:26:29 +0000 (11:26 +0200)]
pf: padalign global locks found in pf.c

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

(cherry picked from commit f649cff58721f493f218a4d1fb88a12255945472)

3 years agopf: allow table stats clearing and reading with ruleset rlock
Mateusz Guzik [Fri, 2 Jul 2021 12:55:57 +0000 (14:55 +0200)]
pf: allow table stats clearing and reading with ruleset rlock

Instead serialize against these operations with a dedicated lock.

Prior to the change, When pushing 17 mln pps of traffic, calling
DIOCRGETTSTATS in a loop would restrict throughput to about 7 mln.  With
the change there is no slowdown.

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

(cherry picked from commit dc1ab04e4c9ede3606985e0cce1200e3060ac166)

3 years agopf: depessimize table handling
Mateusz Guzik [Fri, 2 Jul 2021 11:19:56 +0000 (13:19 +0200)]
pf: depessimize table handling

Creating tables and zeroing their counters induces excessive IPIs (14
per table), which in turns kills single- and multi-threaded performance.

Work around the problem by extending per-CPU counters with a general
counter populated on "zeroing" requests -- it stores the currently found
sum. Then requests to report the current value are the sum of per-CPU
counters subtracted by the saved value.

Sample timings when loading a config with 100k tables on a 104-way box:

stock:

pfctl -f tables100000.conf  0.39s user 69.37s system 99% cpu 1:09.76 total
pfctl -f tables100000.conf  0.40s user 68.14s system 99% cpu 1:08.54 total

patched:

pfctl -f tables100000.conf  0.35s user 6.41s system 99% cpu 6.771 total
pfctl -f tables100000.conf  0.48s user 6.47s system 99% cpu 6.949 total

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

(cherry picked from commit f92c21a28cd856834249a008771b2f002e477a39)

3 years agolibalias: fix divide by zero causing panic
Stefan Eßer [Sat, 10 Jul 2021 11:00:56 +0000 (13:00 +0200)]
libalias: fix divide by zero causing panic

The packet_limit can fall to 0, leading to a divide by zero abort in
the "packets % packet_limit".

An possible solution would be to apply a lower limit of 1 after the
calculation of packet_limit, but since any number modulo 1 gives 0,
the more efficient solution is to skip the modulo operation for
packet_limit <= 1.

Reported by: Karl Denninger <karl@denninger.net>

(cherry picked from commit 58080fbca09fda6d5f011d37059edbca8ceb4c58)

3 years agopf: rename pf_state to pf_kstate
Kristof Provost [Tue, 6 Jul 2021 09:42:20 +0000 (11:42 +0200)]
pf: rename pf_state to pf_kstate

Indicate that this is a kernel-only structure, and make it easier to
distinguish from others used to communicate with userspace.

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

(cherry picked from commit 211cddf9e3a1bc0d4b1b94bea7d16a47b5a17f49)

3 years agotcp: fix alternate stack build with LINT-NO{INET,INET6,IP}
Andrew Gallatin [Wed, 7 Jul 2021 17:02:08 +0000 (13:02 -0400)]
tcp: fix alternate stack build with LINT-NO{INET,INET6,IP}

When fixing another bug, I noticed that the alternate
TCP stacks do not build when various combinations of
ipv4 and ipv6 are disabled.

Reviewed by: rrs, tuexen
Differential Revision: https://reviews.freebsd.org/D31094
Sponsored by:  Netflix

(cherry picked from commit b1e806c0ed960e1eb9ee889c7d0df3c168290c4f)

3 years agotcp: Fix 32 bit platform breakage
Randall Stewart [Thu, 8 Jul 2021 11:06:58 +0000 (07:06 -0400)]
tcp: Fix 32 bit platform breakage

This fixes the incorrect use of a sysctl add to u64. It
was for a useconds time, but on 32 bit platforms its
not a u64. Instead use the long directive.

Reviewed by: tuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D31107

(cherry picked from commit 7312e4e5cfc8e48597acf17f4faa8159f0b5fa06)

3 years agotcp: HPTS performance enhancements
Randall Stewart [Tue, 6 Jul 2021 19:23:22 +0000 (15:23 -0400)]
tcp: HPTS performance enhancements

HPTS drives both rack and bbr, and yet there have been many complaints
about performance. This bit of work restructures hpts to help reduce CPU
overhead. It does this by now instead of relying on the timer/callout to
drive it instead use user return from a system call as well as lro flushes
to drive hpts. The timer becomes a backstop that dynamically adjusts
based on how "late" we are.

Reviewed by: tuexen, glebius
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D31083

(cherry picked from commit d7955cc0ffdf9fb58013245a6f181c757574ea0a)

3 years agotcp: Address goodput and TLP edge cases.
Randall Stewart [Tue, 6 Jul 2021 14:36:14 +0000 (10:36 -0400)]
tcp: Address goodput and TLP edge cases.

There are several cases where we make a goodput measurement and we are running
out of data when we decide to make the measurement. In reality we should not make
such a measurement if there is no chance we can have "enough" data. There is also
some corner case TLP's that end up not registering as a TLP like they should, we
fix this by pushing the doing_tlp setup to the actual timeout that knows it did
a TLP. This makes it so we always have the appropriate flag on the sendmap
indicating a TLP being done as well as count correctly so we make no more
that two TLP's.

In addressing the goodput lets also add a "quality" metric that can be viewed via
blackbox logs so that a casual observer does not have to figure out how good
of a measurement it is. This is needed due to the fact that we may still make
a measurement that is of a poorer quality as we run out of data but still have
a minimal amount of data to make a measurement.

Reviewed by: tuexen
Sponsored by:  Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D31076

(cherry picked from commit e834f9a44acc577e658f40023d9465e887c94920)

3 years agotcp: Preparation for allowing hardware TLS to be able to kick a tcp connection that...
Randall Stewart [Fri, 25 Jun 2021 13:30:54 +0000 (09:30 -0400)]
tcp: Preparation for allowing hardware TLS to be able to kick a tcp connection that is retransmitting too much out of hardware and back to software.

Hardware TLS is now supported in some interface cards and it works well. Except that
when we have connections that retransmit a lot we get into trouble with all the retransmits.
This prep step makes way for change that Drew will be making so that we can "kick out" a
session from hardware TLS.

Reviewed by: tuexen, gallatin
Sponsored by:  Netflix Inc
Differential Revision:  https://reviews.freebsd.org/D30895

(cherry picked from commit 9e4d9e4c4d79db58740a05d67645351e640aa32c)

3 years agotcp: enter network epoch when calling tfb_tcp_fb_fini
Andrew Gallatin [Tue, 25 May 2021 17:45:37 +0000 (13:45 -0400)]
tcp: enter network epoch when calling tfb_tcp_fb_fini

We need to enter the network epoch when calling into
tfb_tcp_fb_fini.  I noticed this when I hit an assert
running the latest rack

Differential Revision: https://reviews.freebsd.org/D30407
Reviewed by: rrs, tuexen
Sponsored by: Netflix

(cherry picked from commit 086a35562f47917a516d30acc8b78a4884e31a4f)

3 years agotcp: Rack not being very friendly with V6:4 socket and having a connection from V4
Randall Stewart [Thu, 24 Jun 2021 18:42:21 +0000 (14:42 -0400)]
tcp: Rack not being very friendly with V6:4 socket and having a connection from V4

There were two bugs that prevented V4 sockets from connecting to
a rack server running a V4/V6 socket. As well as a bug that stops the
mapped v4 in V6 address from working.

Reviewed by:  tuexen
Sponsored by:  Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30885
PR: 256657
(cherry picked from commit 66aec14a5391bda1e9a20f5e4381626797c3e0fb)

3 years agosctp: Fix errno in case of association setup failures
Michael Tuexen [Fri, 9 Jul 2021 21:17:35 +0000 (23:17 +0200)]
sctp: Fix errno in case of association setup failures

Do not report always ETIMEDOUT, but only when appropriate. In
other cases report ECONNABORTED.

(cherry picked from commit 105b68b42dd11bce5c554b1ef0ddf73aa069d7da)

3 years agosctp: provide consistent stream information in case of early errors
Michael Tuexen [Fri, 9 Jul 2021 12:15:22 +0000 (14:15 +0200)]
sctp: provide consistent stream information in case of early errors

While there, make sure the function is called correctly.

(cherry picked from commit ce64352a702db1fef8c0e33f3a6f13a3e5d92736)

3 years agosctp: provide sac_error also for ABORT chunk being sent
Michael Tuexen [Fri, 9 Jul 2021 11:46:27 +0000 (13:46 +0200)]
sctp: provide sac_error also for ABORT chunk being sent

Thanks to Florent Castelli for bringing this issue up for the
userland stack and providing an initial patch.

(cherry picked from commit 84992a3251d56df3bc36e0ac33ba383f41107864)

3 years agosctp: initialize sequence numbers for ECN correctly
Michael Tuexen [Sun, 27 Jun 2021 18:14:48 +0000 (20:14 +0200)]
sctp: initialize sequence numbers for ECN correctly

Reported by: Junseok Yang (for the userland stack)

(cherry picked from commit c7f048ab3532a9f081addd6da0adf96f25271de8)