Commit Graph

302587 Commits

Author SHA1 Message Date
Muhammad Saheed 94ed4c1903 libifconfig: Add netlink based helper to bring the interface up/down
Adds `ifconfig_set_up()` to set and unset the `IFF_UP`
on a network interface using `RTM_NEWLINK`.

Sponsored by:	Google LLC (GSoC)
Reviewed by:	obiwac, mckusick (mentor), kp
Approved by:	obiwac, mckusick (mentor), kp
Differential Revision:	https://reviews.freebsd.org/D52128
2025-08-29 17:39:39 +02:00
Marius Halden 6e6febb54d w: Fix idle time in json output, add login/idle times to json output
Currently the idle time will show as `true` part of the time in the json
output and quoting depends on what is being printed. Make sure it's
always printed correctly and for consistency treated as a string in the
json output.

Login time delta and since times are currently exposed in the xml
output, expose these times in the json output as well.

In the json and xml outputs expose the number of seconds idle as a new
field or attribute respectively.

MFC after:	1 week
Sponsored by:	Modirum MDPay
Event:		Oslo Hackathon 202508
Differential Revision:	https://reviews.freebsd.org/D52237
2025-08-29 16:53:26 +02:00
Bjoern A. Zeeb 86a0941db7 LinuxKPI: 802.11: do not delete keys while still assoc
While we are still associated we cannot delete the keys as packets
may still go out and if the firmware has no more keys it will raise
and exception.

This can happen given net80211 has its own mind when to do this and
we, in various places, unlock and re-lock the com lock, so are open
to races.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-08-29 13:18:43 +00:00
Bjoern A. Zeeb a4c17ecf96 LinuxKPI: 802.11: introduce a debug flag for scan/beacon logging
Split the scan logging up into scan and scan/beacon in order to
not log every beacon if we are trying to debug the scan machinery
but not the actual results.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-08-29 13:18:43 +00:00
Bjoern A. Zeeb ad4ddc83eb LinuxKPI: 802.11: sort the fallback to software scan for rtw88
In the special case hardware scan fails to start, we cancel the
scan with net80211 and cleanup our part.  In that case we now
sleep and wait for a wakeup.  The wakeup was moved to a different
callback function to serve both cases (hw scan cancelled, and
hw scan failed).

In the very special case the hardware scan fails with a return code
of 1, we need to start a software scan.  I cannot fully imagine this
ever worked well (some rtw88 chipsets are using this).  The trouble
is that the cancael_scan runs in a taskq in net80211 and by the time
we tried to start the new scan, the old one was not fully cleaned up
and finished (or could have been restarted in case we enable bgscan).
So defer starting the software scan to the taskq as well and it will
run once the previous finished.  The RTW8821ce I tested with seemed
a lot more happy.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-08-29 13:18:43 +00:00
Bjoern A. Zeeb eb4722614a LinuxKPI: 802.11: improve scan/beacon tracing in RX path
In one of my setups I am sometimes seeing "ghost beacons" (beacons from a
BSSID on a 2nd channel where it is not sending beacons; also checked with
a monitor node to be sure).
In order to rule out later processing errors I added debugging early on
in the LinuxKPI 802.11 RX path.  This will at least help us (users) to
debug possible problems more easily by turning on scan debugging (either
here, or using wlandebug +scan to get the net80211 view on it, or both).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-08-29 13:18:42 +00:00
Bjoern A. Zeeb 075a75efa6 LinuxKPI: 802.11: improve scanning when not using the net80211 chanlist
With the option to not use the net80211 scan list but scan all channels
(if we can scan all bands at once, etc.) we possibly scanned more
channels than needed (or we should have).  Add a helper function to
sort out disabled channels and channels which are not on the net80211
ic_chan_active list (e.g. removed by regdomain).  This could potentially
also remove channels for a 2nd band for software scanning, but in the
offload cases it should not.

Add scan logging for the disabled channels and add scan logging to print
the finalized channel list we are using for this scan (as net80211 has a
similar logging).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-08-29 13:18:42 +00:00
Bjoern A. Zeeb be1ae08d0a LinuxKPI: 802.11: use ni_dtim_period instead of iv_dtim_period
Both iwm(4) and iwx(4) are using the iv_dtim_period from the vap.
This likely stems from the fact that ieee80211_sta_join() while setting
up the ni basics does set the dtim_period on the vap (we should revist
this in net80211) from the scan results.

The problem with that is that once we are associated and are receiving
beacons, sta_recv_mgmt() will handle the TIM IE and and save the
tim period and tim count in ni_dtim_period and ni_dtim_count on the node.

Given we need to inform the driver/firmware (at least for iwlwifi)
with values from beacons received after assoc, the ni is the better
place the take the value from (though the beacons hopefully stay
consistent).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-08-29 13:18:42 +00:00
Bjoern A. Zeeb 1d77e11f6c LinuxKPI: 802.11: scanning improvements and experiments
Introduce SCAN tracing by adding a dedicated debug category for it
and sprinkle some TRACE_SCAN() lines in hopefully helpful places.

Add an experimental sysctl to re-sort the scan channel list based on
"primary" channels first and 5Ghz before 2Ghz.
Also start scanning the higher bands first (5Ghz before 2.4 even without
the sysctl set).
These are largely a result of various reports of people not able to
see their BSSID on 5Ghz.  How much of a difference this will make
in real world and depending on driver/firmware is for the people to
experiment.  In my observations iwlwifi(4) independent on all this
presents scan results 2.4 band channels 1..14 first, and then the
5Ghz band channels 177..32.

Factor out re-enabling hardware scan.  This is used especially in case
of rtw88 to not be stuck on software scan forever if the rtw88 driver
decides that it currently cannot do a full hw offload scan.

Add compile time support for BGSCANs but keep it disabled by default
as during testing races with net80211 and some APs idle-disconnect
were found.  Still check in the code in case we do see a bgscan
despite it being disabled.  This stems from 32af70fae8.

Minor improvements like recording the scan_start time and making sure
we properly cancel/restart scans if hw offload scan fails.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-08-29 13:18:42 +00:00
Bjoern A. Zeeb fc36de571f LinuxKPI: 802.11: adjust lower wake_queue locking
In bc24342d96 we added lower wake_queue locking.  There are paths,
such as in rtw89 from a (*hw_scan_cancel)() that we can get to there and
then would recursively acquire the wiphy lock which is not allowed.
Adjust locking to a spin lock to match Linux driver expectations.

Sponsored by:	The FreeBSD Foundation
Fixes:		bc24342d96
MFC after:	3 days
2025-08-29 13:18:41 +00:00
Bjoern A. Zeeb d1df103190 LinuxKPI: 802.11: mark all structs in struct ieee80211_mgmt __packed
These structs as part of the union are used to handle raw packet data
so mark them all __packed.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-08-29 13:18:41 +00:00
Bjoern A. Zeeb a99462b0c9 rtw88: ensure channel definitions have band set
A Linux definition of a channel has freq, hw_value, band, and flags.
rtw88 so far only set the first two but never set the band on the
channel.
This sorted out channels from scanning (at least after updates) but
possibly also led to other unnoticed circumstances.

Use the macros from rtw89 and replicate the information properly
filling band on each channel definition as well.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-08-29 13:18:41 +00:00
Bjoern A. Zeeb a274435d0d LinuxKPI: implement str_disable_enable()
Implement str_disable_enable() needed by a wireless driver by using
the already existing str_enable_disable() with a toggled argument.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D52081
2025-08-29 13:18:41 +00:00
Bjoern A. Zeeb 7dce26eded usb: hub: uhub_root_intr() mark function arguments as __unused
No functional change.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	aokblast, imp
Differential Revision: https://reviews.freebsd.org/D52147
2025-08-29 13:18:40 +00:00
Alexander Ziaee b4a560d34f man4/Makefile: Add a reminder about architectures
MFC after:		3 days
Suggested by:		emaste
Reviewed by:		bcr
Differential Revision:	https://reviews.freebsd.org/D51464
2025-08-29 08:49:27 -04:00
Alexander Ziaee 4cf5878d27 devinfo.8: Document libxo support
PR:		289151
Fixes:		c759aca606 (Add support for libxo)
MFC after:	3 days
Reviewed by:	imp
Closes:		https://github.com/freebsd/freebsd-src/pull/1829
2025-08-29 08:43:45 -04:00
Alexander Ziaee 7e477aac80 devinfo.8: Polish
+ replace "-*- nroff -*-" comment with SPDX tag
+ alphabetize options in SYNOPSIS and DESCRIPTION
+ add HISTORY, correct two minor mdoc typos

MFC after:	3 days
Reviewed by:	imp
Closes:		https://github.com/freebsd/freebsd-src/pull/1829
2025-08-29 08:43:29 -04:00
Zhenlei Huang 2ddb9cbe42 git-blame-ignore-revs: witness white space cleanup and style(9) tweeks
MFC after:	3 days
2025-08-29 18:01:43 +08:00
Zhenlei Huang f537766525 witness: White space cleanup and some style(9) tweeks
MFC after:	3 days
2025-08-29 18:00:57 +08:00
Kajetan Staszkiewicz 65c3186301 pf: Add prefer-ipv6-nexthop option for route-to pools
Now that pf is aware of address family of each pool address and source
tracking uses distinct address family for source and redirection
adddresses it is possible to add a new pool option prefer-ipv6-nexthop
which enables routing of IPv4 packets over IPv6 next hops for rules
with the route-to option.

Add a pool option flag PF_POOL_IPV6NH, apply it to pools with a keyword
prefer-ipv6-nexthop.

Modify pf_map_addr() to handle pools with addresses of different
families. Use *naf as a hint about what address family the forwarded
packet is, then pick from the pool addresses of family that can be used
as a next hop for the forwarded packet, controlled by the PF_POOL_IPV6NH
flag. For NAT pools this flag is never set and thus pf_map_addr()
will return an IP address of the same family as the forwarded packet.
For route-to pools when the flag is enabled IPv6 addresses can be
returned or IPv4 packets.

In pf_route() check rt_af, it is not guaranteed to be AF_INET anymore
because pf_map_addr() could have changed it (as *naf).

Add tests for behaviour of pf_map_addr() both with PF_POOL_IPV6NH and
without, for single IP addresses, prefixes and subnets.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D50781
2025-08-29 09:58:40 +02:00
Colin Percival 778bfd4e10 Chase pkg repo rename in cloudware builds
We ship cloudware images without a downloaded copy of the pkg repo
database, since it will typically be wildly out of date by the time
cloudware releases get launched.  These paths changed due to the
"FreeBSD" -> "FreeBSD-ports" renaming in /etc/pkg/FreeBSD.conf.

While I'm here, nuke the FreeBSD-ports-kmods repo database too; I
forgot to add that when we added that to /etc/pkg/FreeBSD.conf.

Fixes:	c83705a575 ("Rename FreeBSD* pkg repos to FreeBSD-ports*")
2025-08-28 11:36:15 -07:00
Konstantin Belousov c18e41de74 vm_fault.c: rename vm_fault_quick_hold_pages_e() to vm_fault_hold_pages_e()
Suggested and reviewed by:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential review:	https://reviews.freebsd.org/D52224
2025-08-28 21:09:19 +03:00
John Baldwin 35d271a4c7 bsd.man.mk: Handle relative paths for MK_MANCOMPRESS=no
If MANSRC.{TARGET} is not used, don't truncate the source path of the
page using :T.

Reported by:	matteo
Fixes:		65f60d715f ("bsd.man.mk: Add a MANSRC.{TARGET} variable")
Sponsored by:	Chelsio Communications
2025-08-28 13:36:17 -04:00
John Baldwin 6d0016aea2 ObsoleteFiles.inc: Treat usr/lib/libwind.so.11 as a library
Reviewed by:	ivy
Fixes:		721c98dd89 ("OptionalObsoleteFiles: Update Kerberos entries")
Differential Revision:	https://reviews.freebsd.org/D52208
2025-08-28 13:35:34 -04:00
Alexander Ziaee 0e17080395 gpio.4: Remove non-existent gpioc from synopsis
MFC after:	3 days
Reported by:	maxfx, kevans
2025-08-28 13:13:41 -04:00
Warner Losh eb1145f0c4 nvme: Style tweaks
Fix a couple of minor style nits that I've noticed (including the
historical initial blank line). Do this all at once rather than many
commits.

Sponsored by:		Netflix
2025-08-28 10:32:39 -06:00
Warner Losh f13301fd3c nvme: fix byte conversion macros
Fix the byte conversion macros for rsvd{2,3}. They are 32-bit quantity,
not 16, so use htole32. These typically aren't used, so this is a nop
for all in-tree uses. This would only have an effect on
powerpc64. Otherwise, we pass the value through unchanged.

Sponsored by:		Netflix
2025-08-28 10:21:54 -06:00
Zhenlei Huang 80dfed11fc vtnet: Do not compare boolean with integer
The type of variable promisc and allmulti was changed from int to bool
by commit [1].

[1] 7dce56596f Convert to if_foreach_llmaddr() KPI

MFC after:	3 days
2025-08-28 23:59:21 +08:00
Konstantin Belousov be8bae6700 vfs: make vfscount refcounting handle possible kld unload
Make the refcounting occur outside any code that might deref a pointer
to struct vfsconf.

Increment vfc_refcount in vfs_byname(), under vfsconf_lock.
Unref either on early mount failure, before struct mount is
instantiated, or in vfs_mount_destroy().

Reported and reviewed by:	kevans
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2025-08-28 18:21:54 +03:00
Ed Maste 959806e0a8 Merge commit 7a66a26658f4 from llvm git (by Fangrui Song):
--discard-locals/--discard-all: allow and keep symbols referenced by relocations

  In GNU objcopy, symbols referenced by relocations are retained. Our
  COFF (https://reviews.llvm.org/D56480) and Mach-O
  (https://reviews.llvm.org/D75104) ports port the behavior, but the ELF
  port doesn't.

  This PR implements the behavior for ELF.
  Close #47468 (tcl has a use case that requires `strip -x tclStubLib.o`
  to strip local symbols not referenced by relocations.)

  Pull Request: https://github.com/llvm/llvm-project/pull/130704

PR:		258820
Approved by:	dim
Differential Revision: https://reviews.freebsd.org/D52198
2025-08-28 09:07:13 -04:00
Michael Tuexen e6253eac1a vtnet: mark statistic counters with CTLFLAG_STATS
Reviewed by:	Timo Völker
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D51999
2025-08-28 12:36:59 +02:00
Michael Tuexen 9a4b30dabf tcp: remove stale comment
MFC after:	3 days
Sponsored by:	Netflix, Inc.
2025-08-28 11:35:19 +02:00
Michael Tuexen 03da439515 vtnet: fix computation of sysctl variables
Fix the aggregation of the interface level counters
* dev.vtnet.X.tx_task_rescheduled,
* dev.vtnet.X.tx_tso_offloaded,
* dev.vtnet.X.tx_csum_offloaded,
* dev.vtnet.X.rx_task_rescheduled,
* dev.vtnet.X.rx_csum_offloaded, and
* dev.vtnet.X.rx_csum_failed.
Also ensure that dev.vtnet.X.tx_defrag_failed only counts the number
of times m_defrag() fails.
While there, mark sysctl-variables used for exporting statistics as
such (CTLFLAG_STATS).

Reviewed by:		Timo Völker
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D51999
2025-08-28 11:27:00 +02:00
Zhenlei Huang 393356f25f ifnet: Don't include ethernet.h twice
MFC after:	3 days
2025-08-28 12:29:06 +08:00
Colin Percival 579bb6c2cd Update comments to match pkg repo renaming
Reported by:	Ceri Davies
Fixes:		c83705a575 ("Rename FreeBSD* pkg repos to FreeBSD-ports*")
2025-08-27 15:48:46 -07:00
Konstantin Belousov fe53e046cd nfs client: switch nfs_advlock() to use exclusive vnode lock
It eliminates the need to upgrade the lock in the function.
More importantly, the calls to nfs_advlock_p()/nlm_advlock() sometimes
flush buffers, which requires exclusive locking.

Reported and tested by:	bz
Reviewed by:	rmacklem
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D52195
2025-08-28 01:36:50 +03:00
Ahmad Khalifa ef73953ebd gpioc: remove unnecessary bus_generic_* calls
gpioc never has any children, so there's no need to call these.

Reviewed by:	jhb
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D51933
2025-08-28 00:38:32 +03:00
Ahmad Khalifa 186100f13b gpio: make gpioc a child of gpiobus
With gpioc being a direct child of the GPIO controller, it can't
allocate interrupts properly. It currently allocates interrupts using
it's parent dev (gpioX). This causes problems since the call never goes
through gpiobus. Instead, make gpioc a child of gpiobus and allocate
interrupts using our own dev. Also don't misuse pin->flags, it's not
meant to store the flags from sys/gpio.h

Reported by:	Evgenii Ivanov <devivanov@proton.me>
Reviewed by:	mmel
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D51932
2025-08-28 00:38:32 +03:00
Ahmad Khalifa 4fd32b1e7f gpio: add GPIO_GET_PIN_LIST
While most GPIO controllers provide pins from 0 .. N in a sequential
manner, not all controllers start with pin 0, and not all controllers
order their pins sequentially. Allow callers to get a pin list from the
controller. The default behaviour is to fill pin_list with pins 0 to
GPIO_PIN_MAX().

Suggested by:	mmel
Reviewed by:	mmel
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D52172
2025-08-28 00:38:32 +03:00
Ahmad Khalifa 59e74fdfaf gpioc: cleanup if pin allocation fails
gpioc normally depends on gpioc_cdevpriv_dtor to call
gpioc_release_pin_intr when it's done with a pin. However, if
gpioc_allocate_pin_intr fails, the pin is never added to the linked list
which the destructor loops over to free the pins. Make it so
gpioc_allocate_pin_intr cleans up after itself if it fails.

Reported by:	Evgenii Ivanov <devivanov@proton.me>
Approved by:	imp (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D51998
2025-08-28 00:38:32 +03:00
Ahmad Khalifa 39bdc7d19b gpiobus: add pin_config_32 and pin_access_32
Add pin_config_32 and pin_access_32 to the gpiobus interface. These work
like the rest of the gpiobus interface. For example, if a child has the
following pins in it's ivars: {2, 7 ... 38} calling these functions with
pin 1 will configure/access pins 7 - 38 on the controller.

Reviewed by:	mmel
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D51931
2025-08-28 00:38:31 +03:00
Ahmad Khalifa e4eba4b9b0 gpiobus: style
Approved by:	imp (mentor, implicit)
2025-08-28 00:38:31 +03:00
Jessica Clarke 840edcd292 sysbuild: Copy /etc/localtime as symlink
Without -P (or -R, which defaults to enabling -P) symlinks are
dereferenced and so the target file is copied, not the symlink itself.

Fixes:	5e16809c95 ("tzsetup: symlink /etc/localtime instead of copying")
2025-08-27 22:35:55 +01:00
Jessica Clarke ccbd3de0f3 bsdinstall: Copy /etc/localtime as symlink in jail script
Without -P (or -R, which defaults to enabling -P) symlinks are
dereferenced and so the target file is copied, not the symlink itself.

Fixes:	5e16809c95 ("tzsetup: symlink /etc/localtime instead of copying")
2025-08-27 22:35:54 +01:00
Ed Maste ac7ed266dc Makefile.inc1: Avoid including cwd in path
Buildworld failed when objcopy tried to overwrite itself, with `objcopy:
open objcopy failed: Text file busy`.  The PATH ended up with `::`,
effectively including the current directory, and we found the wrong
objcopy.

PR:		261215
Sponsored by:	The FreeBSD Foundation
2025-08-27 17:34:12 -04:00
Ka Ho Ng a93e46f156 irdma: normalize .CURDIR-relative paths to SRCTOP
Sponsored by:	Juniper Networks, Inc.
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D52192
2025-08-27 21:13:59 +00:00
Evgenii Ivanov b6a1c91b71 VFS.9: Remove obsolete reference to VFS_INIT(9)
MFC after:		3 days
Reviewed by:		ziaee
Differential Revision:	https://reviews.freebsd.org/D52173
2025-08-27 17:09:21 -04:00
John Baldwin 557cc0f350 bsd.man.mk: Handle MANSRC.{TARGET} for MK_MANCOMPRESS=no and empty MANBUILDCAT
Reviewed by:	kevans
Fixes:		65f60d715f ("bsd.man.mk: Add a MANSRC.{TARGET} variable")
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D52181
2025-08-27 16:11:54 -04:00
Boris Lytochkin 9ce29249ec makefs: Calculate indirect block count properly for large files on ffs
When building an ffs image containing large file(s), space requirements
were calculated incorrectly yielding a bigger image than necessary.
The reason is that amount of indirect blocks estimation was done wrong:

- single indirect block was treated as it can hold just 12 data blocks
- nested indirect blocks were not taken into account at all

Add support for indirect blocks and fix another tiny bug with
underestimated space requirement for files with size between
(UFS_NDADDR-1)*blksz+fragsz ... (UFS_NDADDR)*blksz requesting N>1
fragments instead of a whole block.

Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D52120
2025-08-27 15:18:50 -04:00
Dimitry Andric cb2887746f Merge commit cf721e29c6a3 from llvm git (by Amy Kwan):
[PowerPC] Do not merge TLS constants within PPCMergeStringPool.cpp (#94059)

  This patch prevents thread-local constants to be merged within
  PPCMergeStringPool.cpp.

  The PPCMergeStringPool pass primarily merges non-thread-local constants
  together, and thread-local constants should not be mixed together with
  other (non-thread-local) constants. In the event that thread-local and
  other non-thread-local constants are pooled together, the
  llvm.threadlocal.address intrinsic can fail as it expects its argument
  to be a thread-local global value, but the merged string structure
  created by the PPCMergeStringPool pass is not thread-local as a whole.

This fixes an error "llvm.threadlocal.address first argument must be a
GlobalValue" when building the math/nauty port on PowerPC architectures.

PR:		289122
Reported by:	pkubaj
MFC after:	3 days
2025-08-27 20:52:30 +02:00