Commit Graph

1589 Commits

Author SHA1 Message Date
Kristof Provost
ddbd3a2b7c carp tests: unicast tests (IPv6)
Test the new unicast carp mode for IPv6.

There's a routing hop between the peers, to ensure that the TTL check is
correctly disabled for unicast carp.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D38942
2023-03-20 14:37:09 +01:00
Kristof Provost
92c5dbbb13 carp tests: unicast tests (IPv4)
Test the new unicast carp mode for IPv4.

There's a routing hop between the peers, to ensure that the TTL check is
correctly disabled for unicast carp.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D38941
2023-03-20 14:37:09 +01:00
Kristof Provost
9d48283d60 carp tests: test manually switch between backup and master
There's been at least one issue where we failed to correctly enter
NET_EPOCH that was triggered in this scenario.
Add a test case for it to make it easier to detect issues like this in
the future.

Reviewed by:	zlei
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39115
2023-03-20 10:52:53 +01:00
Mark Johnston
bad8f86843 netgraph tests: Serialize
Some tests share names for netgraph nodes, so they cannot be run in
parallel.

MFC after:	1 week
2023-03-18 16:57:11 -04:00
Alexander V. Chernikov
568a645ba5 netlink: fix capped uncapped ack handling in snl(3).
Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D39144
MFC after:	2 weeks
2023-03-18 11:35:56 +00:00
Mark Johnston
a7ba32e6bc tun tests: Fix cleanup definitions
Without this, vnet jails for the tests don't get torn down.

Fixes:	fe701c39e8 ("if_tun: Add basic connectivity test with nc tun support")
2023-03-16 13:27:24 -04:00
Dag-Erling Smørgrav
ef184e989b tarfs: Fix backtracking during node creation.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D39082
2023-03-16 11:31:22 +00:00
Dag-Erling Smørgrav
e81d55b439 tarfs: Support tar files which include file modes with permissions.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D39020
2023-03-16 11:31:22 +00:00
Dag-Erling Smørgrav
fd8c98a52f tarfs: Correctly track link count.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D39019
2023-03-16 11:31:22 +00:00
Dag-Erling Smørgrav
6cb78fa479 tarfs: Repeat tests using GNU tar if available.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	ngie, asomers
Differential Revision:	https://reviews.freebsd.org/D39018
2023-03-16 11:31:22 +00:00
Kristof Provost
225e85513f pf tests: test IPv6 fragmentation with link-local addresses
We've observed a panic after pf_refragment6() with link-local addresses,
because pf_refragment6() calls ip6_forward() even for a simple output
case.
That results in us entering ip6_forward() with an mbuf with a NULL
m->m_pkthdr.rcvif, which can cause a NULL deref (but seemingly not for
GUAs.

Test sending fragmented link-local packets to pf.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39063
2023-03-16 10:59:04 +01:00
Alexander V. Chernikov
73ae25c174 netlink: improve snl(3)
Summary:
* add snl_send_message() as a convenient send wrapper
* add signed integer parsers
* add snl_read_reply_code() to simplify operation result checks
* add snl_read_reply_multi() to simplify reading multipart messages
* add snl_create_genl_msg_request()
* add snl_get_genl_family() to simplify family name->id resolution
* add tests for some of the functionality

Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D39092
MFC after:	2 weeks
2023-03-15 20:53:20 +00:00
Mark Johnston
683853a924 sendfile tests: Mount filesystems under the test workdir
Otherwise they can't be run in parallel as they share a mount point.

MFC after:	1 week
2023-03-13 10:45:35 -04:00
Alexander V. Chernikov
90bc2120b5 tests: fix python parsing of netlink nested attributes
MFC after:	2 weeks
2023-03-13 10:17:36 +00:00
Alexander V. Chernikov
595d23f777 netlink: add snl(3) default parsers for routes and links.
This change adds the "default" parsers of _all_ route/link attributes
 exported by the kernel.
It removes the need to declare similar parsers in the userland applications,
 simplifying their logic.

Differential Revision: https://reviews.freebsd.org/D38979
MFC after:	2 weeks
2023-03-09 14:46:27 +00:00
Alexander V. Chernikov
c57dfd92c8 tests: add more netlink tests for neighbors/routes
Differential Revision: https://reviews.freebsd.org/D38912
MFC after:	2 weeks
2023-03-07 17:31:26 +00:00
Dag-Erling Smørgrav
b1218349ed tarfs: Set mountedfrom correctly.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	sjg, kib
Differential Revision:	https://reviews.freebsd.org/D38930
2023-03-07 17:20:49 +00:00
Kristof Provost
f427703f16 carp tests: ensure exactly one jail is master
Verify that we only have one master, not two.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-07 10:51:44 +01:00
Kristof Provost
38e2d5db2a netpfil tests: Add functions for testing routing scenarios
Many pf tests use identical setup where one jail is a router and
optionally another jail is a server. Add functions to create such jails
for IPv6 and IPv4 and functions to perform tests on such setup.

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

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38126
2023-03-04 14:35:24 +01:00
Mark Johnston
560f9cd5e1 posixshm tests: Correct page size index checks
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
2023-03-03 11:16:51 -05:00
Alexander V. Chernikov
ce9f95bd83 netlink: fix vlan interface creation
MFC after:	2 weeks
2023-03-03 16:02:05 +00:00
Olivier Cochard
e78dc78e51 testing: skip tarfs tests if module is not loadable.
Approved by:	asomers
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D38828
2023-03-01 22:23:07 +01:00
Kristof Provost
2a02d3dad3 pf tests: test pfsync over IPSec
Test that we can transport pfsync (unicast) over IPSec.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-01 16:10:12 +01:00
Kristof Provost
69361b8785 if_ovpn tests: skip the if_ovpn_c test if if_ovpn.ko isn't loaded
Skip the test (rather than loading it) if if_ovpn.ko isn't loaded. Match
the behaviour of other tests.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-01 10:07:34 +01:00
Gleb Smirnoff
a170657108 unix/dgram tests: match the kernel behavior
In CURRENT for some time an overflowed unix/dgram socket would
return EAGAIN if it has O_NONBLOCK set.  This proved to be
undesired.  See 71e70c25c0 for details.  Update tests to match
the "new" behavior, which actually is the historical behavior.
2023-02-22 20:44:46 -08:00
Alan Somers
5f51c9c328 fusefs: add some more test cases for bad fuse servers
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D38719
2023-02-22 10:03:58 -07:00
Alan Somers
0c9df4afc2 fusefs: fix a buffer overflow in the tests
The actual overflow occured in the ReadAhead.readahead test.
Surprisingly it has never segfaulted or resulted in any bad behavior.

MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D38718
2023-02-22 10:03:01 -07:00
Dag-Erling Smørgrav
d481dcee72 tarfs: Really prevent descending into a non-directory.
The previous fix was incorrect: we need to verify that the current node, if it exists, is not a directory, but we were checking the parent node instead.  Address this, add more tests, and fix the test cleanup routines.

PR:		269519, 269561
Fixes:		ae6cff8973
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D38645
2023-02-20 21:29:19 +00:00
Alexander V. Chernikov
828d3c6c4c tests: add netlink large dump buffer check
Differential Revision: https://reviews.freebsd.org/D38665
MFC after:	2 weeks
2023-02-20 10:20:54 +00:00
Alexander V. Chernikov
79748cec1f tests: fix netlink test_dump_ifaces_many test.
Consider only loopback interfaces when counting.
Otherwise, if pf is loaded, 'pflog0' gets added to the vnet,
 breaking the test.

MFC after:	2 weeks
2023-02-18 22:28:01 +00:00
Alexander V. Chernikov
ff8da9b2ba netlink: improve attribute decoding in python tests
MFC after:	2 weeks
2023-02-17 18:16:08 +00:00
Alexander V. Chernikov
86fd0bdba5 netlink: fix interface dump.
The current code missed interface addition when reallocating
 temporary buffer.
Tweak the code to perform the reallocation first and add
 interface afterwards unconditionally.

Reported by:	Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after:	3 days
2023-02-16 13:20:45 +00:00
Dag-Erling Smørgrav
ae6cff8973 tarfs: Don't panic if the parent of a new node is not a directory.
PR:		269519
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D38587
2023-02-15 02:13:11 +00:00
Kyle Evans
e63dcbe7a2 wg: tests: remove an obsolete workaround
PR 254212 was resolved to avoid issues with not having IPv6 addresses
present in the jail, so we can safely drop this workaround now...

Reviewed by:	jhb, markj
Differential Revision:	https://reviews.freebsd.org/D37755
2023-02-12 23:59:46 -06:00
Kyle Evans
96f4ab2663 wg: add a test for the home jail socket feature
This adds a test for a semantic that we added to mirror a feature of
the Linux implementation w/ netns: if a wg interface is moved into a
jail, we still create the socket in the context of the home vnet.  With
this added, one can actually create vnet jails that only have a wg
tunnel to the outside world providing network connectivity without any
epairs in the setup.

Reviewed by:	jhb, markj (both earlier version)
Differential Revision:	https://reviews.freebsd.org/D37755
2023-02-12 23:59:35 -06:00
Dag-Erling Smørgrav
ce6a0c776b tarfs: Fix issues revealed by static analysis and testing.
* tarfs_alloc_mount(): Remove an unnecessary null check (CID 1504505) and an unused variable.

* tarfs_alloc_one(): Verify that the file size is not negative (CID 1504506).  While there, also validate the mode, owner and group.

* tarfs_vget(), tarfs_zio_init(): Explicitly ignore return value from getnewvnode(), which cannot fail (CID 1504508)

* tarfs_lookup_path(): Fix a case where a specially-crafted tarball could trigger a null pointer dereference by first descending into, and then backing out of, a previously unknown directory. (CID 1504515)

* mktar: Construct a tarball that triggers the aforementioned null pointer dereference.

Reported by:	Coverity
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D38463
2023-02-09 17:35:47 +00:00
Alexander V. Chernikov
25c2dd2f2c netlink: return optional metadata with the operation result.
Some operations like interface creation may need to return metadata
 - in this case, interface name - back to the caller if the operation
 is successful.
This change implements attaching an `NLMSGERR_ATTR_COOKIE` nla to the
operation reply message via `nlmsg_report_cookie()`.
Additionally, on successful interface creation, interface index and
 interface name are returned in the `IFLA_NEW_IFINDEX` and `IFLA_IFNAME
 TLVs, encapsulated in the `NLMSGERR_ATTR_COOKIE`.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38283
MFC after:	1 week
2023-02-09 15:30:00 +00:00
Alexander V. Chernikov
6332ef8941 testing: handling non-root users with VNETs in pytest-based tests.
Currently isolation and resource requirements are handled directly
 by the kyua runner, based on the requirements specified by the test.
It works well for simple tests, but may cause discrepancy with tests
 doing complex pre-setups. For example, all tests that perform
 VNET setups require root access to properly function.

This change adds additional handling of the "require_user" property
 within the python testing framework. Specifically, it requests
 root access if the test class signals its root requirements and
 drops privileges to the desired user after performing the pre-setup.

Differential Revision: https://reviews.freebsd.org/D37923
MFC after:	2 weeks
2023-02-09 14:49:27 +00:00
Olivier Cochard
d22c5c42e8 Skip if_wg regression tests if module doesn't exist
Approved by:	jhb
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D38406
2023-02-07 00:06:48 +01:00
Kristof Provost
afa77b6996 pf tests: improve pfsync:basic_defer test
Create state on output only, to ensure we trigger the defer code.

MFC after:	2 weeks
2023-02-03 09:39:21 +01:00
Dag-Erling Smørgrav
69d94f4c76 Add tarfs, a filesystem backed by tarballs.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	pauamma, imp
Differential Revision:	https://reviews.freebsd.org/D37753
2023-02-02 18:19:29 +01:00
Dmitry Chagin
02f7670ed2 sched.h: Fix _S macros for better compatibility with glibc.
In e2650af157 was added "_S" macros for compatibility with glibc, but it's still
incompatible as under glibc the macros whose names end with "_S" operate on the
dynamically allocated CPU set(s) whose size is in bytes, not in bits.

While here remove limiting ifdef to non-kernel case.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D38110
MFC after:		1 week
2023-01-29 15:34:10 +03:00
Alexander V. Chernikov
20ea7f26e4 pytest: delete interfaces from inside the jail.
This change follows the approach used in 80fc25025f, to
 minimise the impact of the delayed interface migration.

MFC after:	2 weeks
2023-01-25 16:34:17 +00:00
Alexander V. Chernikov
864ea9abfb pytest: add an example test fetching test directory and ATF vars.
MFC after:	2 weeks
2023-01-25 13:55:33 +00:00
Kajetan Staszkiewicz
06012728be netpfil tests: improve pfsync_defer.py
Return different exit code depending on which failure was encountered.
The pfsync test expect a very particular failure, not just any.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38123
2023-01-22 04:26:32 +01:00
Kajetan Staszkiewicz
f57218e469 netpfil tests: improve pft_ping.py
Multiple improvements to pft_ping.py:

* Automatically use IPv6 when IPv6 addresses are used, --ip6 is not needed.
* Building of ping requests and parsing of ping replies is done layer by
  layer. This way most arguments are available both for IPv6 and IPv4,
  for ICMP and TCP.
* Use argument groups for improved readability.
* Change ToS and TTL argument name to TC and HL to reflect the modern
  IPv6 nomenclature. The argument still set related IPv4 header fields
  properly.
* Instead of sniffing for the very specific case of duplicated packets,
  allow for sniffing on multiple interfaces.
* Report which sniffer has failed by setting bits of error code.
* Raise meaningful exceptions when irrecoverable errors happen.
* Make IPv4 fragmentation flags configurable.
* Make IPv6 HL / IPv4 TTL configurable.
* Make TCP MSS configurable.
* Make TCP sequence number configurable.
* Make ICMP payload size configurable.
* Add debug output.
* Move command line argument parsing out of network functions.
* Make the code somehow PEP-8 compliant.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38122
2023-01-22 04:26:32 +01:00
Kajetan Staszkiewicz
a39dedeb31 netpfil tests: improve sniffer.py
Multiple improvements to sniffer.py:

* Remove ambiguity of configuring recvif, it must be now explicitly specified.
* Don't catch exceptions around creating the sniffer, let it properly
  fail and display the whole stack trace.
* Count correct packets so that duplicates can be found.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38120
2023-01-22 04:26:32 +01:00
Alexander V. Chernikov
0079d177ab netlink: allow creating sockets with SOCK_DGRAM.
Some existing applications setup Netlink socket with
SOCK_DGRAM instead of SOCK_RAW. Update the manpage to clarify
that the default way of creating the socket should be with
SOCK_RAW. Update the code to support both SOCK_RAW and SOCK_DGRAM.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38075
2023-01-21 14:58:19 +00:00
Tom Jones
fe701c39e8 if_tun: Add basic connectivity test with nc tun support
Reviewed by:    kevans
Sponsored by:   Zenarmor
Sponsored by:   OPNsense
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D37435
2023-01-17 10:05:50 +00:00
Alexander V. Chernikov
228c632ab3 netlink: fix compatibility with older netlink applications.
Some apps try to provide only the non-zero part of the required message
 header instead of the full one. It happens when fetching routes or
 interface addresses, where the first header byte is the family.
This behavior is "illegal" under the "strict" Netlink socket option,
 however there are many applications out there doing things in the
 "old" way.

Support this usecase by copying the provided bytes into the temporary
 zero-filled header and running the parser on this header instead.

Reported by:	Goran Mekić <meka@tilda.center>
2023-01-16 12:21:40 +00:00