Commit graph

1786 commits

Author SHA1 Message Date
Alan Somers 6b1c534927 Add a regression test for PR 276191.
The bug isn't fusefs-specific, but this is the easiest way to reproduce
it.

PR:		276191
MFC after:	1 week
MFC with:	bdb46c21a3
Differential Revision:  https://reviews.freebsd.org/D43446
Reviewed by: 	kib
2024-01-13 15:47:16 -07:00
Gleb Smirnoff e007b89e9d tests: add a test for shutdown(2) on a datagram socket 2024-01-12 02:04:04 -08:00
Gleb Smirnoff 26caf57e0b tests/netlink: improve recently added netlink_socket:membership
Change sequence of syscalls: instead of "add, delete, check, check"
run sequence "add, check, delete, check".  Seems to make more sense.

Do minimal parsing of incoming messages: find the IPv4 address there
and compare it to the original.
2024-01-10 20:51:53 -08:00
Gleb Smirnoff effa0f6c0a tests/netlink: mark a test that requires tun(4) 2024-01-10 20:51:53 -08:00
Gleb Smirnoff 6ee181b9d5 tests/net: enable if_clone_test:epair_ipv6_up_stress
The panic mentioned was fixed in f5a365e51f.

PR:	225438
2024-01-10 20:51:53 -08:00
Gleb Smirnoff 8338ea1d3c tests/netlink: add minimal test for a group writer
Subscribe a socket for RTNLGRP_IPV4_ROUTE announcements, add & delete
a route and check that announcements came in.
2024-01-09 16:56:51 -08:00
Brooks Davis 8e2c2992da socket_msg_trunc: allocate a large enough buffer
Allocate 9000 bytes to match the largest requsted size.  Add a check to
prevent the list of sizes and buffer size from getting out of sync
again.

Reviewed by:	markj
Found with:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D43340
2024-01-09 22:59:29 +00:00
Kristof Provost 32df0124f4 pf tests: ensure that pflog shows malformed packets as blocked, not passed
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-04 23:08:08 +01:00
Brooks Davis a9174861ea posixshm largepage_mmap: fix a racy test
You can't ever safely map a single page and then map a superpage sized
mapping over it with MAP_FIXED.  Even in a single-threaded program, ASLR
might mean you land too close to another mapping and on CheriBSD we
don't allow the initial reservation to grow because doing so requires
program changes that are hard to automate.

To avoid this, map the entire region we want to use upfront.

Reviewed by:	markj
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43282
2024-01-03 16:39:53 +00:00
Gleb Smirnoff 17083b94a9 netlink: use protocol specific receive buffer
Implement Netlink socket receive buffer as a simple TAILQ of nl_buf's,
same part of struct sockbuf that is used for send buffer already.
This shaves a lot of code and a lot of extra processing.  The pcb rids
of the I/O queues as the socket buffer is exactly the queue.  The
message writer is simplified a lot, as we now always deal with linear
buf.  Notion of different buffer types goes away as way as different
kinds of writers.  The only things remaining are: a socket writer and
a group writer.
The impact on the network stack is that we no longer use mbufs, so
a workaround from d187154750 disappears.

Note on message throttling.  Now the taskqueue throttling mechanism
needs to look at both socket buffers protected by their respective
locks and on flags in the pcb that are protected by the pcb lock.
There is definitely some room for optimization, but this changes tries
to preserve as much as possible.

Note on new nl_soreceive().  It emulates soreceive_generic().  It
must undergo further optimization, see large comment put in there.

Note on tests/sys/netlink/test_netlink_message_writer.py. This test
boiled down almost to nothing with mbufs removed.  However, I left
it with minimal functionality (it basically checks that allocating N
bytes we get N bytes) as it is one of not so many examples of ktest
framework that allows to test KPIs with python.

Note on Linux support. It got much simplier: Netlink message writer
loses notion of Linux support lifetime, it is same regardless of
process ABI.  On socket write from Linux process we perform
conversion immediately in nl_receive_message() and on an output
conversion to Linux happens in in nl_send_one(). XXX: both
conversions use M_NOWAIT allocation, which used to be the case
before this change, too.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D42524
2024-01-02 13:04:01 -08:00
Gleb Smirnoff 0ad011ecec tests/netlink: add netlink socket buffer test
With upcoming protocol specific socket buffer for Netlink we need some
additional tests that cover basic socket operations, w/o much of actual
Netlink knowledge.  Following tests are performed:

1) Overflow.  If an application keeps sending messages to the kernel,
but doesn't read out the replies, then first the receive buffer shall
fill and after that further messages from applications will be queued
on the send buffer until it is filled.  After that socket operations
should block.  However, reading from the receive buffer some data should
wake up the taskqueue and the send buffer should start draining again.

2) Peek & trunc.  Check that socket correctly reports amount of readable
data with MSG_PEEK & MSG_TRUNC.  This is typical pattern of Netlink apps.

3) Sizes. Check that zero size read doesn't affect the socket, undersize
read will return one truncated message and the message is removed from
the buffer.  Check that large buffer will be filled in one read, without
any boundaries imposed by internal representation of the buffer.  Check
that any meaningful read is amended with control data if requested so.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D42525
2024-01-02 13:03:49 -08:00
Mark Johnston 8b57b2a98b frag6 tests: Serialize
I'm not sure exactly why, but these tests consistently fail when run in
parallel.  Serialize them for now.

MFC after:	1 week
2023-12-31 11:22:45 -05:00
Vincenzo Maffione ee5804da11 netmap: fix unit tests
After ad874544d9, interface name
validation has been removed, resulting in two unit tests failures.
Drop the failing tests since they no longer apply.

Reported by:	markj
2023-12-29 07:46:46 +00:00
Dimitry Andric dc0b4094ab Silence VLA extension warnings in fusefs tests
Building tests/sys/fs/fusefs with clang 18 results the following
warning:

  tests/sys/fs/fusefs/cache.cc:145:14: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
    145 |         uint8_t buf[bufsize];
        |                     ^~~~~~~

Because we do not particularly care that this is a clang extension,
suppress the warning.

MFC after:	3 days
2023-12-21 23:45:52 +01:00
Michael Gmelin 3d36053ca6 libifconfig: Fix bridge status member list
When this functionality was moved to libifconfig in 3dfbda3401,
the end of list calculation was modified for unknown reasons, practically
limiting the number of bridge member returned to (about) 102.

This patch changes the calculation back to what it was originally and
adds a unit test to verify it works as expected.

Reported by:	Patrick M. Hausen (via ML)
Reviewed by:	kp
Approved by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43135
2023-12-21 16:50:27 +01:00
Kristof Provost c2e0b604a3 netinet tests: test that we send IGMP join/leave packets as expected
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-12-19 17:47:41 +01:00
Richard Scheffenegger 31cf66d755 dummynet: add simple gilbert-elliott channel model
Have a simple Gilbert-Elliott channel model in
dummynet to mimick correlated loss behavior of
realistic environments. This allows simpler testing
of burst-loss environments.

Reviewed By:           tuexen, kp, pauamma_gundo.com, #manpages
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D42980
2023-12-17 13:20:45 +01:00
Kristof Provost 8fab83d2c5 pf tests: fix typos in the abort_v6 test case head / cleanup function name
MFC after:	1 week
2023-12-14 10:23:41 +01:00
Kristof Provost 4c84c69ba3 pf tests: test that we validate sequence numbers on TCP RST
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-12-05 21:03:49 +01:00
Jose Luis Duran 5b36076d28 zfs tests: Silence clang warning
"assigning to 'pattern_t *' from 'const pattern_t *' discards qualifiers"

Reviewed by:	asomers
Reported by:	clang
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42791
2023-12-04 12:22:14 -05:00
Gleb Smirnoff cfb1e92912 sockets: don't malloc/free sockaddr memory on accept(2)
Let the accept functions provide stack memory for protocols to fill it in.
Generic code should provide sockaddr_storage, specialized code may provide
smaller structure.

While rewriting accept(2) make 'addrlen' a true in/out parameter, reporting
required length in case if provided length was insufficient.  Our manual
page accept(2) and POSIX don't explicitly require that, but one can read
the text as they do.  Linux also does that. Update tests accordingly.

Reviewed by:		rscheff, tuexen, zlei, dchagin
Differential Revision:	https://reviews.freebsd.org/D42635
2023-11-30 08:30:55 -08:00
Alan Somers d565784a7e zfsd: fault disks that generate too many I/O delay events
If ZFS reports that a disk had at least 8 I/O operations over 60s that
were each delayed by at least 30s (implying a queue depth > 4 or I/O
aggregation, obviously), fault that disk.  Disks that respond this
slowly can degrade the entire system's performance.

MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	delphij
Differential Revision: https://reviews.freebsd.org/D42825
2023-11-29 07:51:11 -07:00
Jose Luis Duran 1db64f8936
netlink: Add tests when adding an interface route
Add tests for adding a route using an interface only (without an IP
address).

Reviewed by:	rcm
Approved by:	kp (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41436
2023-11-28 16:53:00 -05:00
Gleb Smirnoff d2de66a90d ng_socket: with getsockname() return node ID for unnamed node
Reviewed by:		afedorov
Differential Revision:	https://reviews.freebsd.org/D42691
2023-11-27 20:11:38 -08:00
Gleb Smirnoff 4064a1108b netgraph: increase size of sockaddr_ng to match maximum node name
The ng_socket(4) node already writes more than declared size of the
struct at least in the in ng_getsockaddr().  Make size match size of
a node name.  The value is pasted instead of including ng_message.h
into ng_socket.h.  This is external API and we want to keep it stable
even if NG_NODESIZ is redefined in a kernel build.

Reviewed by:		afedorov
Differential Revision:	https://reviews.freebsd.org/D42690
2023-11-27 20:10:52 -08:00
Warner Losh 8b923102f9 Revert "cdefs: Remove __func__ define"
This reverts commit 17a238a15f. There were
too many other changes accidentally mixed in.

Sponsored by:		Netflix
2023-11-27 14:59:54 -07:00
Gleb Smirnoff 96950419f1 tests: don't run atf_* in a subshell
Shell limitation is that a classic function call via $() is a subshell
and atf-sh(3) commands won't work as epxected there.  Subsequently,
atf_skip inside a function won't skip a test.  The test will fail later.

A working approach is to pass desired variable name as argument to
a function and don't run subshell.

Reviewed by:		ngie
Differential Revision:	https://reviews.freebsd.org/D42646
Fixes:			ea82362219
2023-11-27 13:15:59 -08:00
Kristof Provost 1d723c1e56 pf tests: test recursive printing of labels
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-11-27 21:37:33 +01:00
Warner Losh 17a238a15f cdefs: Remove __func__ define
We require an ANSI-C compiler to build the base system. It's required
that __func__ work. Remove this define since the only known problem
compilers are ancient history (gcc 2.6 from 1994, almost pre-dating the
project). 3rd party code that used this define will now need to provide
it via some other means when using non-ansi-c compilers.

PR: 275221 (exp-run)
Sponsored by:		Netflix
2023-11-26 22:24:02 -07:00
Warner Losh b88ca6ee16 cdefs: Remove CC_SUPPORTS macros, they are unused
Remove __CC_SUPPORTS_INLINE, __CC_SUPPORTS___INLINE__,
__CC_SUPPORTS___FUNC__, __CC_SUPPORTS_WARNING,
__CC_SUPPORTS_VARADIC_XXX, __CC_SUPPORTS_DYNAMIC_ARRAY_INIT: they are
unused. Also remove them from the generated cryptodevh.py script.

Retain, for the moment, __CC_SUPPORTS___INLINE, since it's used in this
file.

PR: 275221 (exp-run)
Sponsored by:		Netflix
2023-11-26 22:24:02 -07:00
Warner Losh a83d4fe9cb cdefs: Remove some builtin defines, they are unused
Remove __GNUCLIKE_BUILTIN_NEXT_ARG, __GNUCLIKE_MATH_BUILTIN_RELOPS,
__GNUCLIKE_BUILTIN_MEMCPY: they are unused. Also remove them from the
generated cryptodevh.py script.

PR: 275221 (exp-run)
Sponsored by:		Netflix
2023-11-26 22:24:02 -07:00
Warner Losh 9e55552208 cdefs: Remove vararg related defines, they are unused.
Remove __GNUCLIKE_BUILTIN_VARARGS, __GNUCLIKE_BUILTIN_STDARG,
__GNUCLIKE_BUILTIN_VAALIST, __GNUC_VA_LIST_COMPATIBILITY: they are
unused. Also remove them from the generated cryptodevh.py script.

PR: 275221 (exp-run)
Sponsored by:		Netflix
2023-11-26 22:24:02 -07:00
Warner Losh eaaa7ca0c3 cdefs: Remove __GNUCLIKE_BUILTIN_CONSTANT_P, it's unused
__GNUCLIKE_BUILTIN_CONSTANT_P is unused, remove it. Also remove it from
the generated cryptodevh.py script.

PR: 275221 (exp-run)
Sponsored by:		Netflix
2023-11-26 22:24:02 -07:00
Warner Losh d2ec42ca57 cdefs: Remove __GNUCLIKE_CTOR_SECTION_HANDLING, it's unused
__GNUCLIKE_CTOR_SECTION_HANDLING is unused, remove it. Also remove it
from the generated cryptodevh.py script.

PR: 275221 (exp-run)
Sponsored by:		Netflix
2023-11-26 22:24:02 -07:00
Warner Losh 45aa39f884 cdefs: Remove __GNUCLIKE___SECTION, it's unused.
__GNUCLIKE___SECTION is unused, remove it. Also remove it from the
generated cryptodevh.py script.

PR: 275221 (exp-run)
Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
Warner Losh 6dced2c635 tests: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
Warner Losh ac00d4d59b tests: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:30 -07:00
Dag-Erling Smørgrav c56f45f2a9 bitstring: Support large bit strings.
Replace int with either size_t or ssize_t (depending on context) in
order to support bit strings up to SSIZE_MAX bits in length.  Since
some of the arguments that need to change type are pointers, we must
resort to light preprocessor trickery to avoid breaking existing code.

MFC after:	3 weeks
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D42698
2023-11-22 23:30:03 +01:00
Gleb Smirnoff 367e8adb4b tests/netgraph: start ng_socket test suite
Just one check now, check node name.
2023-11-20 14:36:58 -08:00
Igor Ostapenko b453e3f755 pf tests: fix name and description of divert-to cases
Reflect the correct order of events for dummynet+ipdivert.
2023-11-20 12:30:18 +01:00
Warner Losh cc02e98a95 cdefs: Remove __GNUCLIKE_ASM
It's no longer used in the tree.

Exp Run PR:		275123
Sponsored by:		Netflix
2023-11-19 19:36:46 -07:00
Warner Losh 7b7975e032 cdefs: Remove __GNUCLIKE___TYPEOF from cdefs.h
It's been unused for quite some time, so remove it from sys/cdefs.h.

Exp Run PR:		275123
Sponsored by:		Netflix
2023-11-19 19:35:53 -07:00
Kristof Provost 0fe663b2a8 pf: always create multihomed states as floating
When we create a new state for multihomed sctp connections (i.e.
based on INIT/INIT_ACK or ASCONF parameters) we cannot know what
interfaces we'll be seeing that traffic on. Make those states floating,
irrespective of state policy.

MFC after:	1 week
Sponsored by:	Orange Business Services
2023-11-17 23:33:43 +01:00
Igor Ostapenko fe3bb40b9e pf: fix dummynet + ipdivert use case
Dummynet re-injects an mbuf with MTAG_IPFW_RULE added, and the same mtag
is used by divert(4) as parameters for packet diversion.

If according to pf rule set a packet should go through dummynet first
and through ipdivert after then mentioned mtag must be removed after
dummynet not to make ipdivert think that this is its input parameters.

At the very beginning ipfw consumes this mtag what means the same
behavior with tag clearing after dummynet.

And after fabf705f4b pf passes parameters to ipdivert using its
personal MTAG_PF_DIVERT mtag.

PR:		274850
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D42609
2023-11-17 17:06:16 +01:00
Mark Johnston b08a9b86f5 ktls tests: Relax error checking for shutdown(2) a bit
In my test suite runs I occasionally see shutdown(2) fail with
ECONNRESET rather than ENOTCONN.  soshutdown(2) will return ENOTCONN if
the socket has been disconnected (synchronized by the socket lock), and
tcp_usr_shutdown() will return ECONNRESET if the inpcb has been dropped
(synchronized by the inpcb lock).  I think it's possible to pass the
first check in soshutdown() but fail the second check in
tcp_usr_shutdown(), so modify the KTLS tests to permit this.

Reviewed by:	jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42277
2023-11-17 09:31:21 -05:00
Gleb Smirnoff 070d9e3540 socket tests: add socket_accept
Start with most basic functionality on a TCP socket.
2023-11-16 08:23:48 -08:00
Yan-Hao Wang 55141f2c89
Add tests for gunion(8)
Reviewed by:	mckusick (earlier version)
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41645
2023-11-16 16:15:33 +08:00
Li-Wen Hsu 86e87c3bd1
Skip sys.netinet6.frag6.frag6_19.frag6_19 in CI
This test case is unreliable in CI environment.

PR:		274941
Sponsored by:	The FreeBSD Foundation
2023-11-07 04:59:24 +08:00
Kristof Provost 483d5c4075 pf tests: ensure that we generate all permutations for SCTP multihome
The initial multihome implementation was a little simplistic, and failed
to create all of the required states. Given a client with IP 1 and 2 and
a server with IP 3 and 4 we end up creating states for 1 - 3 and 2 - 3,
as well as 3 - 1 and 4 - 1, but not for 2 - 4.

Check for this.

MFC after:	1 week
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D42362
2023-10-31 16:03:22 +01:00
Stephen J. Kiernan 5e3190f700 dirdeps: Update Makefile.depend* files with empty contents
Some Makefile.depend* files were committed with no contents or empty
DIRDEPS list, but they should have DIRDEPS with some contents.
2023-10-29 17:01:04 -04:00