]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
23 months agosys: Consolidate common implementation details of PV entries.
John Baldwin [Fri, 7 Oct 2022 17:14:03 +0000 (10:14 -0700)]
sys: Consolidate common implementation details of PV entries.

Add a <sys/_pv_entry.h> intended for use in <machine/pmap.h> to
define struct pv_entry, pv_chunk, and related macros and inline
functions.

Note that powerpc does not yet use this as while the mmu_radix pmap
in powerpc uses the new scheme (albeit with fewer PV entries in a
chunk than normal due to an used pv_pmap field in struct pv_entry),
the Book-E pmaps for powerpc use the older style PV entries without
chunks (and thus require the pv_pmap field).

Suggested by: kib
Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D36685

23 months agoif_ovpn: remove an incorrect assertion
Kristof Provost [Fri, 7 Oct 2022 17:10:01 +0000 (19:10 +0200)]
if_ovpn: remove an incorrect assertion

netisr_dispatch() can fail, especially when under high traffic loads.
This isn't a fatal error, so simply don't check the return value.

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

23 months agow: don't truncate if we're writing libxo json/xml
Kristof Provost [Fri, 7 Oct 2022 16:14:02 +0000 (18:14 +0200)]
w: don't truncate if we're writing libxo json/xml

If we're writing structured output (i.e. json or xml) we shouldn't worry
about terminal width, and instead always output full width information.

This means that, for example, if we're called from crontab with 'w
--libxo json' we'll provide full the command field rather than
pointlessly truncating it.

Suggested by: Phil Shafer
Event: Aberdeen Hackathon 2022
Differential Revision: https://reviews.freebsd.org/D25013

23 months agoUpdate the organization graph for pkgmgr
Rene Ladan [Fri, 7 Oct 2022 15:26:42 +0000 (17:26 +0200)]
Update the organization graph for pkgmgr
Event: Aberdeen 2022 Hackathon

23 months agoBump MAC_VERSION to 5
Allan Jude [Fri, 7 Oct 2022 14:37:35 +0000 (14:37 +0000)]
Bump MAC_VERSION to 5

2449b9e5fe565be757a4b29093fd1c9c6ffcf3c9 introduced API changes
that require ensuring that loadable MAC modules use the matching API.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.

23 months agofusefs: during F_GETLK, don't change l_pid if no lock is found
Alan Somers [Fri, 7 Oct 2022 14:46:22 +0000 (08:46 -0600)]
fusefs: during F_GETLK, don't change l_pid if no lock is found

PR: 266885
MFC after: 2 weeks
Submitted by: John Millikin <jmillikin@gmail.com>
Sponsored by: Axcient
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D36905

23 months agotcp: update repeat <SYN,ACK> with latest IP ECN info
Richard Scheffenegger [Thu, 6 Oct 2022 23:50:02 +0000 (01:50 +0200)]
tcp: update repeat <SYN,ACK> with latest IP ECN info

When multiple <SYN> segments are received, update the <SYN,ACK>
sent in response to the latest IP ECN and TCP ECN information.

On retransmitting the <SYN,ACK>, once ECN maxtries are done, not
only disable RFC3168 ECN, but AccECN also.

Reviewed By:     tuexen, #transport
Sponsored by:    NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D36875

23 months agotcp: honor rfc1323 sysctl on passive sessions
Richard Scheffenegger [Thu, 6 Oct 2022 23:43:14 +0000 (01:43 +0200)]
tcp: honor rfc1323 sysctl on passive sessions

On passive sessions, honor the local settings disabling or
enabling window scaling and timestamp options.

Reviewed By:     tuexen, #transport
Sponsored by:    NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D36874

23 months agosiftr: apply filter early on
Richard Scheffenegger [Thu, 6 Oct 2022 23:31:48 +0000 (01:31 +0200)]
siftr: apply filter early on

Quickly check TCP port filter, before investing into
expensive operations.

No functional change.

Obtained from:   guest-ccui
Reviewed By:     #transport, tuexen, guest-ccui
Sponsored by:    NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D36842

23 months agoif_vxlan(4): Correct the statistic for output bytes
Zhenlei Huang [Fri, 7 Oct 2022 11:37:12 +0000 (13:37 +0200)]
if_vxlan(4): Correct the statistic for output bytes

The vxlan interface encapsulates the Ethernet frame by prepending IP/UDP
and vxlan headers. For statistics, only the payload, i.e. the
encapsulated (inner) frame should be counted.

Event: Aberdeen Hackathon 2022
Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D36855

23 months agousb(4): Substitute "unsigned int" using the equivalent and shorter "unsigned" keyword.
Hans Petter Selasky [Fri, 7 Oct 2022 11:31:51 +0000 (13:31 +0200)]
usb(4): Substitute "unsigned int" using the equivalent and shorter "unsigned" keyword.

MFC after: 1 week
Sponsored by: NVIDIA Networking

23 months agousb(4): Make the enumeration thread nice time a variable.
Hans Petter Selasky [Fri, 7 Oct 2022 11:28:38 +0000 (13:28 +0200)]
usb(4): Make the enumeration thread nice time a variable.

Depends on "options USB_DEBUG".

Suggested by: koobs@
MFC after: 1 week
Sponsored by: NVIDIA Networking

23 months agoAdd extra EINVAL information about wrong block size to read(2)/write(2)
Benedict Reuschling [Fri, 7 Oct 2022 11:32:37 +0000 (11:32 +0000)]
Add extra EINVAL information about wrong block size to read(2)/write(2)

The read system call will return EINVAL if the current file offset is
not a multiple of the block size. This also applies to write(2). Add an
entry for EINVAL about this error to both man pages.

PR: 91149
Event: Aberdeen Hackathon 2022
Differential Revision: https://reviews.freebsd.org/D24617

23 months agotcp: remove INP_TIMEWAIT flag
Gleb Smirnoff [Fri, 7 Oct 2022 02:22:23 +0000 (19:22 -0700)]
tcp: remove INP_TIMEWAIT flag

Mechanically cleanup INP_TIMEWAIT from the kernel sources.  After
0d7445193ab, this commit shall not cause any functional changes.

Note: this flag was very often checked together with INP_DROPPED.
If we modify in_pcblookup*() not to return INP_DROPPED pcbs, we
will be able to remove most of this checks and turn them to
assertions.  Some of them can be turned into assertions right now,
but that should be carefully done on a case by case basis.

Differential revision: https://reviews.freebsd.org/D36400

23 months agosystat: remove INP_TIMEWAIT
Gleb Smirnoff [Fri, 7 Oct 2022 02:22:23 +0000 (19:22 -0700)]
systat: remove INP_TIMEWAIT

23 months agotcp: in tcp_usr_detach() remove special handling of compressed time-wait
Gleb Smirnoff [Fri, 7 Oct 2022 02:22:23 +0000 (19:22 -0700)]
tcp: in tcp_usr_detach() remove special handling of compressed time-wait

Differential revision: https://reviews.freebsd.org/D36399

23 months agotcp: remove tcptw, the compressed timewait state structure
Gleb Smirnoff [Fri, 7 Oct 2022 02:22:23 +0000 (19:22 -0700)]
tcp: remove tcptw, the compressed timewait state structure

The memory savings the tcptw brought back in 2003 (see 340c35de6a2) no
longer justify the complexity required to maintain it.  For longer
explanation please check out the email [1].

Surpisingly through almost 20 years the TCP stack functionality of
handling the TIME_WAIT state with a normal tcpcb did not bitrot.  The
existing tcp_input() properly handles a tcpcb in TCPS_TIME_WAIT state,
which is confirmed by the packetdrill tcp-testsuite [2].

This change just removes tcptw and leaves INP_TIMEWAIT.  The flag will
be removed in a separate commit.  This makes it easier to review and
possibly debug the changes.

[1] https://lists.freebsd.org/archives/freebsd-net/2022-January/001206.html
[2] https://github.com/freebsd-net/tcp-testsuite

Differential revision: https://reviews.freebsd.org/D36398

23 months agoldd: ignore unverified files
Simon J. Gerraty [Fri, 7 Oct 2022 00:51:28 +0000 (17:51 -0700)]
ldd: ignore unverified files

When mac_veriexec is enforcing, we won't run unverified binaries,
don't let ldd examine them either.

Reviewed by: stevek emaste
MFC after: 1 week
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D36897

23 months agoamd64, arm64 pmap: fix a comment typo
Mitchell Horne [Tue, 4 Oct 2022 19:22:20 +0000 (16:22 -0300)]
amd64, arm64 pmap: fix a comment typo

There is no such error code.

Fixes: 1d5ebad06c20b ("pmap: optimize MADV_WILLNEED on existing superpages")

23 months agoriscv: handle kernel PTE edge-case in pmap_enter_l2()
Mitchell Horne [Wed, 5 Oct 2022 16:14:36 +0000 (13:14 -0300)]
riscv: handle kernel PTE edge-case in pmap_enter_l2()

Page table pages are never freed from the kernel pmap, instead they are
zeroed when a range is unmapped. This allows future mappings to be
constructed more quickly. Detect this scenario in pmap_enter_l2(), so we
don't fail to create a superpage mapping when the 2MB range is actually
available.

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36885

23 months agoriscv: add an assert to pmap_remove_pages()
Mitchell Horne [Thu, 25 Aug 2022 20:08:20 +0000 (17:08 -0300)]
riscv: add an assert to pmap_remove_pages()

Similar checks exist for both arm64 and amd64, but note that for amd64
it is a bare panic().

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36564

23 months agoriscv: handle superpage in pmap_enter_quick_locked()
Mitchell Horne [Wed, 5 Oct 2022 17:11:02 +0000 (14:11 -0300)]
riscv: handle superpage in pmap_enter_quick_locked()

Previously, if pmap_enter_l2() was asked to re-map an existing superpage
(the result of madvise(MADV_WILLNEED) on a mapped range), it could
'fail' to do so, falling back to trying pmap_enter_quick_locked() for
each 4K virtual page. Because this function does not check if the l2
entry it finds is a superpage, it would proceed, sometimes resulting in
the creation of false PV entries.

If the relevant range was later munmap'ed, the system would panic during
the process' exit in pmap_remove_pages(), while attempting to clean up
the PV entries for mappings which no longer exist.

Instead, we should return early in the presence of an existing
superpage, as is done in other pmaps.

PR:             266108
Reviewed by: markj, alc
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36563

23 months agoriscv: optimize MADV_WILLNEED on existing superpages
Mitchell Horne [Wed, 5 Oct 2022 17:10:45 +0000 (14:10 -0300)]
riscv: optimize MADV_WILLNEED on existing superpages

Specifically, avoid pointless calls to pmap_enter_quick_locked() when
madvise(MADV_WILLNEED) is applied to an existing superpage mapping.

1d5ebad06c20 made the change for amd64 and arm64.

Reviewed by: markj, alc
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36563

23 months agoriscv: better CTR messages in pmap_enter_l2()
Mitchell Horne [Thu, 25 Aug 2022 20:08:41 +0000 (17:08 -0300)]
riscv: better CTR messages in pmap_enter_l2()

Disambiguate the failure cases.

Reviewed by: jhb
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D36562

23 months agozfs: powerpc: disable kernel floating point support
Alfredo Dal'Ava Junior [Thu, 6 Oct 2022 21:48:01 +0000 (18:48 -0300)]
zfs: powerpc: disable kernel floating point support

Powerpc* doesn't support support floating point in the kernel yet,
so disable it on zfs for now.

This fixes "panic: altivec unavailable trap" when loading zfs.ko

Approved by: jhibbits
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D36894

23 months agobsdinstall: Fix race condition when shutting down after installation
Jessica Clarke [Thu, 6 Oct 2022 19:04:04 +0000 (20:04 +0100)]
bsdinstall: Fix race condition when shutting down after installation

Whilst reboot(8) will block whilst it runs, shutdown(8) does not,
daemonizing instead. This means that we must wait after running it,
otherwise we will exit and cause the system to attempt to go multi-user
in parallel with the shutdown daemon killing init. With the new
multi-console support in the installer, runconsoles will immediately
kill this daemon, racing with the daemon being able to signal init as
desired, and I have seen this race be lost in QEMU with a single CPU. In
the past this wasn't such an issue, since shutdown's daemon puts itself
in a new session group immediately after fork (and the parent doesn't
wait until that has happened, so whilst there's technically a race
condition in there where it could receive a SIGHUP from the death of the
parent's session leader, in practice this is very unlikely to be hit.
This means that the only consequence of this oversight before was that
you might get the beginnings of more console output on the way to
multi-user and thus the console would look a little confusing.

Reviewed by: gjb
Fixes: e4505364c087 ("release/rc.local: Provide option to shutdown after installation complete")
Fixes: a09af1b7fd95 ("bsdinstall release: Start installer on multiple consoles")
Differential Revision: https://reviews.freebsd.org/D36879

23 months agonvmecontrol: Apply cast
Cy Schubert [Thu, 6 Oct 2022 18:56:11 +0000 (11:56 -0700)]
nvmecontrol: Apply cast

The proper fix also casts to uintmax_t.

Reported by: imp
Fixes: a7b568109ec7

23 months agoioat: Add Ice Lake ID.
Alexander Motin [Thu, 6 Oct 2022 18:44:10 +0000 (14:44 -0400)]
ioat: Add Ice Lake ID.

MFC after: 2 weeks

23 months agonvmecontrol: Fix i386 build
Cy Schubert [Thu, 6 Oct 2022 17:56:48 +0000 (10:56 -0700)]
nvmecontrol: Fix i386 build

Fix:

--- all_subdir_sbin ---
/opt/src/git-src/sbin/nvmecontrol/modules/samsung/samsung.c:149:64:
error: format specifies type 'unsigned long' but the argument has type
'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
        printf("   Read Reclaim Count                       : %lu\n",
le64dec(&temp->rrc));
                                                              ~~~
^~~~~~~~~~~~~~~~~~~
                                                              %llu
/opt/src/git-src/sbin/nvmecontrol/modules/samsung/samsung.c:150:64:
error: forma t specifies type 'unsigned long' but the argument has type
'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
        printf("   Lifetime Uncorrectable ECC Count         : %lu\n",
le64dec(&temp->lueccc));
                                                              ~~~
^~~~~~~~~~~~~~~~~~~~~~
                                                              %llu
2 errors generated.

Fixes: 84e86788705c176cc195e4a9831c0be08dcece31

23 months agoMakefile: replace mergemaster references with etcupdate
Dries Michiels [Tue, 4 Oct 2022 19:34:05 +0000 (21:34 +0200)]
Makefile: replace mergemaster references with etcupdate

Similar to UPDATING and handbook changes, treat Makefile the same.

PR: 260822
Approved by: jhb, philip
Differential Revision: https://reviews.freebsd.org/D36877

23 months agoarm64/machdep: Delete trailing whitespace
Warner Losh [Thu, 6 Oct 2022 03:06:31 +0000 (21:06 -0600)]
arm64/machdep: Delete trailing whitespace

No functional change.

Sponsored by: Netflix

23 months agocxgbe/cxgbei: Do not validate the hardware iSCSI tag mask.
Navdeep Parhar [Wed, 5 Oct 2022 18:05:12 +0000 (11:05 -0700)]
cxgbe/cxgbei: Do not validate the hardware iSCSI tag mask.

This was added in 7cba15b16eb2 in 2016 and firmwares at that time were
already setting up the iSCSI tag mask properly.  Since then it has also
become possible to split the iSCSI region between multiple PCIE PFs but
the driver's calculation takes only its own PF's allocation into account
and that means this code is incorrect and not just a harmless no-op.

MFC after: 1 week
Sponsored by: Chelsio Communications

23 months agoIgnore IPv6 NA and drop IPv6 NS when BACKUP CARP address is used
Andrey V. Elsukov [Thu, 6 Oct 2022 16:50:33 +0000 (19:50 +0300)]
Ignore IPv6 NA and drop IPv6 NS when BACKUP CARP address is used

When system acts as CARP BACKUP ignore received IPv6 Neighbor Advertisements
to ensure that neighbor cache will not be changed.
Also do not send IPv6 Neighbor Solicitation from CARP BACKUP source address.
Such packets can confuse network switch and it detects MAC addresses
flapping.

Obtained from: Yandex LLC
MFC after: 2 weeks
Sponsored by: Yandex LLC
Differential Revision:     https://reviews.freebsd.org/D36649

23 months agovmd: Add DID 8086:7D0B and 8086:AD0B for Intel MTL SKUs
Alexander Motin [Thu, 6 Oct 2022 16:44:59 +0000 (12:44 -0400)]
vmd: Add DID 8086:7D0B and 8086:AD0B for Intel MTL SKUs

MFC after: 2 weeks

23 months agovmd: Bypass MSI/MSI-X remapping when possible.
Alexander Motin [Thu, 6 Oct 2022 16:15:25 +0000 (12:15 -0400)]
vmd: Bypass MSI/MSI-X remapping when possible.

By default all VMD devices remap children MSI/MSI-X interrupts into their
own.  It creates additional isolation, but also complicates things due to
sharing, etc.  Fortunately some VMD devices can bypass the remapping.
Add tunable to control it for remap testing or if something go wrong.

MFC after: 2 weeks

23 months agoldd: use direct exec mode unconditionally
Konstantin Belousov [Wed, 21 Sep 2022 13:55:44 +0000 (16:55 +0300)]
ldd: use direct exec mode unconditionally

Trying to exec malformed or unusual binary, for instance, a non-FreeBSD
ABI, or using a non-standard interpreter, might give unexpected outcome.

Reported by: The UK's National Cyber Security Centre (NCSC)
Reviewed by: emaste, markj, philip
Discussed with: jhb
Sponsored by: The FreeBSD Foundation
admbug: 991
PR: 127276, 175339, 231926
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D36650

23 months agoif_ovpn: ensure we're in net_epoch when calling ovpn_encap()
Kristof Provost [Thu, 6 Oct 2022 15:01:47 +0000 (17:01 +0200)]
if_ovpn: ensure we're in net_epoch when calling ovpn_encap()

If the crypto callback is asynchronous we're no longer in net_epoch,
which ovpn_encap() (and ip_output() it calls) expect.

Ensure we've entered the epoch.

Do the same thing for the rx path.

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

23 months agouart_dev_snps: Fix device probing
Kornel Dulęba [Thu, 6 Oct 2022 14:25:47 +0000 (16:25 +0200)]
uart_dev_snps: Fix device probing

The "uart_bus_probe" function is used as a generic part of uart probe
logic. It returns a driver priority(negative number) if successful and
an error code otherwise.
Fix the error checking condition to account for that.
Also, while here return "BUS_PROBE_VENDOR", instead of "0".
This fixes uart on clearfog pro with recent DT.

PR: 266657
Reviewed by: mw
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D36880

23 months agotest/sys/opencrypto: Fix NIST KAT parser iterator
Kornel Dulęba [Thu, 6 Oct 2022 14:20:58 +0000 (16:20 +0200)]
test/sys/opencrypto: Fix NIST KAT parser iterator

When yield a.k.a "generator" iterator is used we need to return all
data using "yield", before returning from the function.
Because of that only encryption tests were run for AES-CBC, other modes
were affected as well.
Add one more loop to the iterator "next" routine to fix that.
This unveiled a problem in the GCM AEAD parser logic, which didn't
correctly handle tests cases with empty plaintext, i.e. AAD only.
Include the fix in this patch as it's a rather trivial one.

Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D36861

23 months agoMake #if and #endif do what people expect in *_if.m
Andrew Turner [Fri, 30 Sep 2022 16:02:36 +0000 (16:02 +0000)]
Make #if and #endif do what people expect in *_if.m

These are used in a few places. Pass them to the generated .c and .h
files to allow us to build the parts of the interface the kernel config
supports.

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

23 months agoStop relying on header pollution in sdhci_xenon.c
Andrew Turner [Wed, 5 Oct 2022 13:52:02 +0000 (14:52 +0100)]
Stop relying on header pollution in sdhci_xenon.c

Include sys/malloc.h directly in sdhci_xenon.c to get the malloc(9)
definition rather than depend on header pollution.

Sponsored by: The FreeBSD Foundation

23 months agoFix the options to build rk_usb2phy.c
Andrew Turner [Wed, 5 Oct 2022 10:45:45 +0000 (11:45 +0100)]
Fix the options to build rk_usb2phy.c

We need to check for fdt rk_usb2phy on both sides of the '|'.

Sponsored by: The FreeBSD Foundation

23 months agouslcom(4): Clear stall at every open.
Hans Petter Selasky [Wed, 5 Oct 2022 14:45:21 +0000 (16:45 +0200)]
uslcom(4): Clear stall at every open.

To avoid data loss, make sure both the receive and transmit data toggles
get reset, before trying to read or write any data.

MFC after: 1 week
Sponsored by: NVIDIA Networking

23 months agonvmecontrol: Add Samsung Extended SMART Information logpage support
Wanpeng Qian [Thu, 6 Oct 2022 10:10:06 +0000 (10:10 +0000)]
nvmecontrol: Add Samsung Extended SMART Information logpage support

Samsung PM983 SSD has a 0xca logpage. It has more information compared
to Intel's this patch tested on PM983 M2 SSD and works as expected.

Reviewed by: imp@
Approved by: kp@
Event: Aberdeen Hackathon 2022
Differential revision: https://reviews.freebsd.org/D33749

23 months agoLinuxKPI: Add pci_power querying for drm-kmod
Jake Freeland [Thu, 6 Oct 2022 08:15:41 +0000 (10:15 +0200)]
LinuxKPI: Add pci_power querying for drm-kmod

Adds a few struct members and a function to get i915_runtime_pm_status()
to compile in drm-kmod.

Differential Revision: https://reviews.freebsd.org/D36749
Sponsored by:   Google, Inc. (GSoC 2022)

23 months agors: Fix some pointer arith UB.
John Baldwin [Wed, 5 Oct 2022 23:48:05 +0000 (16:48 -0700)]
rs: Fix some pointer arith UB.

If the next column was blank, then the length of the following entry
was computed as the end of the following entry minus a global variable
"blank" which is not in the same string or allocation.  Instead, save
the start value of 'p' explicitly instead of abusing '*ep'.  Possibly
we should just increment p before saving it in sp in the 'blank' case,
but at worst that would just mean maxlen might be one char too large
which should be harmless.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D36832

23 months agors: Fix a use after free.
John Baldwin [Wed, 5 Oct 2022 23:47:40 +0000 (16:47 -0700)]
rs: Fix a use after free.

Using a pointer passed to realloc() after realloc() even for pointer
arithmetic is UB.  It also breaks in practice on CHERI systems as
the updated value of 'sp' in this case would have had the bounds from
the old allocation.

This would be much cleaner if elem were a std::vector<char *>.

Reviewed by: brooks, emaste
Reported by: GCC -Wuse-after-free
Differential Revision: https://reviews.freebsd.org/D36831

23 months agors: Fix various harmless warnings.
John Baldwin [Wed, 5 Oct 2022 23:47:21 +0000 (16:47 -0700)]
rs: Fix various harmless warnings.

- Add /* FALLTHROUGH */ comments for intentional fall throughs in
  getargs().

- Remove id strings to quiet -Wunused-const-variable warnings from
  GCC.

- While here, remove __FBSDID.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D36830

23 months agomsk: Use a void cast to mark values of dummy reads as unused.
John Baldwin [Wed, 5 Oct 2022 23:46:01 +0000 (16:46 -0700)]
msk: Use a void cast to mark values of dummy reads as unused.

Note that this required adding missing ()'s around the outermost level
of MSK_READ_MIB*.  Otherwise, the void cast was only applied to the
first register read.  This also meant that MSK_READ_MIB64 was pretty
broken as the uint64_t cast only applied to the first 16-bit register
read in each MSK_READ_MIB32 invocation and the 32-bit shift was only
applied to the second register read of the pair.

Reviewed by: imp, emaste
Reported by: GCC -Wunused-value
Differential Revision: https://reviews.freebsd.org/D36777

23 months agomsk: Don't bother reading spare stats registers.
John Baldwin [Wed, 5 Oct 2022 23:45:43 +0000 (16:45 -0700)]
msk: Don't bother reading spare stats registers.

msk_stats_update reads stats registers named "spare" whose values are
discarded.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D36871

23 months agoarm64: Simplify initialization of pc_freemask.
John Baldwin [Wed, 5 Oct 2022 23:20:55 +0000 (16:20 -0700)]
arm64: Simplify initialization of pc_freemask.

Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D36502

23 months agoAdd mbuf_tstmp2timeval()
Konstantin Belousov [Mon, 3 Oct 2022 22:49:45 +0000 (01:49 +0300)]
Add mbuf_tstmp2timeval()

Reviewed by: hselasky, jkim, rscheff
Sponsored by: NVIDIA networking
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D36870

23 months agovm_page: Fix a logic error in the handling of PQ_ACTIVE operations
Mark Johnston [Wed, 5 Oct 2022 19:12:46 +0000 (15:12 -0400)]
vm_page: Fix a logic error in the handling of PQ_ACTIVE operations

As an optimization, vm_page_activate() avoids requeuing a page that's
already in the active queue.  A page's location in the active queue is
mostly unimportant.

When a page is unwired and placed back in the page queues,
vm_page_unwire() avoids moving pages out of PQ_ACTIVE to honour the
request, the idea being that they're likely mapped and so will simply
get bounced back in to PQ_ACTIVE during a queue scan.

In both cases, if the page was logically in PQ_ACTIVE but had not yet
been physically enqueued (i.e., the page is in a per-CPU batch), we
would end up clearing PGA_REQUEUE from the page.  Then, batch processing
would ignore the page, so it would end up unwired and not in any queues.
This can arise, for example, when a page is allocated and then
vm_page_activate() is called multiple times in quick succession.  The
result is that the page is hidden from the page daemon, so while it will
be freed when its VM object is destroyed, it cannot be reclaimed under
memory pressure.

Fix the bug: when checking if a page is in PQ_ACTIVE, only perform the
optimization if the page is physically enqueued.

PR: 256507
Fixes: f3f38e2580f1 ("Start implementing queue state updates using fcmpset loops.")
Reviewed by: alc, kib
MFC after: 1 week
Sponsored by: E-CARD Ltd.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D36839

23 months agogrep: Add quotes in manpage when using wildcards with --include
Daniel Engberg [Wed, 5 Oct 2022 17:04:52 +0000 (19:04 +0200)]
grep: Add quotes in manpage when using wildcards with --include

Examples uses --include=*.h which doesn't work as intended

Approved by: kevans
Differential Revision: https://reviews.freebsd.org/D36883

23 months agoAdd information on how to load gmirror on boot to auto activate mirrors
Benedict Reuschling [Wed, 5 Oct 2022 16:44:31 +0000 (16:44 +0000)]
Add information on how to load gmirror on boot to auto activate mirrors

PR: 234997
Reported by: Michiel van Baak <michiel@vanbaak.eu>
Event: Aberdeen Hackathon 2022
Differential Revision: https://reviews.freebsd.org/D20577

23 months agolibc: Include quad support on long32 ABIs
Brooks Davis [Wed, 5 Oct 2022 16:26:31 +0000 (17:26 +0100)]
libc: Include quad support on long32 ABIs

Rather than not including it on all 64-bit platforms, just include it on
32-bit ones.

Reviewed by: imp, jhb
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D36422

23 months agobsd.cpu.mk: Introduce MACHINE_ABI
Brooks Davis [Wed, 5 Oct 2022 16:26:30 +0000 (17:26 +0100)]
bsd.cpu.mk: Introduce MACHINE_ABI

MACHINE_ABI is a list of properties of the ABI used for MACHINE_ARCH.
It should be used in place of long conditionals on MACHINE_ARCH where
practical.

The following properties are indicated with one of the follow values:

Byte order:                  big-endian, little-endian
Floating point ABI:          soft-float, hard-float
Size of long (size_t, etc):  long32, long64
Pointer type:                ptr32, ptr64
Size of time_t:              time32, time64

For example, i386 targets will be:
MACHINE_ABI= big-endian hard-float long32 ptr32 time32

Reviewed by: imp
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D36421

23 months agoRename MACHINE_ABI and TARGET_ABI
Brooks Davis [Wed, 5 Oct 2022 16:26:30 +0000 (17:26 +0100)]
Rename MACHINE_ABI and TARGET_ABI

The MACHINE_ABI and TARGET_ABI variables are used to set the middle of
the target triple (e.g., "-unknown-" or "-gnueabihf-"). They are not set
by any tool in the base system and I've only found the latter mentioned
in one review online. As such, rename them to to MACHINE_TRIPLE_ABI and
TARGET_TRIPLE_ABI to clear the way to use MACHINE_ABI as a supplement to
MACHINE_CPU, etc.

Reviewed by: imp, jhb
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D36420

23 months agoRemove telnetd sources
Brooks Davis [Wed, 5 Oct 2022 16:26:30 +0000 (17:26 +0100)]
Remove telnetd sources

Differential Revision: https://reviews.freebsd.org/D36621

23 months agopf: use time_to for timestamps
Kristof Provost [Thu, 29 Sep 2022 12:45:03 +0000 (14:45 +0200)]
pf: use time_to for timestamps

Use time_t rather than uint32_t to represent the timestamps. That means
we have 64 bits rather than 32 on all platforms except i386, avoiding
the Y2K38 issues on most platforms.

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

23 months agoif_vxlan(4): Add missing statistic for input packets
Zhenlei Huang [Wed, 5 Oct 2022 10:38:30 +0000 (12:38 +0200)]
if_vxlan(4): Add missing statistic for input packets

Event: Aberdeen hackathon 2022
Reviewed by: bryanv, kp
Differential Revision: https://reviews.freebsd.org/D36841

23 months agodhclient-script: cope with /32 address leases
Kristof Provost [Wed, 5 Oct 2022 10:11:07 +0000 (12:11 +0200)]
dhclient-script: cope with /32 address leases

On certain cloud platforms (Google Cloud, Packet.net and others) the
DHCP server offers a /32 address. This makes adding the default route
fail since it is not reachable via any interface. Linux's
dhclient-script seem to usually have a special case for that and
explicitly adds an interface route to the router's address.

FreeBSD's dhclient-script already has a special case for when the router
address is the same as the leased address. Now also add one for when
it's a different address that doesn't fall in the interface's subnet.

PR: 241792
Event: Aberdeen hackathon 2022
Submitted by: sigsys@gmail.com
Reviewed by: dch, kp, bz (+1 on the idea, not reviewed), thj
MFC after: 1 week

23 months agousb(4): Make sure the enumeration thread doesn't loop too fast.
Hans Petter Selasky [Thu, 9 Jun 2022 13:15:49 +0000 (15:15 +0200)]
usb(4): Make sure the enumeration thread doesn't loop too fast.

MFC after: 1 week
Sponsored by: NVIDIA Networking

23 months agovt(4): Clear paste buffer after pasting.
Ivan Quitschal [Wed, 5 Oct 2022 08:37:08 +0000 (10:37 +0200)]
vt(4): Clear paste buffer after pasting.

MFC after: 1 week
Sponsored by: NVIDIA Networking
Differential Revision: https://reviews.freebsd.org/D36042

23 months agovt(4): When cutting a line, append a newline character.
Ivan Quitschal [Wed, 5 Oct 2022 09:20:54 +0000 (11:20 +0200)]
vt(4): When cutting a line, append a newline character.

While at it optimise "case 3" into a default.
This way there is no need to initialize the "mark" variable in the beginning,
because all cases set it.

MFC after: 1 week
Sponsored by: NVIDIA Networking
Differential Revision: https://reviews.freebsd.org/D36042

23 months agovt(4): Use define instead of numerical value.
Hans Petter Selasky [Wed, 5 Oct 2022 09:50:42 +0000 (11:50 +0200)]
vt(4): Use define instead of numerical value.

No functional change intended.

MFC after: 1 week
Sponsored by: NVIDIA Networking

23 months agovt(4): Make sure pressing the extend button updates the current selection.
Hans Petter Selasky [Wed, 5 Oct 2022 09:40:01 +0000 (11:40 +0200)]
vt(4): Make sure pressing the extend button updates the current selection.

MFC after: 1 week
Sponsored by: NVIDIA Networking

23 months agoRemove an extra argument to SYSCTL_FOREACH
Andrew Turner [Wed, 5 Oct 2022 09:27:48 +0000 (10:27 +0100)]
Remove an extra argument to SYSCTL_FOREACH

This was missed in e0853c933661.

Sponsored by: The FreeBSD Foundation

23 months agoUse SYSCTL_FOREACH in drm2
Andrew Turner [Wed, 5 Oct 2022 09:24:13 +0000 (10:24 +0100)]
Use SYSCTL_FOREACH in drm2

This was added recently. Use it to get the correct _FOREACH macro.

Sponsored by: The FreeBSD Foundation

23 months agoRemove pre-armv6 support from devmap
Andrew Turner [Wed, 5 Oct 2022 08:53:12 +0000 (09:53 +0100)]
Remove pre-armv6 support from devmap

Remove an old code path that was used used by Armv4/5 so is unused now.

Sponsored by: The FreeBSD Foundation

23 months agotraceroute6: fix capabilities for the rcv socket
Michael Tuexen [Tue, 4 Oct 2022 21:34:58 +0000 (23:34 +0200)]
traceroute6: fix capabilities for the rcv socket

On the receive socket, recvmsg() and poll()/select() is called.
Therefore, CAP_EVENT is needed in addition to CAP_RECV..

While there, check the socket for readbility before calling recvmsg().

Reviewed by: markj@
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D36878

23 months agonetlink: make it working without INET6
Gleb Smirnoff [Tue, 4 Oct 2022 21:39:49 +0000 (14:39 -0700)]
netlink: make it working without INET6

23 months agonetlink: fix standalone module build
Gleb Smirnoff [Tue, 4 Oct 2022 21:38:40 +0000 (14:38 -0700)]
netlink: fix standalone module build

23 months agossh-keysign: fix double free in error path
Ed Maste [Tue, 4 Oct 2022 20:34:15 +0000 (16:34 -0400)]
ssh-keysign: fix double free in error path

From OpenSSH-portable commit 141535b904b6, OpenBSD commit 3d21aa127b1f.

MFC after: 3 days

23 months agossh-keygen: fix double free in error path
Ed Maste [Tue, 4 Oct 2022 20:31:39 +0000 (16:31 -0400)]
ssh-keygen: fix double free in error path

From OpenSSH-portable commit 5062ad48814b, OpenBSD commit 39f35e16ba87.

MFC after: 3 days

23 months agossh-keyscan: Strictly enforce the maximum allowed SSH2 banner size
Ed Maste [Tue, 4 Oct 2022 20:28:13 +0000 (16:28 -0400)]
ssh-keyscan: Strictly enforce the maximum allowed SSH2 banner size

From OpenSSH-portable commit ff89b1bed807, OpenBSD commit 6ae664f9f4db.

MFC after: 3 days

23 months agozfs: merge openzfs/zfs@d62bafee9
Martin Matuska [Tue, 4 Oct 2022 18:16:52 +0000 (20:16 +0200)]
zfs: merge openzfs/zfs@d62bafee9

Notable upstream pull request merges:
  #13857 Enforce "-F" flag on resuming recv of full/newfs on existing dataset
  #13928 Revert "Reduce dbuf_find() lock contention"
  #13928 Dynamically size dbuf hash mutex array
  #13930 zpool: Don't print "repairing" on force faulted drives
  #13938 Bring per_txg_dirty_frees_percent back to 30
  #13939 Fix panic in dsl_process_sub_livelist for EINTR
  #13954 Fix bad free in skein code
  #13967 Fix potential NULL pointer dereference in dsl_dataset_promote_check()

Obtained from: OpenZFS
OpenZFS commit: d62bafee9fc38f8b9653c531e1861e83dcba4618

23 months agogit-arc: Fix handling of review title containing double quotes
Mark Johnston [Tue, 4 Oct 2022 16:59:13 +0000 (12:59 -0400)]
git-arc: Fix handling of review title containing double quotes

23 months agodtrace: Add a "regs" variable
Mark Johnston [Tue, 4 Oct 2022 16:54:36 +0000 (12:54 -0400)]
dtrace: Add a "regs" variable

This allows invop-based providers (i.e., fbt and kinst) to expose the
register file of the CPU at the point where the probe fired.  It does
not work for SDT providers because their probes are implemented as plain
function calls and so don't save registers.  It's not clear what
semantics "regs" should have for them anyway.

This is akin to "uregs", which nominally provides access to the
userspace registers.  In fact, DIF already had a DIF_VAR_REGS variable
defined, it was simply unimplemented.

Usage example: print the contents of %rdi upon each call to
amd64_syscall():

    fbt::amd64_syscall:entry {printf("%x", regs[R_RDI]);}

Note that the R_* constants are defined in /usr/lib/dtrace/regs_x86.d.
Currently there are no similar definitions for non-x86 platforms.

Reviewed by: christos
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D36799

23 months agomakefs: Add a cast to placate static analyzers
Mark Johnston [Tue, 4 Oct 2022 16:50:13 +0000 (12:50 -0400)]
makefs: Add a cast to placate static analyzers

"prefixlen" will always be smaller than 32 but adding a cast is
harmless.

Reported by: Coverity

23 months agoriscv: Apply 8d7ee2047c5e to the riscv pmap
Mark Johnston [Tue, 4 Oct 2022 16:49:36 +0000 (12:49 -0400)]
riscv: Apply 8d7ee2047c5e to the riscv pmap

Reviewed by: alc
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36840

23 months agomakefs: Plug a memory leak
Mark Johnston [Tue, 4 Oct 2022 16:46:39 +0000 (12:46 -0400)]
makefs: Plug a memory leak

nvlist_find_string() would return a copy of the found value, but callers
assumed they would have to make their own copy.  It's simpler to change
nvlist_find_string() than it is to change callers, so do that.

Reported by: Coverity

23 months agoInclude opt_platform.h to ensure FDT is defined
Andrew Turner [Tue, 4 Oct 2022 16:31:01 +0000 (17:31 +0100)]
Include opt_platform.h to ensure FDT is defined

We need to include opt_platform.h as it's where FDT will be defined.

Sponsored by: The FreeBSD Foundation

23 months agoRemove unneeded FDT checks from phydev and regdev
Andrew Turner [Tue, 4 Oct 2022 16:27:59 +0000 (17:27 +0100)]
Remove unneeded FDT checks from phydev and regdev

They are only ever built when FDT is enabled so there is no need to
check for it in the files.

Sponsored by: The FreeBSD Foundation

23 months agoClear the indirect flag in the GICv3 ITS driver
Andrew Turner [Tue, 4 Oct 2022 11:46:24 +0000 (12:46 +0100)]
Clear the indirect flag in the GICv3 ITS driver

Summary:
The indirect flag tells the hardware to use a flat or two level table.
As we only support using the flat table ensure the flag that marks
which is in use is set correctly.

We can't rely on this being set correctly as some firmware may set the
indirect flag, e.g. booting from LinuxBoot.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36873

23 months agolibc: Fix size range check in setvbuf
Ed Maste [Mon, 3 Oct 2022 18:24:42 +0000 (14:24 -0400)]
libc: Fix size range check in setvbuf

From enh at google.com via openbsd-tech mailing list via pfg@:

The existing test is wrong for LP64, where size_t has twice as many
relevant bits as int, not just one. (Found by inspection by
rprichard.)

23 months agoFix kernel build after 754cb545b68ba0a1643792763d000018ffe2afec .
Hans Petter Selasky [Tue, 4 Oct 2022 15:09:07 +0000 (17:09 +0200)]
Fix kernel build after 754cb545b68ba0a1643792763d000018ffe2afec .

By adding missing include file for powerpc64, QORIQ64.

Differential Revision: https://reviews.freebsd.org/D36565
MFC after: 1 week
Sponsored by: NVIDIA Networking

23 months agopci: Disable Electromechanical Interlock.
Alexander Motin [Tue, 4 Oct 2022 14:34:15 +0000 (10:34 -0400)]
pci: Disable Electromechanical Interlock.

Add sysctl/tunable to control Electromechanical Interlock support.
Disable it by default since Linux does not do it either and it seems
the number of systems having it broken is higher than having working.

This fixes NVMe backplane operation on ASUS RS500A-E11-RS12U server
with AMD EPYC 7402 CPU, where attempts to control reported interlock
for some reason end up in PCIe link loss, while interlock status does
not change (it is not really there).

MFC after: 2 weeks

23 months agoFix kernel build after fcb3f813f379f544f9cd2a10d18045588da0e132 .
Hans Petter Selasky [Tue, 4 Oct 2022 14:08:20 +0000 (16:08 +0200)]
Fix kernel build after fcb3f813f379f544f9cd2a10d18045588da0e132 .

By adding missing ifdefs for INET and INET6 when building LINT-NOIP .

Differential Revision: https://reviews.freebsd.org/D36731
Sponsored by: NVIDIA Networking

23 months agoFix kernel build after fcb3f813f379f544f9cd2a10d18045588da0e132 .
Hans Petter Selasky [Tue, 4 Oct 2022 13:55:15 +0000 (15:55 +0200)]
Fix kernel build after fcb3f813f379f544f9cd2a10d18045588da0e132 .

By adding missing ifdefs for INET6 .

Differential Revision: https://reviews.freebsd.org/D36731
Sponsored by: NVIDIA Networking

23 months agoFix kernel build after fcb3f813f379f544f9cd2a10d18045588da0e132 .
Hans Petter Selasky [Tue, 4 Oct 2022 13:41:39 +0000 (15:41 +0200)]
Fix kernel build after fcb3f813f379f544f9cd2a10d18045588da0e132 .

By updating function arguments for ipsec_kmod_ctlinput() which is used
when loading IPSEC support via kernel modules.

Differential Revision: https://reviews.freebsd.org/D36731
Sponsored by: NVIDIA Networking

23 months agotime(3): Increase precision of time conversion functions by using gcd.
Hans Petter Selasky [Sun, 2 Oct 2022 22:15:09 +0000 (00:15 +0200)]
time(3): Increase precision of time conversion functions by using gcd.

When converting times to and from units which have many leading zeros,
it pays off to compute the greatest common divisor first, and then do the
scaling product. This way all time unit conversion comes down to scaling a
signed or unsigned 64-bit value by a fraction represented by two signed
or unsigned 32-bit integers.

SBT_1S is defined as 2^32 . When scaling using powers of 10 above 1,
the gcd of SBT_1S and 10^N is always greater than or equal to 4,
when N is greater or equal to 2.

Scaling a sbt value to milliseconds is then done by multiplying by
(1000 / 8) and dividing by (2^32 / 8).

This trick allows for higher precision at very little additional CPU cost.

It shall also be noted that the Xtosbt() functions prior to this patch,
sometimes were off-by-one:

For example when converting 1 / 8 of a second to sbt as 125ms the old sbt
conversion function would compute 0x20000001 while the new function computes
0x20000000 which multiplied by 8 becomes SBT_1S, which is the correct value.

Reviewed by: kib@
Differential Revision: https://reviews.freebsd.org/D36857
MFC after: 1 week
Sponsored by: NVIDIA Networking

23 months agocuse(3): Cosmetic change about testing boolean values.
Hans Petter Selasky [Tue, 4 Oct 2022 10:31:51 +0000 (12:31 +0200)]
cuse(3): Cosmetic change about testing boolean values.

No functional change intended.

Differential Revision: https://reviews.freebsd.org/D36633
Suggested by: jrtc27@ and avg@
MFC after: 1 week
Sponsored by: NVIDIA Networking

23 months agoqdivrem: Predict division by zero as false.
Hans Petter Selasky [Tue, 4 Oct 2022 10:28:25 +0000 (12:28 +0200)]
qdivrem: Predict division by zero as false.

Division by zero triggers an arithmetic exception and should not be very
common. Predict this.

No functional change intended.

MFC after: 1 week
Sponsored by: NVIDIA Networking

23 months agotcp idle reduce does not work for a server.
Randall Stewart [Tue, 4 Oct 2022 11:09:01 +0000 (07:09 -0400)]
tcp idle reduce does not work for a server.

TCP has an idle-reduce feature that allows a connection to reduce its
cwnd after it has been idle more than an RTT. This feature only works
for a sending side connection. It does this by at output checking the
idle time (t_rcvtime vs ticks) to see if its more than the RTO timeout.

The problem comes if you are a web server. You get a request and
then send out all the data.. then go idle. The next time you would
send is in response to a request from the peer asking for more data.
But the thing is you updated t_rcvtime when the request came in so
you never reduce.

The fix is to do the idle reduce check also on inbound.

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

23 months agotcp_timers: provide tcp_timer_drop() and tcp_timer_close()
Gleb Smirnoff [Tue, 4 Oct 2022 05:21:55 +0000 (22:21 -0700)]
tcp_timers: provide tcp_timer_drop() and tcp_timer_close()

Two functions to call tcp_drop() and tcp_close() from a callout context.
Garbage collect tcp_inpinfo_lock_del(), it has a single use now.

Differential revision: https://reviews.freebsd.org/D36397

23 months agotcp: make tcp_drop_syn_sent() static
Gleb Smirnoff [Tue, 4 Oct 2022 04:11:17 +0000 (21:11 -0700)]
tcp: make tcp_drop_syn_sent() static

23 months agonetinet*: remove PRC_ constants and streamline ICMP processing
Gleb Smirnoff [Tue, 4 Oct 2022 03:53:04 +0000 (20:53 -0700)]
netinet*: remove PRC_ constants and streamline ICMP processing

In the original design of the network stack from the protocol control
input method pr_ctlinput was used notify the protocols about two very
different kinds of events: internal system events and receival of an
ICMP messages from outside.  These events were coded with PRC_ codes.
Today these methods are removed from the protosw(9) and are isolated
to IPv4 and IPv6 stacks and are called only from icmp*_input().  The
PRC_ codes now just create a shim layer between ICMP codes and errors
or actions taken by protocols.

- Change ipproto_ctlinput_t to pass just pointer to ICMP header.  This
  allows protocols to not deduct it from the internal IP header.
- Change ip6proto_ctlinput_t to pass just struct ip6ctlparam pointer.
  It has all the information needed to the protocols.  In the structure,
  change ip6c_finaldst fields to sockaddr_in6.  The reason is that
  icmp6_input() already has this address wrapped in sockaddr, and the
  protocols want this address as sockaddr.
- For UDP tunneling control input, as well as for IPSEC control input,
  change the prototypes to accept a transparent union of either ICMP
  header pointer or struct ip6ctlparam pointer.
- In icmp_input() and icmp6_input() do only validation of ICMP header and
  count bad packets.  The translation of ICMP codes to errors/actions is
  done by protocols.
- Provide icmp_errmap() and icmp6_errmap() as substitute to inetctlerrmap,
  inet6ctlerrmap arrays.
- In protocol ctlinput methods either trust what icmp_errmap() recommend,
  or do our own logic based on the ICMP header.

Differential revision: https://reviews.freebsd.org/D36731

23 months agonetipsec: move specific ipsecmethods declarations to ipsec_support.h
Gleb Smirnoff [Tue, 4 Oct 2022 03:53:04 +0000 (20:53 -0700)]
netipsec: move specific ipsecmethods declarations to ipsec_support.h

where struct ipsec_methods is defined.  Not a functional change.
Allows further modification of method prototypes without breaking
compilation of other ipsec compilation units.

Differential revision: https://reviews.freebsd.org/D36730

23 months agonetinet*: remove dead code from TCP, UDP, SCTP control input
Gleb Smirnoff [Tue, 4 Oct 2022 03:53:04 +0000 (20:53 -0700)]
netinet*: remove dead code from TCP, UDP, SCTP control input

Now these functions are called only from icmp*_input().  The pointer
to the ICMP data is never NULL and cmd has a limited set of values.

In the past the functions were demultiplexing control messages from
ICMP layer, as well as internally generated events.  In the latter
case the the pointer to IP would be NULL.

Differential revision: https://reviews.freebsd.org/D36729