Commit Graph

281891 Commits

Author SHA1 Message Date
Ed Maste
d7a491dd30 make showconfig: set MACHINE and MACHINE_ARCH
Previously these were not set for the showconfig target, so took the
host's value rather than the target.  As a result some machine-dependent
kernel options were not reported with correct defaults in the src.conf
manpage.

PR:		269994
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38926
2023-03-06 16:03:22 -05:00
Mark Johnston
713264f6b8 netinet: Tighten checks for unspecified source addresses
The assertions added in commit b0ccf53f24 ("inpcb: Assert against
wildcard addrs in in_pcblookup_hash_locked()") revealed that protocol
layers may pass the unspecified address to in_pcblookup().

Add some checks to filter out such packets before we attempt an inpcb
lookup:
- Disallow the use of an unspecified source address in in_pcbladdr() and
  in6_pcbladdr().
- Disallow IP packets with an unspecified destination address.
- Disallow TCP packets with an unspecified source address, and add an
  assertion to verify the comment claiming that the case of an
  unspecified destination address is handled by the IP layer.

Reported by:	syzbot+9ca890fb84e984e82df2@syzkaller.appspotmail.com
Reported by:	syzbot+ae873c71d3c71d5f41cb@syzkaller.appspotmail.com
Reported by:	syzbot+e3e689aba1d442905067@syzkaller.appspotmail.com
Reviewed by:	glebius, melifaro
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D38570
2023-03-06 15:06:00 -05:00
Kristof Provost
1be25bdb73 pfctl: remove set but unused variable
In pfctl_show_ifaces() `i` is set, but never used. Remove it.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-06 19:22:35 +01:00
Kajetan Staszkiewicz
9f1beeaed4 pfctl: fix superblock printf format mismatch
It is impossible to compile pfctl with OPT_DEBUG due to integer width mismatch:

	/usr/home/kajetan.staszkiewicz/freebsd.git/sbin/pfctl/pfctl_optimize.c:1479:9: error: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Werror,-Wformat]
					    i - pf_rule_desc[closest].prf_off--- pfctl_optimize.o ---
	^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	/usr/home/kajetan.staszkiewicz/freebsd.git/sbin/pfctl/pfctl_optimize.c:52:44: note: expanded from macro 'DEBUG'
		printf("%s: " str "\n", __FUNCTION__ , ## v)
			      ~~~                         ^
	1 error generated.

Reviewed by:	kp
Obtained from:	OpenBSD (pfctl_optimize.c 1.15)
Differential Revision:	https://reviews.freebsd.org/D38918
2023-03-06 19:22:35 +01:00
Christos Margiolis
cec2d0b1c7 readelf: fix -wR option, memory leaks, and -wf minor bug
Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38419
2023-03-06 12:51:23 -05:00
Mark Johnston
df7bbd8c35 epair: Simplify the transmit path and address lost wakeups
epairs currently shuttle all transmitted packets through a single global
taskqueue thread.  To hand packets over to the taskqueue thread, each
epair maintains a pair of ring buffers and a lockless scheme for
notifying the thread of pending work.  The implementation can lead to
lost wakeups, causing to-be-transmitted packets to end up stuck in the
queue.

Rather than extending the existing scheme, simply replace it with a
linked list protected by a mutex, and use the mutex to synchronize
wakeups of the taskqueue thread.  This appears to give equivalent or
better throughput with >= 16 producer threads and eliminates the lost
wakeups.

Reviewed by:	kp
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D38843
2023-03-06 12:49:28 -05:00
Mark Johnston
48227d1c6d epair: Avoid loading m_flags into a short
The m_flags field of struct mbuf is 24 bits wide and so gets truncated
in a couple of places in the epair code.  Instead of preserving the
entire flag set, just remember whether M_BCAST or M_MCAST is set.

MFC after:	1 week
Sponsored by:	Klara, Inc.
2023-03-06 12:39:11 -05:00
Vincenzo Maffione
506336f2cd netmap: pkt-gen: init all slots of every tx ring
sender_body() uses OPT_COPY to copy the frame into the destination slot
for the first 100,000 packets. Then it removes OPT_COPY to improve
performance. The function always starts with the first tx ring.

If multiple tx rings are in use, it is possible that the initial 100k
packets will only use the first ring. After OPT_COPY is removed, there
may come a time when the first ring is full and sender_body() will move
to the next ring which was never initialized. As a result it will send
all zero packets. (This was discovered when the receiving NIC reported
rx errors.)

Before any transmissions, step through every tx ring and set
NS_BUF_CHANGED on every slot. That will force send_packets() to
initialize the slot when first used. Since it only copies when
necessary, it performs better than always setting OPT_COPY. With this
change, there is no reason for the "drop copy" code.

Submitted by:	Brian Poole <brian90013@gmail.com>
MFC after:	7 days
2023-03-06 17:22:09 +00:00
Justin Hibbits
935b194ded Mechanically convert usb ethernet drivers to DrvAPI
Reviewed by:	zlei
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37812
2023-03-06 11:04:15 -05:00
Justin Hibbits
70510800d1 mlx5: Enter network epoch when using if_foreach()
Summary: IFNET_RLOCK() is not sufficient, the epoch needs entered.

Reviewed by:	hselasky
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38711
2023-03-06 11:04:15 -05:00
Alexander V. Chernikov
6a6f2b0ce9 netstat: fix IPv6 link-locals & custom multipath printing. 2023-03-06 15:08:09 +00:00
Alexander V. Chernikov
e2dc8d789f dhclient: do not add 0.0.0.0 interface alias.
Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D38908
2023-03-06 15:08:09 +00:00
Alexander V. Chernikov
055776c84a netlink: use newly-added if_foreach_sleep() to iterate over the interface list.
Summary: MFC after:	2 weeks

Subscribers: imp, glebius

Differential Revision: https://reviews.freebsd.org/D38907
2023-03-06 15:08:08 +00:00
Alexander V. Chernikov
df2b419a41 ifnet: add if_foreach_sleep() to allow ifnet iterations with sleep.
Subscribers: imp, ae, glebius

Differential Revision: https://reviews.freebsd.org/D38904
2023-03-06 15:08:08 +00:00
Alexander V. Chernikov
66bdbcd544 net: unify mtu update code
Subscribers: imp, ae, glebius

Differential Revision: https://reviews.freebsd.org/D38893
2023-03-06 15:08:08 +00:00
Vitaliy Gusev
062f2818c1
bhyvectl: don't permit using --suspend and --checkpoint at same time
When using the --suspend and --checkpoint parameter, bhyvectl will
produce two checkpoint images and the exits. This is slightly ambiguous.
So, permit only one of theses parameters at the same time.

Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38887
2023-03-06 14:04:26 +01:00
Vitaliy Gusev
9a9a248964
bhyve: init checkput before caph_enter
init_checkpoint_thread binds to a socket. Bhyve isn't allowed to do that
after caph_enter.

Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38857
2023-03-06 14:04:21 +01:00
Vitaliy Gusev
d213429e42
bhyve: exit with EX_OSERR if init checkpoint or restore time failed
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38872
2023-03-06 14:04:16 +01:00
Vitaliy Gusev
577ddca908
bhyve: add cap limits for ipc socket
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38856
2023-03-06 14:04:11 +01:00
Vitaliy Gusev
5c0a031259
bhyve: don't flush readonly device at blockif_pause
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38855
2023-03-06 14:04:07 +01:00
Vitaliy Gusev
755dcd5e49
libvmm: add missing ioctl's to vm_ioctl_cmds
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38866
2023-03-06 14:04:02 +01:00
Vitaliy Gusev
942525ab47
bhyvectl: don't leak nvlist in send_message
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38900
2023-03-06 14:03:58 +01:00
Vitaliy Gusev
b64ba24264
bhyvectl: correct socket_fd closing in send_message
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38889
2023-03-06 14:03:54 +01:00
Vitaliy Gusev
89fe7b98fe
bhyvectl: do not return garbage from send_message
err is used uninitialized in some cases.

Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38886
2023-03-06 14:03:40 +01:00
Peter Holm
ee10c61d7a stress2: Fix a off-by-one error. Added check for argument file type 2023-03-06 10:03:43 +01:00
Andrew Turner
527bf20032 Remove a #error that sneaked in 2023-03-06 08:07:52 +00:00
Baptiste Daroussin
4cd30c640d uuidgen(1): fix another typo 2023-03-06 09:03:52 +01:00
Kirk McKusick
528d8e55c8 FFS/UFS snapshots: improve documentation.
This update provides a more detailed description of FFS/UFS snapshots
and adds links to useful man pages.

Requested by: Graham Perrin
Submitted by: darius-dons.net.au
Reviewed by:  Ravi Pokala
PR:           266358
MFC after:    2 weeks
Differential Revision: https://reviews.freebsd.org/D38817
2023-03-05 21:38:57 -08:00
Kajetan Staszkiewicz
cd9e5d4333 netstat: fix pfsync stats spelling
Reviewed by:	mjg
2023-03-05 22:50:07 +00:00
Andrew Turner
5a91529479 Support non-posted MMIO on arm64 with FDT
To allow hardware to work around a broken memory bus where we need to
support the nonposted-mmio flag.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D34333
2023-03-05 20:17:21 +00:00
Andrew Turner
cb894f746c Map arm64 pci config memory as non-posted
On arm64 PCI config memory is expected to be mapped with a non-posted
device type. To handle this use the new bus_map_resource support in
arm64 to map memory with the new VM_MEMATTR_DEVICE_NP attribute. This
memory has already been allocated and activated, it just needs to be
mapped.

Reviewed by:	kevans, mmel
Differential Revision:	https://reviews.freebsd.org/D30079
2023-03-05 20:17:21 +00:00
Colin Percival
3689f8aeab linux_80211: Don't dequeue lsta if not queued
This fixes an instapanic when restarting wpa_supplicant on my laptop's
iwlwifi device.  After this change, iwlwifi enters a nonfunctional
state if wpa_supplicant is restarted, but "service netif restart wlan0"
is enough to get it working again.

releng/13.2 candidate.

Reviewed by:	bz
MFC after:	3 days
2023-03-05 12:16:22 -08:00
Xin LI
c237c10a23 xz: Improve compatibility with systems without capability mode support
When the kernel is built without capability mode support, or when
using an emulator like qemu-user-static that does not translate
system calls, these calls will return a negative number and set
the errno to ENOSYS. However, this error does not indicate a
real programming or runtime error and is generally ignored by
base system applications built with capability mode sandboxing.

Match this behavior by making xz(1) to ignore ENOSYS errors
when calling capability mode system calls too.

PR:		269185
Reported by:	Dan Kotowski
MFC after:	2 days
2023-03-05 01:40:13 -08:00
Tom Hukins
6d2feb39ad netlink: Fix "version introduced" documentation
netlink(4) and associated features will exist in FreeBSD 14.0 but they
will also exist in 13.2, an older version, from commits such as 02b958b1
and b309249b.

This commit needs merging to stable/13 and releng/13.2.

MFC after: 2days (needs to be in RC2)
Reviewed by: imp,melifaro
Pull Request: https://github.com/freebsd/freebsd-src/pull/651
2023-03-04 09:00:13 -07:00
Kristof Provost
38e2d5db2a netpfil tests: Add functions for testing routing scenarios
Many pf tests use identical setup where one jail is a router and
optionally another jail is a server. Add functions to create such jails
for IPv6 and IPv4 and functions to perform tests on such setup.

Add tests using those functions: scrub actions, routing table, tcp
sequence number modulation.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38126
2023-03-04 14:35:24 +01:00
Kristof Provost
f5b204adf4 ifconfig: remove unused variable
In printgroup() 'cnt' is set, but never read. Remove it.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-04 11:19:12 +01:00
Dmitry Chagin
8243e17463 linux(4): Fixup 5c32488de0 mis-merge 2023-03-04 12:42:04 +03:00
Dmitry Chagin
5c32488de0 linux(4): Add a counterpart to linux_ifflags
For further use in linux_ioctl_socket add bsd_to_linux_ifflags() which
accepts FreeBSD interface flags and translate it to Linux if flags.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D38873
2023-03-04 12:26:48 +03:00
Dmitry Chagin
945a7f0d21 linux(4): Assert that the FreeBSD size of struct sockaddr is equal to Linux
Our code depends on the fact that the size of struct sockaddr and
the size of sa_data is equal between FreeBSD and Linux.
2023-03-04 12:11:39 +03:00
Dmitry Chagin
9883961ed5 linux(4): Drop excess assert that Linux IFNAMSIZ is equal to FreeBSD
While here use _Static_assert() instead of the older CTASSERT().
2023-03-04 12:11:39 +03:00
Dmitry Chagin
d447088d99 linux(4): Improve linux_ifconf readability
Initialize max_len and full variables in a code block where
they are used.
2023-03-04 12:11:39 +03:00
Dmitry Chagin
96a8c6aa37 linux(4): Fixup of the pointer cast when comparing to an integer 2023-03-04 12:11:39 +03:00
Dmitry Chagin
8d6dd96d50 linux(4): Add net epoch assert to the linux_ifhwaddr, linux_ifflags
Now this functions are intended to use in the net epoch.

Reviewed by:		emaste, melifaro
Differential Revision:	https://reviews.freebsd.org/D38795
2023-03-04 12:11:38 +03:00
Dmitry Chagin
f9b0675b01 linux(4): Refactor socket ioctl path to avoid referencing an unstable interfaces
Split the linux_ioctl_socket() function on two counterparts, where
the linux_ioctl_socket_ifreq() intended to use in a code path which
requires the struct ifreq manipulation, i.e., translating in/out
values of the struct, while the linux_ioctl_socket() function is left
as is, it calls sys_ioctl() without touching in/out values.

Due to structures ifreq, sockaddr difference between FreeBSD and Linux
the linux_ioctl_socket_ifreq() calls kern_ioctl() directly, converting
in and out values to FreeBSD and to Linux accordingly.

Finally, modify the ifname_linux_to_bsd() to return error code, not
an unstable reference to the interface.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D38794
2023-03-04 12:11:38 +03:00
Dmitry Chagin
9e7f03e9c6 linux(4): Drop unncessary struct l_ifconf declaration from amd64/linux
Its needed only for amd64/linux32 Linuxulator.

Differential Revision:	https://reviews.freebsd.org/D38793
2023-03-04 12:11:38 +03:00
Dmitry Chagin
a927409ce8 linux(4): Rename struct l_ifreq members names to avoid conflicts with FreeBSD
For now we are using mixed names to access struct ifreq members, some
of Linux (ifr_name, ifr_ifindex), others of FreeBSD. To avoid conflicts
switch to use FreeBSD names.

Reviewed by:		jhibbits
Differential Revision:	https://reviews.freebsd.org/D38792
2023-03-04 12:11:38 +03:00
Dmitry Chagin
cabbfb60d0 linux(4): Reduce code duplication between MD files
Move struct ifnet definitions under compat/linux.

Reviewed by:		emaste
Differential Revision:	https://reviews.freebsd.org/D38791
2023-03-04 12:11:38 +03:00
Dmitry Chagin
5d5b633dde linsysfs(4): Refactor to avoid referencing an unstable interfaces
Enter the net epoch when traversing a list of interfaces. For that
split the ifname_linux_to_bsd() function on two counterparts, where
the ifname_linux_to_ifp() intended to use in epoch, while the
ifname_linux_to_bsd() intended to be a self-contained.
Until the linux_ioctl_coket() function is refactored, the
ifname_linux_to_bsd() temporarily returns interface outside
of the net epoch.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D38790
2023-03-04 12:11:38 +03:00
Dmitry Chagin
130383f2f1 linux(4): Make linux_ifflags return a value
To simplify the use of the function in the printf-like statements.

Differential Revision:	https://reviews.freebsd.org/D38830
2023-03-04 12:11:38 +03:00
Dmitry Chagin
6c5786fd37 linux(4): Migrate to IfAPI
Migrate linux and linprocfs to use the IfAPI interfaces instead of
direct ifnet accesses.
The code initially writed by jhibbits@, and adapted by me to 3ab3c9c2.

Reviewed by:		jhibbits
Differential Revision:  https://reviews.freebsd.org/D38735
2023-03-04 12:11:38 +03:00