Commit graph

89 commits

Author SHA1 Message Date
Gleb Smirnoff 78ec113617 tests/netinet: mark more tests that require python 2022-12-07 11:51:49 -08:00
John Baldwin 9e0aaedd70 Split netinet shell tests into one per line.
This makes diffs when adding or removing tests easier to read.

While here, sort the list of tests.

Reviewed by:	kevans, melifaro, asomers, markj, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36908
2022-10-28 13:36:12 -07:00
Mike Karels ec00e95190 netinet tests: Add test for IPv6 mapped-v4 bind problem
Test fix in 637f317c6d, verifying that when ports run out, we get
an EADDRNOTAVAIL error from bind() rather than an EADDRINUSE error
from connect().  Use small port range to exhaust ports and see which
error happens.

Reviewed by:	tuexen, glebius, melifaro
Differential Revision:	https://reviews.freebsd.org/D36056
MFC after:	3 days (with 637f317c6d)
2022-08-09 07:08:09 -05:00
Claudio Jeker 7958889716 Add tests for TCP_MD5 getsockopt
Add tests for TCP_MD5 getsockopt for ipv6 and ipv4. These will only run
when the kernel module is loaded, but will be in place if further
regressions are found.

Reviewed by:	rscheff
MFC after:	3 days
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D35532
2022-06-23 15:57:56 +01:00
Kristof Provost d234b011a8 netinet tests: only log critical errors from scapy
See also a26e895f3d.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-17 23:34:12 +01:00
John Baldwin dba02df30d Cast pointer to uintptr_t to avoid alignment warnings.
Both struct ip and struct udphdr both have an aligment of 2, but the
cast from struct ip to a uint32_t pointer confused GCC 9 into raising
the required alignment to 4 and then raising a
-Waddress-of-packed-member error when casting to struct udphdr.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D31941
2022-02-11 16:04:52 -08:00
Thomas Steen Rasmussen 4a178afb4a tests/netinet: add test for IPv6 NS and CARP
PR:			193280
Reviewed by:		melifaro
Differential revision:	https://reviews.freebsd.org/D33859
2022-01-24 21:02:47 -08:00
Lutz Donnerhacke 2c733b50c5 tests/libalias: Portrange
Test ranges of allowed ports for aliasing.
 - Explicit default like ipfw(8) is doing
 - Regular range
 - Exhausting a very small range
 - Recovery

Includes a fix of an utility macro, which was not used before.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31012
2021-12-27 14:54:57 +01:00
Dimitry Andric 46aec7fae4 tests/libalias: Make inline functions static inline
In C, plain inline functions should never be used: they should be
declared either static inline or extern inline. In this case, they are
clearly meant to be static inline.

MFC after:	3 days
2021-12-20 10:52:25 +01:00
Gleb Smirnoff 6913bf4c3d tests/divert: fix after 2ce85919bb (IP source address validation)
Just make the test packet more legitimate.

Reviewed by:	melifaro
2021-11-12 11:20:06 -08:00
Marius Halden 847b0d07c4 carp tests: negative demotion
PR:		259528
Reviewed by:	donner
MFC after:	3 weeks
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D32760
2021-11-01 17:08:23 +01:00
Kristof Provost e86469075c netinet tests: delete an interface with pending lookups
This has been known to trigger panics. It currently doesn't, but we may
as well have a test for it.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-08-17 17:01:21 +02:00
Lutz Donnerhacke b3dc6f137b tests/libalias: Bugfix in used variables
Fix two copy and waste errors (referencing the wrong variable).

MFC after:	3 days
2021-07-03 00:31:54 +02:00
Lutz Donnerhacke 5434ebd256 tests/libalias: Measure cleanup time separatly
After long test runs, a lot of ressouces can be allocated.  Freeing
them takes a considerable amount of time.
2021-05-28 17:29:10 +02:00
Lutz Donnerhacke f4c460dacd tests/libalias: Fix build error due to wrong prototype 2021-05-26 21:59:12 +02:00
Lutz Donnerhacke fef99da69f tests/libalias: Add missing prototype to fix build error 2021-05-26 19:39:06 +02:00
Lutz Donnerhacke d62e1ecba0 tests/libalias: Add port forwardings
Add port forwardings to the performance tests.  This will cause random
incoming packets to match the random port forwardings opends beforehand.

MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30443
2021-05-26 16:34:22 +02:00
Lutz Donnerhacke 6e87898a2c tests/libalias: Improve testing
gettimeofday(3) is almost as expensive as the calls to libalias.
So the call frequency for this call is reduced by a factor of 1000 in
order to neglect it's influence.

Using NAT entries became more realistic: A communication of a random
length of up to 150 packets (10% outgoing, 90% incoming) is applied
for each entry.

Precision of the execution time is raised to see the trends better.

Reviewed by:	kp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30405
2021-05-26 16:26:44 +02:00
Lutz Donnerhacke 755bab6d55 tests/libalias: Test LibAliasIn on redirection
Extend the test suite for libalias(3) to incoming connections.
Test the various types of redirections.

MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30408
2021-05-26 16:19:24 +02:00
Lutz Donnerhacke f1462ab051 tests/libalias: Factor out common primitives
Rework the tests to check the correct layer in a single test.
Factor out tests for reuse in other modules.

MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30412
2021-05-26 16:16:07 +02:00
Lutz Donnerhacke 7b8696bf12 tests/libalias: Add missing copyright statements 2021-05-24 21:56:05 +02:00
Lutz Donnerhacke a660948b7b tests/libalias: Reduce stress
Due to the new, external performance test utility, the regular test
suite can reduce the stress test to a fair amount of activity.

MFC after:	1 week
2021-05-23 22:48:28 +02:00
Lutz Donnerhacke ccac04cae5 test/libalias: Fix build errors on various platforms
struct timeval has an unspecified integral type, which needs to be
canonfied before beeing usable by printf(3).
2021-05-23 14:43:00 +02:00
Lutz Donnerhacke 33c1bdfc3e tests/libalias: Add perfomance test utility
In order to compare upcoming changes for their effectivness, measure
performance by counting opertions and the runtime of each operation
over the time.  Accumulate all tests in a single instance, so make it
complicated over the time.  If you wait long enough, you will notice
the expiry of old flows.

Reviewed by:	kp (earlier version)
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30379
2021-05-22 23:45:42 +02:00
Lutz Donnerhacke c1fbb54f4b test/libalias: Tests for outgoing NAT
Testing LibAliasOut functionality. This concentrates the typical use
case of initiating data transfers from the inside.  Provide a
exhaustive test for the data structure in order to check for
performance improvements.

Reviewed by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30335
2021-05-21 11:45:52 +02:00
Lutz Donnerhacke 7fd8baee75 test/libalias: Tests for instantiation
In order to modify libalias for performance, the existing
functionality must not change.  Enforce this.

Reviewed by:	kp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30307
2021-05-18 22:15:39 +02:00
Thomas Munro 3aaaa2efde poll(2): Add POLLRDHUP.
Teach poll(2) to support Linux-style POLLRDHUP events for sockets, if
requested.  Triggered when the remote peer shuts down writing or closes
its end.

Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D29757
2021-04-28 23:00:31 +12:00
Kyle Evans f187d6dfbf base: remove if_wg(4) and associated utilities, manpage
After length decisions, we've decided that the if_wg(4) driver and
related work is not yet ready to live in the tree.  This driver has
larger security implications than many, and thus will be held to
more scrutiny than other drivers.

Please also see the related message sent to the freebsd-hackers@
and freebsd-arch@ lists by Kyle Evans <kevans@FreeBSD.org> on
2021/03/16, with the subject line "Removing WireGuard Support From Base"
for additional context.
2021-03-17 09:14:48 -05:00
Kyle Evans e277a507d8 tests: netinet: add missing up from local change 2021-03-15 00:24:54 -05:00
Kyle Evans 74ae3f3e33 if_wg: import latest fixup work from the wireguard-freebsd project
This is the culmination of about a week of work from three developers to
fix a number of functional and security issues.  This patch consists of
work done by the following folks:

- Jason A. Donenfeld <Jason@zx2c4.com>
- Matt Dunwoodie <ncon@noconroy.net>
- Kyle Evans <kevans@FreeBSD.org>

Notable changes include:
- Packets are now correctly staged for processing once the handshake has
  completed, resulting in less packet loss in the interim.
- Various race conditions have been resolved, particularly w.r.t. socket
  and packet lifetime (panics)
- Various tests have been added to assure correct functionality and
  tooling conformance
- Many security issues have been addressed
- if_wg now maintains jail-friendly semantics: sockets are created in
  the interface's home vnet so that it can act as the sole network
  connection for a jail
- if_wg no longer fails to remove peer allowed-ips of 0.0.0.0/0
- if_wg now exports via ioctl a format that is future proof and
  complete.  It is additionally supported by the upstream
  wireguard-tools (which we plan to merge in to base soon)
- if_wg now conforms to the WireGuard protocol and is more closely
  aligned with security auditing guidelines

Note that the driver has been rebased away from using iflib.  iflib
poses a number of challenges for a cloned device trying to operate in a
vnet that are non-trivial to solve and adds complexity to the
implementation for little gain.

The crypto implementation that was previously added to the tree was a
super complex integration of what previously appeared in an old out of
tree Linux module, which has been reduced to crypto.c containing simple
boring reference implementations.  This is part of a near-to-mid term
goal to work with FreeBSD kernel crypto folks and take advantage of or
improve accelerated crypto already offered elsewhere.

There's additional test suite effort underway out-of-tree taking
advantage of the aforementioned jail-friendly semantics to test a number
of real-world topologies, based on netns.sh.

Also note that this is still a work in progress; work going further will
be much smaller in nature.

MFC after:	1 month (maybe)
2021-03-14 23:52:04 -05:00
Alexander V. Chernikov f17f94cd1b Add arp/ndp tests in addition to rtsock ll tests. 2021-02-20 18:26:36 +00:00
Alan Somers 01f3f35447 ping: fix some man pages and tests after r368045
MFC-with:	r368045
2020-11-26 04:55:02 +00:00
Jonathan T. Looney 36c52a52ee Add a regression test for the port-selection behavior fixed in r367680.
Reviewed by:	markj, olivier, tuexen
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D27173
2020-11-14 15:44:28 +00:00
Alexander V. Chernikov a3525bd166 Try to enable multipath routing in flowid tests. 2020-10-16 21:51:17 +00:00
Kyle Evans 7cc42f6d25 Do a sweep and remove most WARNS=6 settings
Repeating the default WARNS here makes it slightly more difficult to
experiment with default WARNS changes, e.g. if we did something absolutely
bananas and introduced a WARNS=7 and wanted to try lifting the default to
that.

Drop most of them; there is one in the blake2 kernel module, but I suspect
it should be dropped -- the default WARNS in the rest of the build doesn't
currently apply to kernel modules, and I haven't put too much thought into
whether it makes sense to make it so.
2020-10-01 01:10:51 +00:00
Olivier Cochard 0d46edd0bb Enable SO_LINGER to the so_reuseport_lb_test regression tests, preventing
many sockets in TIME_WAIT state at the end of the test.

PR:		249885
Reviewed by:	markj
Approved by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D26549
2020-09-25 16:02:13 +00:00
Alexander V. Chernikov 4a8c6300e9 Use atf_fail instead of exit 1 to indicate mpath tests failure. 2020-09-18 07:27:01 +00:00
Alexander V. Chernikov 99efb80d00 Add basic test for net.fibs dynamic growth.
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D26382
2020-09-10 19:25:51 +00:00
Shteryana Shopova a7a64b722b Proper check if divert(4) module is present by the relevant tests
Fix the netinet/netinet6 divert tests falsely reporting 'ipdivert module is
not loaded' when the divert module is built into the kernel

Sponsored by:	Axiado
Differential Revision:	https://reviews.freebsd.org/D25026
2020-05-27 16:33:00 +00:00
Edward Tomasz Napierala b43bd1070c Make sys.netinet.output and sys.netinet6.output6 tests depend on python;
they need to be able to run net_receiver.py.

MFC after:	2 weeks
Sponsored by:	DARPA
2020-05-19 21:48:45 +00:00
Li-Wen Hsu 6c9dbd8b13 Revert r361237, it's fixed by r361231
PR:		246560
Sponsored by:	The FreeBSD Foundation
2020-05-19 07:16:09 +00:00
Li-Wen Hsu 3f5fe78b9a Temporarily disable test case causes kernel panic in CI:
- sys.netinet.so_reuseport_lb_test.basic_ipv6

PR:		246560
Sponsored by:	The FreeBSD Foundation
2020-05-19 02:07:08 +00:00
Alexander V. Chernikov 768c98a737 Add basic routing LPM tests.
Differential Revision:	https://reviews.freebsd.org/D24684
2020-05-06 07:48:37 +00:00
Li-Wen Hsu 69b7dbeb38 Only skip sys.netinet.socket_afinet.socket_afinet_bind_zero in CI env
Sponsored by:	The FreeBSD Foundation
2020-04-20 14:24:13 +00:00
Li-Wen Hsu a1841da4fa Temporarily disable sys.netinet.divert.* on i386
PR:		244703
Sponsored by:	The FreeBSD Foundation
2020-04-20 14:18:56 +00:00
Kristof Provost 47308803e7 carp tests: Basic functionality test
Set up three vnet jails, bridged together. Run carp between two of them.
Attempt to provoke locking / epoch issues.

Reviewed by:	mav (previous version), melifaro, asomers
Differential Revision:	https://reviews.freebsd.org/D24303
2020-04-12 16:13:05 +00:00
Alfredo Dal'Ava Junior 9b2877353b so_reuseport_lb_test: correct setsockopt parameter size
Change type of variable used in setsocketopt so correct size of
option is passed.

Test failure was identified when running the test on PowerPC64,
and the following error message was seen:

	"bind () failed: Address already in use"

Submitted by:	Fernando Valle <fernando.valle@eldorado.org.br>
Reviewed by:	melifaro, adalava
Approved by:	jhibbits (mentor)
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D24164
2020-03-25 20:20:08 +00:00
Alexander V. Chernikov b4a4a3b82f Add tests verifying IPv4/IPv6 output for TCP/UDP/raw paths.
Reviewed by:	kp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24138
2020-03-23 12:21:32 +00:00
Alexander V. Chernikov d7cdd89777 Add basic IPv4/IPv6 forwarding tests.
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24002
2020-03-10 19:52:19 +00:00
Alexander V. Chernikov ea2773323c Fix dynamic redrects by adding forgotten RTF_HOST flag.
Improve tests to verify the generated route flags.

Reported by:	jtl
MFC after:	2 weeks
2020-03-03 15:33:43 +00:00