Commit graph

1821 commits

Author SHA1 Message Date
Kristof Provost
8921c82b76 carp: don't unintentionally revert to multicast mode
PR:		284140
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit af33f86e6aef6b15c8aa3da615167272aa7a3ee3)
2025-02-11 17:52:42 +01:00
Gleb Smirnoff
e4e6423ef3 tests/sigsys: initialize parameter passed to sysctlbyname()
(cherry picked from commit e53b83a849e3a34772d0a0ed26eb0cb4aeeec71d)
2025-02-10 00:36:24 +08:00
Kristof Provost
491f5e37ae pf: add 'allow-related' to always allow SCTP multihome extra connections
Allow users to choose to allow permitted SCTP connections to set up additional
multihomed connections regardless of the ruleset. That is, allow an already
established connection to set up flows that would otherwise be disallowed.

In case of if-bound connections we initially set the extra associations to
be floating, because we don't know what path they'll be taking when they're
created. Once we see the first traffic we can bind them.

MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D48453

(cherry picked from commit e4f2733df8c9d2fd0c5e8fdc8bec002bf39811f3)
2025-01-30 12:00:31 +01:00
Florian Walpen
e922268736 sound tests: Fix 32bit calculation detection in pcm_read_write
Fix a mistake in the pcm_read_write test that would result in not
properly detecting 32bit calculation on 32bit architectures like i386.
As a consequence, the wrong values would be checked, thus failing the
test.

Reported by:	CI
Fixes:          27ef5d48c729 ("sound: Unit test the pcm sample read and write macros")
MFC after:      1 week
Reviewed by:    christos
Differential Revision:  https://reviews.freebsd.org/D48617

(cherry picked from commit e02b579b537998495b06d02be6aa07f03db3a42a)
2025-01-28 16:04:52 +02:00
Christos Margiolis
afa1ba3b9c sound tests: Fix gcc build
/workspace/src/tests/sys/sound/pcm_read_write.c:36:1: error: 'static' is not
at beginning of declaration [-Werror=old-style-declaration]
   36 | } static const afmt_tests[] = {
      | ^

Reported by:	CI
Fixes:		27ef5d48c729 ("sound: Unit test the pcm sample read and write macros")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week

(cherry picked from commit f6631da0b581b28c2bfeea1199b52013bb46aa41)
2025-01-28 16:04:52 +02:00
Florian Walpen
5edda2488c sound: Unit test the pcm sample read and write macros
Main goal is to have a unit test, with sample test data that is verified
against the current macro implementation of pcm sample read and write
functions. With a test in place, we can proceed on a planned refactoring
of the sample read and write code, and confidently check the new code
for regressions.

Implementation of the unit test itself has to avoid any cast or
conversion affected by endianness, to make the tests compatible with all
machine architectures.

MFC after:	1 week
Reviewed by:    christos, markj
Differential Revision:  https://reviews.freebsd.org/D48330

(cherry picked from commit 27ef5d48c729defb83a8822143dc71ab17f9d68b)
2025-01-28 16:04:52 +02:00
Mark Johnston
49f7412402 inpcb: Further restrict binding to a port owned by a different UID
See commit 4f02a7d739b3 for more background.

I cannot see a good reason to continue ignoring mismatching UIDs when
binding to INADDR_ANY.  Looking at the sdr.V2.4a7n sources (mentioned in
bugzilla PR 7713), there is a CANT_MCAST_BIND hack wherein the
application binds to INADDR_ANY instead of a multicast address, but
CANT_MCAST_BIND isn't defined for FreeBSD builds.

It seems unlikely that we still have a use-case for allowing sockets
from different UIDs to bind to the same port when binding to the
unspecified address.  And, as noted in D47832, applications like sdr
would have been broken by the inverted SO_REUSEPORT check removed in
that revision, apparently without any bug reports.  Let's break
compatibility and simply disallow this case outright.

Also, add some comments, remove a hack in a regression test which tests
this funtionality, and add a new regression test to exercise the
remaining checks that were added in commit 4658dc8325.

MFC after:	1 month
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D47870

(cherry picked from commit c9756953bded0d8428027fa3e812c9bdac069252)
2025-01-23 13:58:07 +00:00
Alan Somers
09df42f1d5 fusefs: Coverity cleanup in the lseek tests
Always check the return value of open().

Reported by:	Coverity Scan
CID:		1471118 1471133 1471215 1471896 1471901 1472116 1473799
CID:		1473879 1473996 1555269 1558044
Sponsored by:	ConnectWise

(cherry picked from commit f415b2ef30f7bf0db753f09fbba7b0910475b0d2)
2025-01-20 09:51:52 -07:00
Alan Somers
8b2b77c32f fusefs: minor cleanup in the tests
Delete some unused includes and member variables.

Sponsored by:	ConnectWise

(cherry picked from commit c2153a533ffb9691848a072c7628dcf56e0e6442)
2025-01-20 09:51:48 -07:00
Alan Somers
60311a5077 fusefs: fix a memory leak
Fix a leak of a fuse_ticket structure.  The leak mostly affected
NFS-exported fuse file systems, and was triggered by a failure during
FUSE_LOOKUP.

Sponsored by:	ConnectWise

(cherry picked from commit 969d1aa4dbfcbccd8de965f7761203208bf04e46)
2025-01-20 09:51:44 -07:00
CismonX
d2c25c4c5e fusefs: ignore FUSE_NO_OPEN(DIR)_SUPPORT flags
The FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT flags
are only meant to indicate kernel features, and should be ignored
if they appear in the FUSE_INIT reply flags.

Also fix the corresponding test cases.

Reviewed by:	Alan Somers <asomers@FreeBSD.org>
Signed-off-by:	CismonX <admin@cismon.net>
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1509

(cherry picked from commit f0f596bd955e5b48c55db502e79fc652ac8970d3)
2025-01-20 09:51:40 -07:00
Alan Somers
fb4e0325c7 fusefs: delete a comment in the tests
Even on a riscv embedded system, the fusefs tests run fast enough that
10 seconds is a reasonable timeout.

[skip ci]

Sponsored by:	ConnectWise

(cherry picked from commit 53f73aaffddaedff019555679d686ec401330d39)
2025-01-20 09:51:35 -07:00
Alan Somers
b034811795 fusefs: More accurately test the unique tokens in the test suite
Every fuse ticket has a "unique" token.  As the name implies, they're
supposed to be unique.  Previously the fusefs test suite verified their
uniqueness by relying on the fact that they are also sequential.  But
they aren't guaranteed to be sequential.  Enhance the tests by removing
that convenient assumption.

Sponsored by:	Axcient

(cherry picked from commit b1879975794772ee51f0b4865753364c7d7626c3)
2025-01-20 09:51:31 -07:00
Alan Somers
23b2704059 Make the CTL tests more resilient
Fix the find_device function to work regardless of whether "camcontrol
devlist" lists the da device first and the pass device second or vice
versa.  On FreeBSD 14 and 15 it apparently always lists da first.  But
on 13 it can do it in either order.

Sponsored by:	ConnectWise
Reviewed by:	emaste, markj, #cam
Differential Revision: https://reviews.freebsd.org/D47446

(cherry picked from commit b032be711c740d2f25b27c92069537edcfac221c)
2025-01-20 09:23:08 -07:00
Kristof Provost
685cafd668 pf: allow ICMP messages related to an SCTP state to pass
Much like we already do for TCP and UDP we should also parse SCTP-in-ICMP
messages to see if they apply to an SCTP connection we've already allowed. If so
we should allow the ICMP packet to pass, even if we'd otherwise block it.

Add a test case where we generate an 'ICMP unreachable - need to frag' packet
and check that it passes through pf.

MFC after:	2 weeks
Sponsored by:	Orange Business Services

(cherry picked from commit 7d5e02b01577047290e937399accc02e6b184ce9)
2025-01-18 22:10:22 +01:00
Leonid Evdokimov
3870483ec4 pf tests: check cleared time when zeroing stats for table addresses
Verify that we reset the cleared time when we zero an address' counters in
a table.

PR:		282877, 282984
Reviewed by:	kp
MFC after:	2 weeks
Signed-off-by:	Leonid Evdokimov <leon@darkk.net.ru>
Differential Revision:	https://reviews.freebsd.org/D48242

(cherry picked from commit 0749d8134300b8e3c956e161890ab496247d2542)
2025-01-16 16:20:34 +01:00
Mark Johnston
872da05f8c SO_SPLICE tests: Fix a comment typo
MFC after:	1 week
Sponsored by:	Klara, Inc.

(cherry picked from commit 9743e9efdf5f0d2338d7cfeed8f09d89d889bac4)
2025-01-14 14:14:24 +00:00
Mark Johnston
cbf77cecec inpcb: Remove bogus SO_REUSEPORT(_LB) checks in in_pcbbind()
This check for SO_REUSEPORT was added way back in commit 52b65dbe85.
Per the commit log, this commit restricted this port-stealing check to
unicast addresses, and then only if the existing socket does not have
SO_REUSEPORT set.  In other words, if there exists a socket bound to
INADDR_ANY, and we bind a socket to INADDR_ANY with the same port, then
the two sockets need not be owned by the same user if the existing
socket has SO_REUSEPORT set.

This is a surprising semantic; bugzilla PR 7713 gives some additional
context.  That PR makes a case for the behaviour described above when
binding to a multicast address.  But, the SO_REUSEPORT check is only
applied when binding to a non-multicast address, so it doesn't really
make sense.  In the PR the committer notes that "unicast applications
don't set SO_REUSEPORT", which makes some sense, but also refers to
"multicast applications that bind to INADDR_ANY", which sounds a bit
suspicious.

OpenBSD performs the multicast check, but not the SO_REUSEPORT check.
DragonflyBSD removed the SO_REUSEPORT (and INADDR_ANY) checks back in
2014 (commit 0323d5fde12a4).  NetBSD explicitly copied our logic and
still has it.

The plot thickens: 20 years later, SO_REUSEPORT_LB was ported from
DragonflyBSD: this option provides similar semantics to SO_REUSEPORT,
but for unicast addresses it causes incoming connections/datagrams to be
distributed among all sockets in the group.  This commit (1a43cff92a)
inverted the check for SO_REUSEPORT while adding one for
SO_REUSEPORT_LB; this appears to have been inadvertent.  However:
- apparently no one has noticed that the semantics were changed;
- sockets belonging to different users can now be bound to the same port
  so long as they belong to a single lbgroup bound to INADDR_ANY, which
  is not correct.

Simply remove the SO_REUSEPORT(_LB) checks, as their original
justification was dubious and their current implementation is wrong; add
some tests.

Reviewed by:	glebius
MFC after:	1 month
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D47832

(cherry picked from commit 4f02a7d739b354eef38e19b25866f64842d69414)
2025-01-14 14:14:24 +00:00
Konstantin Belousov
1b2bf32658 path_test: adjust test for open(O_PATH | O_CREAT)
(cherry picked from commit 749b3b2c0629f44f6b0044992dfb2ce5ac7e562b)
2025-01-14 10:56:41 +02:00
Kristof Provost
13ea23ee6e pf: fix potential NULL dereference in SCTP multihome handling
When processing an SCTP ASCONF we re-run the rules processing to check
if the new state should be allowed as well. We used to do so against the
'all' interface, to allow new connections to use any interface.

This is problematic for two reasons, the first being it may unexpectedly
bypass interface restrictions. The more important one is that it
can trigger panics. If the ruleset contains a rule which filters on
interface group we'd attempt to process the group list for the 'all'
interface. As this isn't a real interface it doesn't have an associated
struct ifnet, and we end up dereferencing a NULL pointer.

Solve this by not overriding the interface, instead leaving the physical
interface the SCTP ASCONF arrived on. This implies that we may end up
binding to that interface (if if-bound), and thus denying traffic on
other interfaces. Users can allow this anyway by setting 'state-policy
floating' on the relevant SCTP rules. This arguably better reflects user
intent as well. That is, we'll consider SCTP multihomed states to be
floating if we're in floating mode, and if-bound if we're if-bound.

Update the test cases to account for this, while adding a "pass on
lo" (i.e. pass on an interface group") rule to provoke this issue. Add
separate test cases for the floating and if-bound scenarios.

Reported by:	Franco Fichtner <franco@opnsense.org>
MFC after:	3 weeks
Sponsored by:	Orange Business Services

(cherry picked from commit c22c9879845653abb365e468daaa621e3f8f767a)
2024-12-24 11:18:58 +01:00
Leonid Evdokimov
30b9d8a737 pfctl: add -T reset to touch pfras_tzero only for non-zero entries
This will make it easier for scripts to detect idle hosts in tables.

PR:		282984
Reviewed by:	kp
MFC after:	2 weeks

(cherry picked from commit 5b59b0c61e29f684a019afdd2848ffe2d5604e0c)
2024-12-24 11:16:53 +01:00
Kristof Provost
ac92792bbd pfctl: clear statistic for specified addresses
The ioctl DIOCRCLRASTATS provides the functionality of clearing stats
not only for the whole table for for addresses stored in that table. The
functionality was missing from pfctl, though. Add it now.

PR:		282877
Obtained from:	OpenBSD, kirill <kirill@openbsd.org>, e496dff3a7
MFC after:	3 weeks

(cherry picked from commit 6463b6b59152fb1695bbe0de78f6e2675c5a765a)
2024-12-14 11:03:27 +01:00
Mark Johnston
da44138dc2 unix: Add support for atomically setting the socket mode
With this patch, it is possible to call fchmod() on a unix socket prior
to binding it to the filesystem namespace, so that the mode is set
atomically.  Without this, one has to call chmod() after bind(), leaving
a window where threads can connect to the socket with the default mode.
After bind(), fchmod() reverts to failing with EINVAL.

This interface is copied from Linux.

The behaviour of fstat() is unmodified, i.e., it continues to return the
mode as set by soo_stat().

PR:		282393
Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D47361

(cherry picked from commit bfd03046d18776ea70785ca1ef36dfc60822de3b)
2024-12-03 01:03:26 +00:00
Mark Johnston
9917a1357c fibs_test: Run in a jail
These tests assume exclusive use of one or more FIBs and so can't be run
in parallel.  Running them in a VNET jail sidesteps this problem.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield

(cherry picked from commit a079f2b52aae74b5469f18dcbef1aff680b80282)
2024-11-28 14:38:17 +00:00
Mark Johnston
08d0ebe560 pf: Let rdr rules modify the src port if doing so would avoid a conflict
If NAT rules cause inbound connections to different external IPs to be
mapped to the same internal IP, and some application uses the same
source port for multiple such connections, rdr translation may result in
conflicts that cause some of the connections to be dropped.

Address this by letting rdr rules detect state conflicts and modulate
the source port to avoid them.

Reviewed by:	kp, allanjude
MFC after:	3 months
Sponsored by:	Klara, Inc.
Sponsored by:	Modirum
Differential Revision:	https://reviews.freebsd.org/D44488

(cherry picked from commit 9897a66923a3e79c22fcbd4bc80afae9eb9f277c)
2024-11-20 21:41:09 +00:00
Tom Jones
f5b3ce0d75 pf: Correct SPDX identifier
Pointed out by: Mike Karels <karels@FreeBSD.org>

(cherry picked from commit 3db693f7da8a1aaf0a8887e7791ebb5d67c7a2d9)
2024-11-20 21:41:09 +00:00
Tom Jones
30d4069253 pf: Add a TCP rdr test on IPv6
Reviewed by:    kp
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision: https://reviews.freebsd.org/D42105

(cherry picked from commit b9870ba93ea90a12f5a5727c80f7958b17f9afcc)
2024-11-20 21:41:08 +00:00
Mark Johnston
8635c1ad51 shm: Respect PROT_MAX when creating private mappings
We were previously unconditionally adding PROT_WRITE to the maxprot of
private mapping (because a private mapping can be written even if the
fd is read-only), but this might violate the user's PROT_MAX request.

While here, rename cap_maxprot to max_maxprot.  This is the intersection
of the maximum protections imposed by capsicum rights on the fd (not
really relevant for private mappings) and the user-required maximum
protections (which were not being obeyed).  In particular, cap_maxprot
is a misnomer after the introduction of PROT_MAX.

Add some regression test cases.  mmap__maxprot_shm fails without this
patch.

Note: Capsicum's CAP_MMAP_W is a bit ambiguous.  Should it be required
in order to create writeable private mappings?  Currently it is, even
though such mappings don't permit writes to the object referenced by the
fd.

Reported by:	brooks
Reviewed by:	brooks
MFC after:	1 month
Fixes:		c7841c6b8e ("Relax restrictions on private mappings of POSIX shm objects.")
Differential Revision:	https://reviews.freebsd.org/D46741

(cherry picked from commit 33c2c58f0a3db0a6d3996fa14ac7967274678771)
2024-11-04 15:38:35 +00:00
Alan Somers
d3459fe7f7 zfsd: replace vdevs with the AUX faulted state
Without this patch, vdevs faulted via AUX state would not be replaced
once the appropriate drive is replaced.  ZFS does not internally use
that state, but a drive can be manually forced into such a state with a
command like zinject.

Submitted by:	Goran Mekić <meka@tilda.center>
Sponsored by:	ConnectWise
Differential Revision: https://reviews.freebsd.org/D46866

(cherry picked from commit 618ae939b7f95a197a0518cbb390a572bb90c6d0)
2024-10-31 08:00:32 -06:00
Kristof Provost
df88800a03 pf tests: disable epsv for the ftp proxy test
The update to py-twisted 24.7.0 broke EPSV mode in twisted's ftp server.
Work around this by disabling EPSV (and thus using PASV).

PR:		282154
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 9cd6ab45a44607ea862c8bbb2ebaa8a7521178ff)
2024-10-21 14:51:36 +02:00
Kristof Provost
f3586d2693 netpfil tests: skip checksum verification in pft_ping.py
From scapy 2.6.0 it now removes (sets to None) the IP checksum in its defrag
code. We typically ask for IPv4 or IPv6 defragmentation, which causes check
function failures.

Just skip the checksum verificiation here, because we're going to notice
incorrect checksums even if the tests don't directly verify it.

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

(cherry picked from commit 6b8096fa5f6f81e2959cbb2ca857c4e134273da2)
2024-10-21 14:51:36 +02:00
Mark Johnston
794fd74ab8 tests: Add some test cases for SO_SPLICE
Reviewed by:	gallatin
MFC after:	3 months
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D46412

(cherry picked from commit 877cf210c08b99aa532107e176b372de58579493)
2024-10-17 15:48:37 +00:00
Mark Johnston
9e6ff43535 netinet tests: Make some tests more reliable when run in parallel
Many of the modified tests add epair interfaces to the host, though most
of the tests themselves run in a VNET jail.  scapy in particular becomes
unhappy when the list of interfaces changes as it is running, so, to
improve reliability of parallel test runs, isolate tests which add
epairs to the host.

Also serialize arp tests, as they examine the dmesg as part of the test.

The list of modified tests is not exhaustive, it was determined by
running the test suite with parallelization enabled and looking at
failures.  It may be easier to just automatically enable VNET jailing of
all netinet tests, but let's be more particular for now.

Reviewed by:	kp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D46606

(cherry picked from commit b103fc49ae160fdce221c2fffa98dde9bc0ff3b0)

Approved by:    kp (mentor), markj (mentor)
2024-10-17 13:45:45 +00:00
Kristof Provost
0e2a3e1da9 if_ovpn tests: allow these tests to run in parallel
Now that kyua can isolate tests in their own vnets we can run these tests in
parallel.

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

(cherry picked from commit a05decec2d194821f8bf5c8f2ae72063de0c87a8)

Approved by:    kp (mentor), markj (mentor)
2024-10-17 13:45:35 +00:00
Kristof Provost
c5fc967cf1 netpfil tests: run in parallel
Run these tests in their own (vnet) jail so we don't have to worry about IP
range or jail name conflicts.

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

(cherry picked from commit 4f752a1583dc97d166caae7f844bf42715e99978)

Approved by:    kp (mentor), markj (mentor)
2024-10-17 13:45:29 +00:00
Mark Johnston
81da8e39f7 geli tests: Work around a missing MFC
The test assumes commit 96950419f15510287080c557174e0d8409f06956, but
that was never MFCed to stable branches, resulting in a broken test.

This is a direct commit to stable/14.
2024-10-15 13:35:59 +00:00
Kristof Provost
ff5a685270 if_vlan: handle VID conflicts
If we fail to change the vlan id we have to undo the removal (and vlan id
change) in the error path. Otherwise we'll have removed the vlan object from the
hash table, and have the wrong vlan id as well. Subsequent modification attempts
will then try to remove an entry which doesn't exist, and panic.

Undo the vlan id modification if the insertion in the hash table fails, and
re-insert it under the original vlan id.

PR:		279195
Reviewed by:	zlei
MFC atfer:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D45285

(cherry picked from commit bdd12889eaa64032b3d09ef47e9a6f7081863378)
2024-10-11 12:04:09 +02:00
Alan Somers
cf2ed0edae fusefs: fix an uninitialized memory access in fuse_vnop_deallocate
If the FUSE_GETATTR issued to query a file's size during
fuse_vnop_deallocate failed for any reason, then fuse_vnop_deallocate
would attempt to destroy an uninitialized fuse_dispatcher struct, with a
crash the likely result.  This bug only affects FUSE file systems that
implement FUSE_FALLOCATE, and is unlikely to be seen on those that don't
disable attribute caching.

Reported by:	Coverity Scan
CID:		1505308

(cherry picked from commit f93a50d69df2e996ff1d4f793d0dcb9de655ebdc)
2024-10-10 12:48:39 -06:00
Mark Johnston
20191b71ba src.conf: Add a MK_ZFS_TESTS knob
The in-tree ZFS test suite is somewhat outdated and I see a number of
failures there.  I tend to think that we want to integrate the OpenZFS
test suite somehow, replacing the legacy one, though it's also possible
to run that as a separate test suite.

In any case, if one wants to run the OpenZFS test suite separately, it's
useful to be able to disable installation of the legacy ZFS test suite,
so let's provide a src.conf option to do that.

Reviewed by:	asomers
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D46476

(cherry picked from commit 24affded3d4ec5fafb6b22f773ec1e20d73b9b03)
2024-09-20 11:39:16 +00:00
Mark Johnston
6f636541a3 capsicum tests: Serialize functional tests
The test suite runs the same tests twice, as different users, and these
can trample over each other when run in parallel, causing spurious test
failures.

MFC after:	1 week

(cherry picked from commit 41ece3c036bda3d4da321989ee59d0555c10d603)
2024-09-20 11:39:16 +00:00
Mark Johnston
246f922d63 ggate tests: Use unique ports among tests
This helps avoid failures when running tests in parallel.

MFC after:	1 week

(cherry picked from commit b5d3f8252fe8b74249ed49e87981d190c3ec3d05)
2024-09-20 11:39:16 +00:00
Alan Somers
4bb8e26c26 fusefs: fix two bugs regarding _PC_MIN_HOLE_SIZE
Background:

If a user does pathconf(_, _PC_MIN_HOLE_SIZE) on a fusefs file system,
the kernel must actually issue a FUSE_LSEEK operation in order to
determine whether the server supports it.  We cache that result, so we
only have to send FUSE_LSEEK the first time that _PC_MIN_HOLE_SIZE is
requested on any given mountpoint.

Problem 1:

Unlike fpathconf, pathconf operates on files that may not be open.  But
FUSE_LSEEK requires the file to be open.  As described in PR 278135,
FUSE_LSEEK cannot be sent for unopened files, causing _PC_MIN_HOLE_size
to wrongly report EINVAL.  We never noticed that before because the
fusefs test suite only uses fpathconf, not pathconf.  Fix this bug by
opening the file if necessary.

Problem 2:

On a completely sparse file, with no data blocks at all, FUSE_LSEEK with
SEEK_DATA would fail to ENXIO.  That's correct behavior, but
fuse_vnop_pathconf wrongly interpreted that as "FUSE_LSEEK not
supported".  Fix the interpretation.

PR:		278135
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D44618

(cherry picked from commit 6efba04df3f8c77b9b12f1df3e5124a7249b82fc)
2024-09-19 14:27:41 -06:00
Alan Somers
e2217f8097 ctl: add tests for PREVENT ALLOW MEDIUM REMOVAL
Sponsored by:	Axcient
Reviewed by:    emaste, markj
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1409

(cherry picked from commit e234a72bb8c0e8e25ea8a879582e85bb2e09f096)
2024-09-19 14:24:02 -06:00
Alan Somers
37357ba28a ctl: add tests for START STOP UNIT
Sponsored by:	Axcient
Reviewed by:	emaste, markj
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1409

(cherry picked from commit fe1755fa6bb4039c1e00f5226c473a024685005b)
2024-09-19 14:23:59 -06:00
Alan Somers
e9329a869c ctl: add some ATF tests for READ BUFFER
Reviewed by:	Pierre Pronchery <pierre@freebsdfoundation.org>
Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	Axcient

(cherry picked from commit 60d717baf2144cf344ec9b47d715ce837b5d46d4)
2024-09-04 15:00:20 +00:00
Kristof Provost
4909bd69dd pf tests: ensure that neighbour discovery works as expected
Also check repeated calls.

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

(cherry picked from commit d154dc21130b607d7903f276dd6d463b990f33f7)
2024-09-04 10:38:15 +02:00
Kristof Provost
485bd16308 pf: cope with SCTP port re-use
Some SCTP implementations will abort connections and then later re-use the same
port numbers (i.e. both src and dst) for a new connection, before pf has fully
purged the old connection.

Apply the same hack we already have for similarly misbehaving TCP
implementations and forcibly remove the old state so we can create a new one.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 82e021443a76b1f210cfb929a495185179606868)
2024-08-27 10:09:10 +02:00
Christos Margiolis
6ab8b418dc sound tests: Add SNDSTIOC_ADD_USER_DEVS test
Test whether the SNDSTIOC_ADD_USER_DEVS IOCTL (registers a userland
device to /dev/sndstat) works properly.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D46228

(cherry picked from commit 2668e76d6e764c5c361156ffa3d39eb02ce8e5d9)
2024-08-26 16:52:02 +03:00
Kristof Provost
09d61b28a0 vnet tests: verify that we can load if_epair and if_bridge
We're going to start running many of the vnet tests in nested jails (so they
can run in parallel). That means the tests won't be able to load kernel modules,
which we commonly do for if_epair and if_bridge.

Just assume that all vnet tests need this, because so many of them do that we
don't want to manually annotate all of them.
This is essentially a no-op on non-nested tests.

Do the same for the python test framework.

While here also have pflog_init actually call pft_init. While having pflog
loaded implies we have pf too pft_init also checks for vimage support, and now
for if_epair.

Reviewed by:	markj
MFC after:	1 month
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46039

(cherry picked from commit ae8d58814089308028046ac80aeeb9cbb784bd0a)
2024-08-22 21:01:33 +02:00
Kristof Provost
145f5005ae pf tests: ensure temporary files end up in the atf working directory
Many of the tests create temporary files. pid files, log files, tcpdump
captures, ... We should take care to ensure they're stored in the temporary
working directory Kyua creates rather than in the root directory.

This ensures there are no conflicts between simultaneously running tests, and
also keeps the root directory clean.

MFC after:	1 month
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit b0fcf4d5222bfdbbc0e2af2b14f0d73704706aa0)
2024-08-22 21:01:33 +02:00