Commit Graph

137004 Commits

Author SHA1 Message Date
Edward Tomasz Napierala
5d1d844a77 kern_linkat: modify to accept AT_ flags instead of FOLLOW/NOFOLLOW
This makes this API match other kern_xxxat() functions.

Reviewed By:	kib
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D29776
2021-04-25 14:13:12 +01:00
Alexander V. Chernikov
67372fb3e0 Fix NOINET[6] build after enabling FIB_ALGO in GENERIC.
Submitted by:	jbeich
PR:		255389
2021-04-21 02:49:18 +01:00
Alexander V. Chernikov
c23385612d [fib algo] Do not print algo attach/detach message on boot
MFC after:	1 day
2021-04-25 08:58:06 +00:00
Alexander V. Chernikov
a81e2e7890 Make gcc happy by initializing error in rib_handle_ifaddr_info(). 2021-04-25 08:44:59 +00:00
Stefan Eßer
6409e59427 Fix build with gcc
Correctly declare function without arguments as f(void) instead of f().
2021-04-25 10:15:17 +02:00
Alexander V. Chernikov
6993187a8c Add FIB_ALGO to GENERIC on amd64/arm64.
Option `FIB_ALGO` gates new modular fib lookup functionality,
 enabling more performant routing table lookups and improving
 control plane convergence under the load.

Detailed feature description is available in D27401.

Reviewed By: olivier, gnn
Differential Revision: https://reviews.freebsd.org/D28434
2021-04-24 23:22:58 +00:00
Alexander V. Chernikov
5d1403a79a [rtsock] Enforce netmask/RTF_HOST consistency.
Traditionally we had 2 sources of information whether the
 added/delete route request targets network or a host route:
netmask (RTA_NETMASK) and RTF_HOST flag.

The former one is tricky: netmask can be empty or can explicitly
 specify the host netmask. Parsing netmask sockaddr requires per-family
 parsing and that's what rtsock code traditionally avoided. As a result,
 consistency was not enforced and it was possible to specify network with
 the RTF_HOST flag and vice versa.

Continue normalization efforts from D29826 and D29826 and ensure that
 RTF_HOST flag always reflects host/network data from netmask field.

Differential Revision: https://reviews.freebsd.org/D29958
MFC after:	2 days
2021-04-24 22:41:27 +00:00
Robert Watson
af14713d49 Support run-time configuration of the PIPE_MINDIRECT threshold.
PIPE_MINDIRECT determines at what (blocking) write size one-copy
optimizations are applied in pipe(2) I/O.  That threshold hasn't
been tuned since the 1990s when this code was originally
committed, and allowing run-time reconfiguration will make it
easier to assess whether contemporary microarchitectures would
prefer a different threshold.

(On our local RPi4 baords, the 8k default would ideally be at least
32k, but it's not clear how generalizable that observation is.)

MFC after:	3 weeks
Reviewers:	jrtc27, arichardson
Differential Revision: https://reviews.freebsd.org/D29819
2021-04-24 20:04:28 +01:00
Vladimir Kondratyev
e68d76c054 hkbd: Fix typo which disables keyboard input in kdb
Reported by:	Greg V
MFC after:	1 week
2021-04-24 22:01:14 +03:00
Edward Tomasz Napierala
77651151f3 linux: make ptrace(2) return EIO when trying to peek invalid address
Previously we've returned the error from native ptrace(2), ENOMEM.
This confused Linux strace(2).

Reviewed By:	emaste
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D29925
2021-04-24 11:37:50 +01:00
Hans Petter Selasky
a9b66dbd91 Allow the tcp_lro_flush_all() function to be called when the control
structure is zeroed, by setting the VNET after checking the mbuf count
for zero. It appears there are some cases with early interrupts on some
network devices which still trigger page-faults on accessing a NULL "ifp"
pointer before the TCP LRO control structure has been initialized.
This basically preserves the old behaviour, prior to
9ca874cf74 .

No functional change.

Reported by:	rscheff@
Differential Revision:	https://reviews.freebsd.org/D29564
MFC after:	2 weeks
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-04-24 12:23:42 +02:00
Alexander Motin
b99419aee4 mpr/mps(4): Make device mapping some more robust.
Allow new enclosure to replace previously existing one if there is
no completely unused table entry, same as it is done for devices.

If we can not process DPM due to corruption -- wipe it and restart
from scratch.  Otherwise I don't see a way to recover persistence if
something go wrong and there is no BIOS to recover it for us.

Together this solves a problem that appeared when 9300-8i firmware
update to 16.00.10.00 somehow switched its mapping mode from Device
Persistence to Enclosure/Slot without wiping the DPM table.  It made
HBA completely unusable, since overflowed and conflicting mapping
table was unable to map any of enclosures and so devices.

Also while there make some enclosure mapping errors more informative.

MFC after:	1 month
Sponsored by:	iXsystems, Inc.
2021-04-23 23:36:51 -04:00
Tai-hwa Liang
2acbe67787 sound(4): fixing panic for INVARIANTS kernel
3e7bae0821 turns the BUS_READ_IVAR() failure from a warning into a
KASSERT.  For certain PCI audio devices such like snd_csa(4) and
snd_emu10kx(4), the ac97_create() keeps the device handler generated
by device_add_child(pci_dev, "pcm"), which is not really a PCI device
handler.  This in turn causes the subsequent pci_get_subdevice()
inside ac97_initmixer() triggering a panic.

This patch tries to put a bandaid for the aforementioned pcm device
children such that they can use the correct PCI handler(from parent)
to avoid a KASSERT panic in the INVARIANTS kernel.

Tested with:	snd_csa(4), snd_ich(4), snd_emu10kx(4)
Reviewed by:	imp
MFC after:	1 month
2021-04-24 03:27:43 +00:00
Rick Macklem
4281bfec36 nfsd: fix session slot handling for failed callbacks
When the NFSv4.1/4.2 server does a callback to a client
on the back channel, it will use a session slot in the
back channel session. If the back channel has failed,
the callback will fail and, without this patch, the
session slot will not be released.
As more callbacks are attempted, all session slots
can become busy and then the nfsd thread gets stuck
waiting for a back channel session slot.

This patch frees the session slot upon callback
failure to avoid this problem.

Without this patch, the problem can be avoided by leaving
delegations disabled in the NFS server.

MFC after:	2 weeks
2021-04-23 15:24:47 -07:00
Navdeep Parhar
50f5d13eeb cxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time.
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2021-04-23 12:17:54 -07:00
Mark Johnston
8e8f1cc9bb Re-enable network ioctls in capability mode
This reverts a portion of 274579831b ("capsicum: Limit socket
operations in capability mode") as at least rtsol and dhcpcd rely on
being able to configure network interfaces while in capability mode.

Reported by:	bapt, Greg V
Sponsored by:	The FreeBSD Foundation
2021-04-23 09:22:49 -04:00
Andrew Gallatin
3183d0b680 iflib: initialize LRO unconditionally
Changes to the LRO code have exposed a bug in iflib where devices
which are not capable of doing LRO are still calling
tcp_lro_flush_all(), even when they have not initialized the LRO
context. This used to be mostly harmless, but the LRO code now sets
the VNET based on the ifp in the lro context and will try to access it
through a NULL ifp resulting in a panic at boot.

To fix this, we unconditionally initializes LRO so that we have a
valid LRO context when calling tcp_lro_flush_all(). One alternative is
to check the device capabilities before calling tcp_lro_flush_all() or
adding a new state flag in the ctx. However, it seems unwise to add an
extra, mostly useless test for higher performance devices when we can
just initialize LRO for all devices.

Reviewed by: erj, hselasky, markj, olivier
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29928
2021-04-23 05:55:20 -04:00
Navdeep Parhar
5f00292fe3 cxgbe(4): Move the hw-specific parts of VXLAN setup to a separate function.
It can be called to (re)apply the settings in the driver softc to the
hardware.

MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2021-04-23 00:26:47 -07:00
Navdeep Parhar
b47b28e5b2 cxgbe(4): Add flag to reliably stop the driver from accessing hw stats.
There are two kinds of routines in the driver that read statistics from
the hardware: the cxgbe_* variants read the per-port MPS/MAC registers
and the vi_* variants read the per-VI registers.  They can be called
from the 1Hz callout or if_get_counter.  All stats collection now takes
place under the callout lock and there is a new flag to indicate that
these routines should not access any hardware register.

MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2021-04-22 17:45:52 -07:00
Navdeep Parhar
dc77e79296 cxgbe(4): Fix minor nit in the display of MPS TCAM entries.
MFC after:	3 days
2021-04-22 15:36:51 -07:00
Navdeep Parhar
8f1bc78ef7 cxgbe(4): make the logging helpers a little more robust.
MFC after:	3 days
Sponsored by:	Chelsio Communications
2021-04-22 15:28:43 -07:00
Vladimir Kondratyev
55eb41bb1f hv_kbd: Fix build with EVDEV_SUPPORT kernel option disabled.
Reported by:	olivier
MFC with:	e4643aa4c4
2021-04-23 01:13:25 +03:00
Navdeep Parhar
557c4521bb cxgbe/t4_tom: Implement tod_pmtu_update.
tod_pmtu_update was added to the kernel in 01d74fe1ff.

Sponsored by:	Chelsio Communications
2021-04-22 14:48:57 -07:00
Warner Losh
2183bfcce4 newvers.sh: better regexp for the FreeBSD_version line
Tested with:		cirrus-ci https://cirrus-ci.com/build/6012323274948608
Reviewed by:		emaste@, rgrimes@
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D29869
2021-04-22 11:45:12 -06:00
Warner Losh
9a5a5c1576 pvscsi: Advertise maxio of 256k.
While the PV SCSI SG list can handle 512k of SG entries, it can only do
so for I/O that's aligned to 4k or better. newfs_msdos does unaligned
I/O, so triggers too long for host errors in cam when a 512k I/O is
attempted. Prefer power of 2 256k to the absolute maximum 508k, though
that can be revisited should the latter show to give significant
performance improvement.

MFC After:		3 days
Tested by:		darius on discord (508k version of patch)
Sponsored by:		Netflix
2021-04-22 11:23:29 -06:00
Mateusz Guzik
7ea3223c78 zfs: use vn_seqc_read_notmodify for racing .. lookups
Catching an in-flight unlocked vnode is fine here.

Reported by;	pho
2021-04-22 13:18:39 +00:00
Ram Kishore Vegesna
fc620f9782 ocs_fc: Fix memory leak in ocs_scsi_io_alloc()
PR: 254690
Approved by: mav(mentor)
MFC after: 2 weeks
2021-04-22 17:48:37 +05:30
Hans Petter Selasky
47bc8fc9ae Add more USB quirks for Kingston devices.
PR:		253855
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-04-22 12:40:29 +02:00
Hans Petter Selasky
28af0c4814 Add more USB quirks for Garmin devices.
Sort the Garmin products while at it.

PR:		254664
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-04-22 12:35:07 +02:00
Hans Petter Selasky
d2c8714064 Remove USB device ID added by SVN r150701 in the CDC USB ethernet driver.
Since then, the FreeBSD USB stack has got proper USB RNDIS support.

PR:		254345
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-04-22 12:23:36 +02:00
Ka Ho Ng
7c707c7c25 __FreeBSD_version: update the references to the doc tree
Update the reference of which file to update in the doc tree when
bumping __FreeBSD_version.

This change is to catch up with commit f8fed61b80 in the doc repository.

MFC after:	3 days
Approved by:	lwhsu (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29920
2021-04-22 17:36:22 +08:00
Alexander V. Chernikov
4044af03a4 Fix vtnet TCP lro panic
Differential Revision: https://reviews.freebsd.org/D29900
Reviewed by:	hps, kp
2021-04-19 17:06:34 +01:00
Warner Losh
df456a1fcf newbus: style nit (align comments)
Sponsored by:		Netflix
2021-04-21 15:37:24 -06:00
Warner Losh
1eebd6158c newbus: Optimize/Simplify kobj_class_compile_common a little
"i" is not used in this loop at all. There's no need to initialize and
increment it.

Reviewed by:		markj@
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D29898
2021-04-21 15:37:24 -06:00
John Baldwin
6a3a6fe34b riscv: Assert that SUM is not set in SSTATUS for exceptions.
Reviewed by:	mhorne
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D29764
2021-04-21 13:57:20 -07:00
John Baldwin
753bcca440 riscv: Clear SUM in SSTATUS for supervisor mode exceptions.
Previously, a page fault taken during copyin/out and related functions
would run the entire fault handler while permitting direct access to
user addresses.  This could also leak across context switches (e.g. if
the page fault handler was preempted by an interrupt or slept for disk
I/O).

To fix, clear SUM in assembly after saving the original version of
SSTATUS in the supervisor mode trapframe.

Reviewed by:	mhorne, jrtc27
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D29763
2021-04-21 13:57:04 -07:00
Navdeep Parhar
01d74fe1ff Path MTU discovery hooks for offloaded TCP connections.
Notify the TOE driver when when an ICMP type 3 code 4 (Fragmentation
needed and DF set) message is received for an offloaded connection.
This gives the driver an opportunity to lower the path MTU for the
connection and resume transmission, much like what the kernel does for
the connections that it handles.

Reviewed by:	glebius@
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29755
2021-04-21 13:00:16 -07:00
Mark Johnston
652908599b Add required checks for unmapped mbufs in ipdivert and ipfw
Also add an M_ASSERTMAPPED() macro to verify that all mbufs in the chain
are mapped.  Use it in ipfw_nat, which operates on a chain returned by
m_megapullup().

PR:		255164
Reviewed by:	ae, gallatin
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29838
2021-04-21 15:47:05 -04:00
Mateusz Guzik
9c651561a2 zfs: damage control racing .. lookups in face of mkdir/rmdir
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D29769
2021-04-21 15:25:32 +00:00
Konstantin Belousov
54f98c4dbf vn_open_vnode(): handle error when fp == NULL
If VOP_ADD_WRITECOUNT() or adv locking failed, so VOP_CLOSE() needs to
be called, we cannot use fp fo_close() when there is no fp.  This occurs
when e.g. kernel code directly calls vn_open() instead of the open(2)
syscall.

In this case, VOP_CLOSE() can be called directly, after possible lock
upgrade.

Reported by:	nvass@gmx.com
PR:	255119
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29830
2021-04-21 18:06:51 +03:00
Ka Ho Ng
a3a02acde1 param.h: bump __FreeBSD_version for commit 4ce1ba6523
Commit 4ce1ba6523 changed the sndstat(4) ioctls nvlist schema and
definitions.

Approved by:	philip (mentor)
2021-04-21 16:21:08 +08:00
Ka Ho Ng
4ce1ba6523 sndstat: nvlist schema and API definition changes
- SNDSTAT_LABEL_* are renamed to SNDST_DSPS_*, and SNDSTAT_LABEL_DSPS
  becomes SNDST_DSPS.
- Centralize channel number/rate/formats into a single nvlist
  The above nvlist is named "info_play" and "info_rec"
- Expose only encoding format in pfmts/rfmts. Userland has no direct
  access to AFMT_ENCODING/CHANNEL/EXTCHANNEL macros, thus it serves no
  meaning to expose too much information through this pair of labels.
  However pminrate/rminrate, pmaxrate/rmaxrate, pfmts/rfmts are
  deprecated and will be removed in future.

This commit keeps ioctls ABI compatibility with __FreeBSD_version
1400006 for now. In future the compat ABI with 1400006 will be removed
once audio/virtual_oss is rebuilt.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	hselasky
Approved by:	philip (mentor)
Differential Revision:	https://reviews.freebsd.org/D29770
2021-04-21 16:19:15 +08:00
Xin LI
438b553207 arcmsr(4): Fix SCSI command timeout on ARC-1886.
Many thanks to Areca for continuing to support FreeBSD.

Submitted by:	黃清隆 <ching2048 areca com tw>
MFC after:	2 weeks
2021-04-21 01:03:54 -07:00
Alexander V. Chernikov
33cb3cb2e3 Fix rib generation count for fib algo.
Currently, PCB caching mechanism relies on the rib generation
 counter (rnh_gen) to invalidate cached nhops/LLE entries.

With certain fib algorithms, it is now possible that the
 datapath lookup state applies RIB changes with some delay.
In that scenario, PCB cache will invalidate on the RIB change,
 but the new lookup may result in the same nexthop being returned.
When fib algo finally gets in sync with the RIB changes, PCB cache
 will not receive any notification and will end up caching the stale data.

To fix this, introduce additional counter, rnh_gen_rib, which is used
 only when FIB_ALGO is enabled.
This counter is incremented by the control plane. Each time when fib algo
 synchronises with the RIB, it updates rnh_gen to the current rnh_gen_rib value.

Differential Revision: https://reviews.freebsd.org/D29812
Reviewed by:	donner
MFC after:	2 weeks
2021-04-20 22:02:41 +00:00
Alexander V. Chernikov
b31fbebeb3 Relax rtsock message restrictions.
Address multiple issues with strict rtsock message validation.

D28668 "normalisation" approach was based on the assumption that
 we always have at least "standard" sockaddr len.
It turned out to be false - certain older applications like quagga
 or routed abuse sin[6]_len field and set it to the offset to the
 first fully-zero bit in the mask. It is impossible to normalise
 such sockaddrs without reallocation.

With that in mind, change the approach to use a distinct memory
 buffer for the altered sockaddrs. This allows supporting the older
 software while maintaining the guarantee on the "standard" sockaddrs.

PR:	255273,255089
Differential Revision:	https://reviews.freebsd.org/D29826
MFC after:	3 days
2021-04-20 21:34:19 +00:00
Sofian Brabez
561d34d705 iwnstats: fix build with clang and allow install under /usr/local/sbin
iwnstats was not compiling because of some issues raised by the clang
compiler due to -Werror. As a tool it is not connected to world build.

Add missing field "barker_mrc" initialization in struct
iwn_sensitivity_limits for -Wmissing-field-initializers, remove unused
pointer *is on iwn_stats_*_print functions and unused variables for
-Wunused-parameter and -Wunused-variable.

The value for field "barker_mrc" of struct iwn2030_sensitivity_limits
was obtained from linux 3.2 wireless/iwlwifi driver code (iwl-2000.c:115
.barker_corr_th_min_mrc = 390).

Also set BINDIR in Makefile to make it possible to install under
/usr/local/sbin/iwnstats as it require super user.

Reviewed by:	adrian
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29800
2021-04-20 18:07:56 +00:00
Gleb Smirnoff
d554522f6e tcp_hostcache: use SMR for lookups, mutex(9) for updates.
In certain cases, e.g. a SYN-flood from a limited set of hosts,
the TCP hostcache becomes the main contention point. To solve
that, this change introduces lockless lookups on the hostcache.

The cache remains a hash, however buckets are now CK_SLIST. For
updates a bucket mutex is obtained, for read an SMR section is
entered.

Reviewed by:	markj, rscheff
Differential revision:	https://reviews.freebsd.org/D29729
2021-04-20 10:02:20 -07:00
Gleb Smirnoff
1db08fbe3f tcp_input: always request read-locking of PCB for any pure SYN segment.
This is further rework of 08d9c92027.  Now we carry the knowledge of
lock type all the way through tcp_input() and also into tcp_twcheck().
Ideally the rlocking for pure SYNs should propagate all the way into
the alternative TCP stacks, but not yet today.

This should close a race when socket is bind(2)-ed but not yet
listen(2)-ed and a SYN-packet arrives racing with listen(2), discovered
recently by pho@.
2021-04-20 10:02:20 -07:00
Gleb Smirnoff
7b5053ce22 tcp_input: remove comments and assertions about tcpbinfo locking
They aren't valid since d40c0d47cd.
2021-04-20 10:02:20 -07:00
Richard Scheffenegger
a649f1f6fd tcp: Deal with DSACKs, and adjust rescue hole on success.
When a rescue retransmission is successful, rather than
inserting new holes to the left of it, adjust the old
rescue entry to cover the missed sequence space.

Also, as snd_fack may be stale by that point, pull it forward
in order to never create a hole left of snd_una/th_ack.

Finally, with DSACKs, tcp_sack_doack() may be called
with new full ACKs but a DSACK block. Account for this
eventuality properly to keep sacked_bytes >= 0.

MFC after: 3 days
Reviewed By: kbowling, tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29835
2021-04-20 14:54:28 +02:00