Commit Graph

118 Commits

Author SHA1 Message Date
Kristof Provost
480ad40553 vnet tests: check for if_bridge.ko
A number of tests create a bridge, but did not check if if_bridge.ko is loaded.

We usually get away with that, because `ifconfig bridge create` autoloads the
module, but if we run the tests in a jail (e.g. because of kyua's upcoming
execenv.jail.params feature) we can't load the module and these tests can fail.

Check if the module is loaded, skip the test if it is not.

Reviewed by:	markj
MFC after:	1 week
Event:		Kitchener-Waterloo Hackathon 202406
Differential Revision:	https://reviews.freebsd.org/D45487
2024-06-04 22:16:56 +02:00
Kristof Provost
5311e73337 netinet tests: basic VRRP tests
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D44775
2024-05-08 13:19:04 +02:00
Gleb Smirnoff
3f3d19d802 tests/netinet: fix UDP I/O test build
Fixes:	8d3d9ca8bd
2024-03-23 09:21:13 -07:00
Gleb Smirnoff
8d3d9ca8bd tests/netinet: add UDP socket I/O tests
Start a file that would collect tests for I/O functionality of a UDP
socket, targeted on how a socket interacts with userland rather than with
wire side of the protocol.

First version tests that MSG_TRUNC and MSG_PEEK are working correctly.
2024-03-22 22:44:16 -07:00
Gleb Smirnoff
1968d71647 tests/arp: test arp -s/-S work
Install permanent entry, try to modify it, check that
net.link.ether.inet.log_arp_permanent_modify works.
2024-02-20 10:32:03 -08:00
Gleb Smirnoff
28bc1822b7 tests/arp: when checking 'arp -d' check that entry is removed
Previous check trusted the "entry was deleted" output of the command.
Improved check does additional request to make sure that entry is not
returned.
2024-02-20 10:32:03 -08:00
Gleb Smirnoff
70f5c6e34f tests/netinet: push variable 'sin' into function scope
This should fix build with GCC 13.

Fixes:	861274c9f8
2024-02-02 21:09:02 -08:00
Gleb Smirnoff
861274c9f8 tests/netinet: add a demo of TCP implied connect
The TCP implied connect is an artifact left after T/TCP.  To my surprise
it still works, hence the existence of this test.  Please read this email
first:

https://lists.freebsd.org/pipermail/freebsd-net/2010-August/026311.html

An interesting fact that this test takes 220 - 240 milliseconds to
execute on my Threadripper PRO.  Flipping the '#if 0' to '#if 1' in the
test, thus bringing it back to normal connect(2), would speed the test up
a hundred times and I guess all this time is fork+exec of the test.
2024-02-01 13:43:36 -08:00
Mark Johnston
001c48b413 netinet tests: Make test jail names unique
Otherwise we get spurious test failures when running tests in parallel.
The intent here was to name jails after the tests, but this was done
incorrectly in a couple of places.

MFC after:	1 week
2024-01-27 13:51:37 -05: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
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
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
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
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
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
b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -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
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
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
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
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
33ff01cebc carp tests: test unicast carp via link-local addresses
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-05-18 17:47:04 +02:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Kristof Provost
5e2e3615d9 netinet tests: test carp source MAC address
Ensure that (multicast) CARP packets are sent with the expected source
MAC address.

Reviewed by:	melifaro
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39454
2023-04-07 17:56:45 +02:00
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
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
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