Commit graph

1827 commits

Author SHA1 Message Date
Kristof Provost 6bd36d1cf4 pf tests: pflow functionality test
Test that we actually send netflow messages when configured to do so.
We do not yet inspect the generated netflow messages.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43111
2024-01-16 09:45:54 +01:00
Kristof Provost fb0c74685f pf tests: initial pflow test case
Basic creation, validation and cleanup test for the new pflow interface.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43109
2024-01-16 09:45:54 +01:00
Kyle Evans 30189156d3 kern: pts: do not special case closed slave side
This would previously return 1 if the slave side of the pts was closed
to force an application to read() from it and observe the EOF, but it's
not clear why and this is inconsistent both with how we handle devices
with similar mechanics (like pipes) and also with other kernels, such as
OpenBSD/NetBSD and Linux.

PR:             239604
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43457
2024-01-15 20:55:59 -06:00
Alan Somers daf26f9350 fusefs: more consistent operand ordering in io.cc
MFC after:	2 weeks
2024-01-15 16:16:40 -07:00
Alan Somers 1c909c300b fusefs: fix an interaction between copy_file_range and mmap
If a copy_file_range operation tries to read from a page that was
previously written via mmap, that page must be flushed first.

MFC after:	2 weeks
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D43451
2024-01-15 14:57:15 -07:00
Kristof Provost 3f9a6e0b85 pf tests: dummynet + nat fragmentation test
Ensure that we do the right thing when we reassemble fragmented packet
and send it through a dummynet pipe.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-15 14:02:02 +01:00
Kristof Provost 24c0058a9b pf tests: test reassembly with dummynet
Ensure that if we pass packets through a dummynet pipe we still
reassemble as expected.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-15 14:02:02 +01:00
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
Kajetan Staszkiewicz ede5d4ff5b pf: Fix packet reassembly
Don't drop fragmented packets when reassembly is disabled, they can be
matched by rules with "fragment" keyword. Ensure that presence of scrub
rules forces old behaviour.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D42355
2023-10-26 15:25:44 +02:00
Kajetan Staszkiewicz d7c9de2d68 pf tests: Add option to send fragmented packets
Add option to send fragmented packets and to properly sniff them by
reassembling them by the sniffer itself.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D42354
2023-10-26 15:25:20 +02:00
Kristof Provost 501b7fbd75 pf tests: add a test for killing states by NAT address
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42313
2023-10-23 16:37:05 +02:00
Mark Johnston 6ad6929974 netinet tests: Fix leaks in ip6_v4mapped_test
Reported by:	Coverity
MFC after:	1 week
2023-10-20 10:05:58 -04:00
Igor Ostapenko fabf705f4b pf: fix pf divert-to loop
Resolved conflict between ipfw and pf if both are used and pf wants to
do divert(4) by having separate mtags for pf and ipfw.

Also fix the incorrect 'rulenum' check, which caused the reported loop.

While here add a few test cases to ensure that divert-to works as
expected, even if ipfw is loaded.

divert(4)
PR:		272770
MFC after:	3 weeks
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D42142
2023-10-19 12:12:15 +02:00
Gleb Smirnoff 2d49ff1e21 tests/netlink: mark the vlan(4) test with required module 2023-10-18 22:21:53 -07:00
Mark Johnston ae5c3dfd3e netinet tests: Add error handling tests for UDP with v4-mapped sockets
This provides a regression test for commit abca3ae773.

Add it to the existing v4-mapped address test file, and rename
accordingly.

Reviewed by:	tuexen, karels, rrs
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39216
2023-10-17 11:19:06 -04:00
Mark Johnston 4bd1e19684 socket tests: Build fix
Fixes:	d8735eb7ac ("socket tests: Add a regression test for ktrace+recv(MSG_TRUNC)")
Reported by:	Jenkins
2023-10-17 10:22:11 -04:00
Mark Johnston d8735eb7ac socket tests: Add a regression test for ktrace+recv(MSG_TRUNC)
MFC after:	1 week
2023-10-17 09:12:57 -04:00
Mark Johnston b5e7dbac75 socket tests: Clean up the MSG_TRUNC regression tests a bit
- Fix style.
- Move test case-specific code out of the shared function and into the
  individual test cases.
- Remove unneeded setting of SO_REUSEPORT.
- Avoid unnecessary copying.
- Use ATF_REQUIRE* instead of ATF_CHECK*.  The former cause test
  execution to stop after a failed assertion, which is what we want.
- Add a test case for AF_LOCAL/SOCK_SEQPACKET sockets.

MFC after:	1 week
2023-10-17 09:12:36 -04:00
Kristof Provost 4f8f43b06e netlink: cope with growing requests
If a request ends up growing beyong the initially allocated space the
netlink functions (such as snl_add_msg_attr_u32()) will allocate a
new buffer. This invalidates the header pointer we can have received
from snl_create_msg_request(). Always use the hdr returned by
snl_finalize_msg().

Reviewed by:	melifaro
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42223
2023-10-17 08:47:52 +02:00
Kristof Provost 81647eb60e pf: implement start/stop calls via netlink
Implement equivalents to DIOCSTART and DIOCSTOP in netlink. Provide a
libpfctl implementation and add a basic test case, mostly to verify that
we still return the same errors as before the conversion

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42145
2023-10-13 09:53:22 +02:00
Kristof Provost a7191e5d7b pf: add a way to list creator ids
Allow userspace to retrieve a list of distinct creator ids for the
current states.

This is used by pfSense, and used to require dumping all states to
userspace. It's rather inefficient to export a (potentially extremely
large) state table to obtain a handful (typically 2) of 32-bit integers.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42092
2023-10-10 11:48:21 +02:00
Alan Somers 662ec2f781 fusefs: sanitize FUSE_READLINK results for embedded NULs
If VOP_READLINK returns a path that contains a NUL, it will trigger an
assertion in vfs_lookup.  Sanitize such paths in fusefs, rejecting any
and warning the user about the misbehaving server.

PR:		274268
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	mjg, markj
Differential Revision: https://reviews.freebsd.org/D42081
2023-10-07 08:22:03 -06:00
Alan Somers 8399d764c9 Fix intermittency in the sys.fs.fusefs.symlink.main test
This change is identical to 86885b1868 but for symlink instead of
mknod.  The kernel sends a FUSE_FORGET asynchronously with the final
syscall.  The lack of an expectation caused this test to occasionally
fail.

Also, remove a sleep that accidentally snuck into a different test.

MFC after:	2 weeks
MFC with:	86885b1868
Sponsored by:	Axcient
2023-10-06 15:08:03 -06:00
Alan Somers 86885b1868 Fix intermittency in the sys.fs.fusefs.mknod.main test
In the Mknod.parent_inode test case, the kernel sends an extra
FUSE_FORGET message.  But because it gets sent asynchronously with the
failing syscall, it doesn't always get received before the test ends.
So we never setup an expectation for it.  And 90+% of the time the test
would exit successfully.

Fix the intermittency by always waiting to receive the FUSE_FORGET
message.

MFC after:	2 weeks
Sponsored by:	Axcient
2023-10-06 13:57:38 -06:00
Dag-Erling Smørgrav c5e5722220 tests: Use ifconfig -j instead of jexec ifconfig.
Reviewed by:	kp, asomers
Differential Revision:	https://reviews.freebsd.org/D42110
2023-10-06 18:40:07 +02:00
Dag-Erling Smørgrav aad8fb3e2b tests: Add a test case for arp host lookups.
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D42108
2023-10-06 18:39:59 +02:00
Brad Davis 7bf5f682c0 Improve the pf nat exhaustion test by checking the reply from the echo server
Event:	Oslo Hackathon
Approved by:	kp
2023-10-06 09:19:51 -06:00
Alan Somers 6a773a0582 fusefs: add more readdir tests for misbehaving servers
Inspired by PR 274268

MFC after:	2 weeks
Sponsored by:	Axcient
2023-10-05 10:15:03 -06:00
Kristof Provost 956a463114 if_ovpn tests: fix ra test
Client one is supposed to be assigend 198.51.100.2, but sometimes it
loses the race and the address ends up assigned to client two. When this
happened one would try to ping itself, which failed because the loopback
interface isn't up.

Ideally we'd generate static address assignments, but that would
complicate the test. Activate loopback interfaces so the test always
passes, and just try to ping both possible addresses.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-10-05 09:48:49 +02:00
Kristof Provost 74c2461386 pf: cope with missing rpool.cur
If we're evaluating a pfsync'd state (and have different rules on both
ends) our state may point to the default rule, which does not have
rpool.cur set. As a result we can end up dereferencing a NULL pointer.

Explicitly check for this when we try to re-construct the route-to interface.

Also add a test case which can trigger this issue.

MFC after:	3 days
See also:	https://redmine.pfsense.org/issues/14804
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-10-04 10:16:03 +02:00
Dmitry Chagin b67c0ba461 tests: Test that SIGSYS is not delivered if kern.signosys knob is off
Reviewed by:		markj
Differential Revision:	https://reviews.freebsd.org/D41979
MFC after:		1 week
2023-10-03 10:38:02 +03:00
Konstantin Belousov 0afcac3e37 SIGSYS: add tests
Reviewed by:	dchagin, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41976
2023-10-03 01:30:53 +03:00
Mark Johnston c4b927c341 geli tests: Use shorter passphrases in setkey_passphrase
There is an undocumented limit on the length of a GELI passphrase, and
the test exceeded that.  Most of the time it worked because a nul
terminator would appear early enough in the string.

Reported by:	Jenkins
Fixes:		2b7b09ac96 ("geli tests: Add a regression test for geli setkey -J")
2023-10-02 16:57:51 -04:00
Mariusz Zaborski 62d3f57c22 capsicum: add tests for copy_file_range
Reviewed by:    emaste, theraven, kib, markj (all previous version)
Differential Revision:  https://reviews.freebsd.org/D41967
2023-09-28 15:48:32 +02:00
Mark Johnston a3074ff212 socket tests: Avoid a buffer leak
Reported by:	Coverity
Fixes:		38426b32e1 ("socket tests: Add a regression test for MSG_WAITALL")
2023-09-27 08:30:50 -04:00
Alan Somers e5236d25f2 fusefs: fix unused variables from fb619c94c6
PR:		270749
Reported by:	cy
MFC after:	1 week
MFC with:	fb619c94c6
Sponsored by:	Axcient
2023-09-21 09:40:49 -06:00
Alan Somers fb619c94c6 fusefs: fix some bugs updating atime during close
When using cached attributes, we must update a file's atime during
close, if it has been read since the last attribute refresh.  But,

* Don't update atime if we lack write permissions to the file or if the
  file system is readonly.
* If the daemon fails our atime update request for any reason, don't
  report this as a failure for VOP_CLOSE.

PR:		270749
Reported by:	Jamie Landeg-Jones <jamie@catflap.org>
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	pfg
Differential Revision: https://reviews.freebsd.org/D41925
2023-09-21 08:02:31 -06:00
Mark Johnston 8f26ed01bd mlock tests: Add a regression test
The test tries to trigger creation of a superpage mapping in an
mlock()ed region.

MFC after:	2 weeks
2023-09-17 06:27:31 -04:00
Mark Johnston d643925a79 unix tests: Use the right type for sendmsg(2) return values
MFC after:	1 week
2023-09-15 13:04:15 -04:00
Mark Johnston 38426b32e1 socket tests: Add a regression test for MSG_WAITALL
PR:		212716
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-09-15 12:59:46 -04:00
Kristof Provost 7d45cdbad4 pf tests: pfsync:defer requires scapy
Add the kyua hint so we skip the test if it's not installed.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-09-13 11:12:27 +02:00
Dag-Erling Smørgrav ef8abddf10 mkfile: getopt() returns an int, not a char.
MFC after:	3 days
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41804
2023-09-10 18:33:32 +00:00
Kristof Provost 97340b68d1 pf tests: extend SCTP tests to test state removal through ASCONF
pf can now mark shut down multihomed connections shutting down. Verify
that pf does the right thing.

MFC after:	3 weeks
Sponsored by:	Orange Business Services
2023-09-07 19:05:01 +02:00
Kristof Provost 1a28d5fea7 pf tests: basic SCTP multihoming test
The SCTP server will announce multiple addresses. Block one of them with
pf, connect to the other have the client use the blocked address. pf
is expected to have created state for all of the addresses announced by
the server.

In a separate test case add the secondary (client) IP after the
connection has been established. The intent is to verify the
functionality of the ASCONF chunk parsing.

MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D41638
2023-09-07 19:05:01 +02:00
Warner Losh ea82362219 tests: Skip all tests that require mdconfig when /dev/mdctl missing
When run in a jail, /dev/mdctl is missing. So skip any tests that use
mdconfig or mdmfs with md in this case: they can't possibly work. This
is in line with other tests that test for presence of required features
and skip if they aren't present. I did this instead of checking for
jails so they can still run in jails that allow creation of md devices.

Sponsored by:		Netflix
2023-09-02 13:16:22 -06:00
Mark Johnston 2b7b09ac96 geli tests: Add a regression test for geli setkey -J
Make sure that it can be used to change the passphrase of both attached
and detached providers.

PR:		254966
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-08-28 11:06:42 -04:00
Dmitry Chagin f8bc606aad tests: Handle SIGSEGV in the vm stack mprotect exec test
To exit gracefully handle SIGSEGV and mark the test as failed.

MFC after:		3 days
2023-08-24 21:02:52 +03:00
Kristof Provost 1fd8c845b8 pf tests: test syncookies on IPv6
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-08-21 13:19:41 +02:00
Warner Losh 05248206f7 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:20 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Dmitry Chagin f3e11927dc vm: Allow MAP_32BIT for all architectures
Reviewed by:		alc, kib, markj
Differential revision:	https://reviews.freebsd.org/D41435
2023-08-14 20:20:20 +03:00
Li-Wen Hsu b231322dbe
tests: Also exclude powerpc/powerpcspe from mmap_map_32bit_test
Sponsored by:	The FreeBSD Foundation
2023-08-12 09:24:15 +08:00
Enji Cooper 811e0a31ac fusefs tests: handle -Wdeprecated* issues with GoogleTest 1.14.0
`INSTANTIATE_TEST_CASE_P` has been replaced with `INSTANTIATE_TEST_SUITE_P`.
Replace all uses of the former macro with the latter macro.

While here, address the fact that the latter macro doesn't permit some
of the constructions that the former macro did, e.g., empty parameters,
etc.

MFC after:	2 weeks
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D41398
2023-08-10 02:32:33 -07:00
Ed Maste 07d3738b82 soxstack: silence GCC warning
Add parens around _STACK_FLAG_GROWS expression to fix GCC warning about
arithmetic in operand of '|'.

Sponsored by:	The FreeBSD Foundation
2023-08-08 21:15:19 -04:00
Dmitry Chagin 76f28f656e tests: Fix build after 8920c5f2
MFC after:		2 weeks
2023-08-09 00:39:35 +03:00
Dmitry Chagin 8920c5f2a1 tests: Add stack grows tests
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D41320
MFC after:		2 weeks
2023-08-08 18:12:09 +03:00
Kristof Provost b23dbabb7f pf: test rules evaluation in the face of multiple IPv6 fragment headers
Send an ICMPv6 echo request packet with multiple IPv6 fragment headers.
Set rules to pass all packets, except for ICMPv6 echo requests.

pf ought to drop the echo request, but doesn't because it reassembles
the packet, and then doesn't handle the second fragment header. In other
words: it fails to detect the ICMPv6 echo header.

Reported by:	Enrico Bassetti bassetti@di.uniroma1.it (NetSecurityLab @ Sapienza University of Rome)
MFC after:	instant
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-08-04 15:24:16 +02:00
Dmitry Chagin 5a7e48dddf tests: Add MAP_32BIT flag test
Reviewed by:		kib, markj
Differential Revision:	https://reviews.freebsd.org/D41236
MFC after:		1 month
2023-08-01 23:23:15 +03:00
Mark Johnston 15e564e408 ggate tests: Serialize 2023-07-31 11:01:53 -04:00
Mark Johnston 9c3f6368b1 gmirror tests: Serialize 2023-07-31 11:01:49 -04:00
Shivank Garg 215bab7924 mac_ipacl: new MAC policy module to limit jail/vnet IP configuration
The mac_ipacl policy module enables fine-grained control over IP address
configuration within VNET jails from the base system.
It allows the root user to define rules governing IP addresses for
jails and their interfaces using the sysctl interface.

Requested by:	multiple
Sponsored by:	Google, Inc. (GSoC 2019)
MFC after:	2 months
Reviewed by:	bz, dch (both earlier versions)
Differential Revision: https://reviews.freebsd.org/D20967
2023-07-26 00:07:57 +00:00
Kristof Provost b03012d0b6 netinet6 tests: test for loss of Solicited-node multicast groups
The multicast code has an issue where it can lose the Solicited-node
multicast group subscription if the same address is added twice.

Test for this.

PR:		233683
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D41123
2023-07-24 16:47:50 +02:00
Kristof Provost b7a9a5773a pf tests: test SCTP pfsync
Ensure that SCTP connections survive a failover to the backup pf
instance.

MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40869
2023-07-21 12:32:19 +02:00
Kristof Provost 4369a57514 pf tests: test 'rdr' for SCTP
Explicitly test that we cannot change the port number with rdr.
That's not a desireable feature on SCTP, because it could break
multihomed connections.

MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40868
2023-07-21 12:32:19 +02:00
Kristof Provost 1e02b7cb07 pf tests: test SCTP NAT
MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40867
2023-07-21 12:32:19 +02:00
Kristof Provost 2d42aa9d7b pf tests: test SCTP 'return'
Ensure that we send a correct abort message for 'block return' rules.

Test this by validating that nc doesn't sit around waiting for a
connection. It should give up immediately when it receives the abort.

MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40865
2023-07-21 12:32:18 +02:00
Kristof Provost 9536347379 pf tests: basic SCTP connection test
pf can now inspect SCTP. Check that we can set up a connection.
IPv4 and IPv6 tests.

MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40863
2023-07-21 12:32:18 +02:00
Luiz Amaral 6fc7fc2dbb pfsync: transport over IPv6
Implement pfsync over IPv6.

Submitted by:	Luiz Amaral <email@luiz.eng.br>
Submitted by:	Naman Sood <naman@freebsdfoundation.org>
Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D40102
2023-07-13 08:09:42 +02:00
Alan Somers dba2e89ea7 Multiple fixes to the zfsd test suite
* Wait for gnop devices to disappear after "gnop destroy".

  Apparently that process is asynchronous now, or maybe it's just slower
  than it used to be.  Also, after removing a gnop wait for its pool to
  be degraded.  That isn't instant.

* The zfsd tests no longer require camcontrol.

  This was a harmless oversight from
  11ed0a95bf

* Fix the zfsd_degrade_001_pos test for recent zfs versions.

  ZFS now rate limits checksum errors to about 20 per second.  But
  zfsd's threshold for degrading a disk is 50 per minute.  So we must
  alternately corrupt and scrub the pool to ensure that checksum errors
  are generated in multiple 1-second windows, so that zfsd will see
  enough of them.

* Fix the zfsd_fault_001_pos test in VMs

  And, for that matter, when using NVME or SATA disks.  As originally
  written, the test used the da driver to inject errors.  Rewrite it to
  use gnop vdevs.  gnop can also inject errors.  It works on top of any
  disk device, and it's also faster than using da.

MFC after:	2 weeks
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D39437
2023-07-10 16:36:57 -06:00
Alfonso Gregory 6fde066264 Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:17 -06:00
Alan Somers be092bcde9 Fix the zfsd_autoreplace_001_neg test
It only ever worked by accident.
* Actually set autoreplace=off as stated in the description
* Wait for the removed device to disappear from the pool before
  proceeding.
* In the assertion, verify that the new disk does not get added, as
  described in the description.

MFC after:	2 weeks
Sponsored by:	Axcient
2023-07-05 16:38:49 -06:00
Olivier Cochard 150d8ca9f3 socket afinet tests: using dynamic ports instead of the same static port
Allows these tests to be run in parallel.

Approved by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D40859
2023-07-04 21:17:56 +02:00
Kristof Provost e842342373 pf tests: test double-pass codel
Build a setup where a given packet will be passed through the codel code
twice. This used to trigger issues with double-free on mtags.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-07-03 21:32:33 +02:00
Mark Johnston b1c66bc44a netinet tests: Add a test which connects a disconnected socket
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2023-06-23 10:06:13 -04:00
Mark Johnston 383d51d592 unix tests: Add a regression test for getpeername(2)
Ensure that it works as expected when applied to a self-connected
socket.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-06-21 14:39:36 -04:00
John Baldwin 062de1c5df tests/fusefs: Suppress false warning from GCC.
GCC complains that DNAME in the inval_entry_below_root test is not
used, but EXPECT_LOOKUP() does pass DNAME to strcmp in an internal
lambda function.

Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D40661
2023-06-20 12:34:39 -07:00
John Baldwin c555dcddce libalias tests: Mark an unused variable with __unused.
It is not trivial to remove this set but unused variable since it
assigned to inside of a macro body, so just mark it with __unused
instead.
2023-06-20 09:29:00 -07:00
John Baldwin 6dd202ce93 unix_seqpacket_test: Consistently use datalen as length to send.
This matches the other tests in this file and quiets a set but unused
warning from GCC.
2023-06-20 09:29:00 -07:00
Doug Rabson 3a1f834b52 pf: Add code to enable filtering for locally delivered packets
This is disabled by default since it potentially changes the behavior of
existing filter rule sets. To enable this extra filter for packets being
delivered locally, use:

	sysctl net.pf.filter_local=1
	service pf restart

PR:             268717
Reviewed-by:	kp
MFC-after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D40373
2023-06-20 15:34:01 +01:00
Kristof Provost f25ceb05af pf tests: make pfsync:defer test more robust
Set the defer timeout to 2.5 seconds, and only make sure that there's at
least a second of delay between the pfsync packet and the ping packet.
The intent is to allow the test to pass even when there's considerable
jitter on the timing measurement (e.g. when the test runs in a VM, such
as during the CI tests).

Allow the test to run in CI.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-06-20 11:38:11 +02:00
Alexander V. Chernikov 9247238cc4 netlink: fix failing TestRtNlAddIfaddrLo::test_add_6 tests.
Recent netlink commit added hook for calling IPv6 code upon implicit
inteface bring-up on adding first interface address. This hook handles
link-local ifa addition for the loopback interface, resulting in
failed assertion in the loopback tests.

Fix the tests by fixing the assert.
2023-06-13 15:26:44 +00:00
Kristof Provost 1e1bb5780c dummynet tests: attempt to provoke wf2q+ use-after-free
Attempt to provoke known use-after-free issues with WF2Q+.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-06-13 15:51:48 +02:00
Mark Johnston 9c0467929a geli tests: Add a regression test for PR 271766
This test case catches both of the bugs reported there.

PR:		271766
Reviewed by:	imp
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40469
2023-06-12 12:52:24 -04:00
Kristof Provost 657aec455f pf tests: test reassembly in the slow path
Ensure that 'fragment reassemble' works as expected, even in the IP
stack's slow forwarding path. (So not via ip_tryforward())

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40396
2023-06-06 10:03:50 +02:00
Doug Rabson 4a6b92849e pf: Fix tests broken by enabling inet-local filtering
Summary:
Three of the pf dummynet tests were using filter rules which matched
both the intended epair interface as well as lo0 which now receives
PFIL_OUT events for messages delivered to the local network stack (if
enabled). This commit changes the rules to match only for the expected
epair interface.

PR:             268717
Reviewed-by:	kp
MFC-after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D40393
2023-06-03 11:07:56 +01:00
Alexander V. Chernikov c1839039b1 netlink: use netlink mbufs in the mbuf chains.
Continue D40356 and switch the remaining parts of mbuf-related
code to the Netlink mbufs.

Reviewed By: gallatin
Differential Revision: https://reviews.freebsd.org/D40368
MFC after:	2 weeks
2023-06-02 13:14:20 +00:00
Alexander V. Chernikov e32221a15f netinet6: make IPv6 fragment TTL per-VNET configurable.
Having it configurable adds more flexibility, especially
 for the systems with low amount of memory.
Additionally, it allows to speedup frag6/ tests execution.

Reviewed by:	kp, markj, bz
Differential Revision:	https://reviews.freebsd.org/D35755
MFC after:	2 weeks
2023-06-01 12:04:49 +00:00
Doug Rabson 5ab151574c netinet*: Fix redirects for connections from localhost
Redirect rules use PFIL_IN and PFIL_OUT events to allow packet filter
rules to change the destination address and port for a connection.
Typically, the rule triggers on an input event when a packet is received
by a router and the destination address and/or port is changed to
implement the redirect. When a reply packet on this connection is output
to the network, the rule triggers again, reversing the modification.

When the connection is initiated on the same host as the packet filter,
it is initially output via lo0 which queues it for input processing.
This causes an input event on the lo0 interface, allowing redirect
processing to rewrite the destination and create state for the
connection. However, when the reply is received, no corresponding output
event is generated; instead, the packet is delivered to the higher level
protocol (e.g. tcp or udp) without reversing the redirect, the reply is
not matched to the connection and the packet is dropped (for tcp, a
connection reset is also sent).

This commit fixes the problem by adding a second packet filter call in
the input path. The second call happens right before the handoff to
higher level processing and provides the missing output event to allow
the redirect's reply processing to perform its rewrite. This extra
processing is disabled by default and can be enabled using pfilctl:

	pfilctl link -o pf:default-out inet-local
	pfilctl link -o pf:default-out6 inet6-local

PR:		268717
Reviewed-by:	kp, melifaro
MFC-after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D40256
2023-05-31 11:11:05 +01:00
Alexander V. Chernikov 7ee6b0f125 netlink: add snl(3) support for listing genetlink multicast groups
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D40282
MFC after:	2 weeks
2023-05-27 11:13:14 +00:00
Mark Johnston da8c3d2149 tests: Fix format strings
Reported by:	Jenkins
Fixes:		844942888f ("tests: Add a simple regression test for ptrace(PT_SC_REMOTE)")
2023-05-26 17:38:06 -04:00
Mark Johnston 844942888f tests: Add a simple regression test for ptrace(PT_SC_REMOTE)
MFC after:	1 week
2023-05-26 15:38:08 -04:00
Alexander V. Chernikov 7eee0eaf16 netlink: automatically generate broadcast for IPv4 ifa if not set.
MFC after:	2 weeks
2023-05-20 10:42:08 +00:00
Kristof Provost 6408d025cf carp test: improve jail names for unicast_ll_v6 test
Rename the jails used in the unicast_ll_v6 test, to ensure the jail
names are unique to this test.
That is one of the requirements for running these tests in parallel.
2023-05-18 22:12:08 +02:00
Kristof Provost 0d574d8ba8 pfsync tests: check for the correct IP address
When checking if the state synced over we should look for
198.51.100.254, not 198.51.100.2. The test worked because the incorrect
address is a substring of the correct one, but we should fix it anyway.

Reported by:	Naman Sood <naman@freebsdfoundation.org>
MFC after:	1 week
2023-05-18 22:12:07 +02:00
Kristof Provost 33ff01cebc carp tests: test unicast carp via link-local addresses
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-05-18 17:47:04 +02:00
Alexander V. Chernikov 10b94e4064 netlink: add support for adding/deleting interface addresses
Differential Revision: https://reviews.freebsd.org/D40103
MFC after:	2 weeks
2023-05-16 19:39:13 +00:00
Jessica Clarke 816129210a tests: Don't recurse into sys/compat32
Stubbing out the whole file means it has no targets, so recursive makes
fail with "don't know how to make X". We could fix that, but because the
level above is adding it to TESTS_SUBDIRS it'll generate an include line
for the subdirectory in its Kyuafile, which won't work (the problem that
was previously seen on non-aarch64 in CI). Thus we really need to not
even add it to TESTS_SUBDIRS in the first place.

Reported by:	Dan Mack <mack@macktronics.com>
Fixes:		28f66935d4 ("tests: Disable sys/compat32 and sys/compat32/aarch64 tests")
2023-05-16 02:06:34 +01:00