Commit graph

83 commits

Author SHA1 Message Date
Kristof Provost a7a273546e if_ovpn tests: test multiple simultaneous clients
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:41 +02:00
Kristof Provost 2fc1fc66c7 if_ovpn tests: Test if_ovpn when there's no route
In client mode (i.e. if there's only one peer) we should be able to
route to the correct peer even if the routing table is incorrect.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:30 +02:00
Kristof Provost f8b1ddbfb1 if_ovpn tests: tunnel with CHACHA20-POLY1305
Sponsored by:   Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:24 +02:00
Kristof Provost c09e62cd91 if_ovpn tests: test pf's route-to
Ensure that pf's route-to works with if_ovpn.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:24 +02:00
Kristof Provost 85a15e4704 if_ovpn tests: IPv6 in IPv4 and IPv4 in IPv6 tunnels
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:15 +02:00
Kristof Provost 3d4f61350d if_ovpn tests: tunnel over IPv6
Set up a tunnel over IPv6 carrying IPv6 traffic.

Sponsored by:   Rubicon Communications, LLC ("Netgate")
2022-06-28 13:50:58 +02:00
Kristof Provost 08926ae328 if_ovpn tests: timeout on clients
Test that openvpn (DCO) clients are notified and handle timeout events.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35091
2022-06-28 13:50:45 +02:00
Kristof Provost 067acae2f3 if_ovpn tests: basic test case
Set up an OpenVPN tunnel between two jails, send traffic through them to
confirm basic function.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35067
2022-06-28 13:50:37 +02:00
Kristof Provost 1e824ee84f if_bridge tests: test adding interfaces with different MTU
We now allow new bridge members to be added with a different MTU from
the bridge. We change the interface MTU to match the bridge.
Test this.

PR:	264883
2022-06-27 08:27:28 +02:00
Alexander V. Chernikov bd03f10a60 routing: add multipath pytest tests
Differential Revision:	https://reviews.freebsd.org/D31084
2022-06-25 19:29:11 +00:00
Kristof Provost 868bf82153 if: avoid interface destroy race
When we destroy an interface while the jail containing it is being
destroyed we risk seeing a race between if_vmove() and the destruction
code, which results in us trying to move a destroyed interface.

Protect against this by using the ifnet_detach_sxlock to also covert
if_vmove() (and not just detach).

PR:		262829
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D34704
2022-05-06 13:55:08 +02:00
Kristof Provost 31566b98b8 vlan tests: fix bpf_pcp test
We now allow net.link.vlan.mtag_pcp to be set per-vnet, so we must set
it in the correct vnet, not on the host.
2022-02-15 07:53:30 +01:00
Gleb Smirnoff 929ff66ad3 tests/sys/net/routing: remove bandaid against old epair(4) panic 2022-01-26 21:58:43 -08:00
Gleb Smirnoff 942d05e3b8 tests/sys/net/epair: don't leak the interface after the test 2022-01-26 21:08:50 -08:00
Warner Losh 7821ef4487 tests: sys.net.if_bridge_test.span is failing in CI
sys.net.if_bridge_test.span has been failing in CI for a while
now. Disable it until this can be resolved.

PR:		260461
Sponsored by:	Netflix
2021-12-15 18:32:37 -07:00
Kristof Provost 67573b7a39 net tests: fix if_stf:6to4
This test needs to have the loopback interface enabled, or route lookups
for our own IP addresses will fail.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33041
2021-11-20 19:29:02 +01:00
Kristof Provost 2610dcc1a5 net tests: 6rd to 6rd test
Test traffic between 6rd hosts, without border relay involvement.

PR:		253328
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33040
2021-11-20 19:29:02 +01:00
Kristof Provost e1b95017d2 net tests: 6rd test for if_stf
Basic test case for 6rd.

PR:		253328
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33039
2021-11-20 19:29:02 +01:00
Kristof Provost eb5e0755f7 net tests: basic if_stf test
Test the 6to4 code.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32850
2021-11-09 09:39:54 +01:00
Kristof Provost 6e0755b37b net tests: basic if_gif(4) test case
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32836
2021-11-08 12:00:00 +01:00
Li-Wen Hsu 2d827c065a
Skip sys.net.if_lagg_test.status_stress in CI
This case panics the machine fairly often and we should run
stress tests separately.

Sponsored by:	The FreeBSD Foundation
2021-10-12 05:40:24 +08:00
Kristof Provost 441d15a482 bridge tests: verify that we can't change MTU of bridge member interfaces
Reviewed by:	donner
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31305
2021-07-28 22:03:38 +02:00
Kristof Provost 6e43950640 bridge tests: test changing the bridge MTU
Changing the bridge MTU will now also change all of the member interface
MTUs. Test this.

Reviewed by:	donner
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31289
2021-07-28 22:01:12 +02:00
Kristof Provost 3e87f800f0 net tests: basic test case for bpf(4)'s ability to set vlan pcp
Use dhclient with its 'vlan-pcp' option to set a VLAN PCP value and
verify that it actually gets set.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31276
2021-07-26 23:13:31 +02:00
Kristof Provost 4b765ab4cd bridge tests: test linking bridges with a gif tunnel
Fairly basic test case for using gif(4)'s ability to tunnel Ethernet
traffic between bridges.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-07-26 23:13:31 +02:00
Kristof Provost a26e895f3d tests: Only log critical errors from scapy
Since 2.4.5 scapy started issuing warnings about a few different
configurations during our tests. These are harmless, but they generate
stderr output, which upsets atf_check.

Configure scapy to only log critical errors (and thus not warnings) to
fix these tests.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-05-12 20:54:30 +02:00
Alexander V. Chernikov bddae5c8a6 Improve debugging output on routing tests failure.
Most of the routing tests create per-test VNET, making
 it harder to repeat the failure with CLI tools.
Provide an additional route/nexthop data on failure.

Differential Revision: https://reviews.freebsd.org/D29957
Reviewed by:	kp
MFC after:	2 weeks
2021-04-24 22:41:27 +00:00
Alex Richardson 694407528f Correctly skip rtsock_l3 test when if_epair is not available
This logic was accidentally changed in 67f2f67fc8

Reported By:	olivier
X-MFC-With:	67f2f67fc8
Tested By:	kp
Reviewed By:	kp, melifaro
Fixes:		67f2f67fc8 ("Update rtsock_l3 test after 2fe5a79425c7")
Differential Revision: https://reviews.freebsd.org/D29944
2021-04-23 11:28:26 +01:00
Alex Richardson 67f2f67fc8 Update rtsock_l3 test after 2fe5a79425
Two of these tests now pass. Looking at Jenkins to find the first commit
where this behaviour changed indicates that
2fe5a79425 is the most likely cause.

Reviewed By:	melifaro
Differential Revision: https://reviews.freebsd.org/D28886
2021-04-21 10:58:34 +01:00
Alexander V. Chernikov 37c0f4a207 Fix typo in rtsock_common.h
MFC after:	3 days
2021-04-19 20:24:46 +00:00
Kristof Provost 4ae3a97e12 bridge tests: Test STP config BPDU validation
PR:		254924
Reviewed by:	donner
Differential Revision:	https://reviews.freebsd.org/D29783
2021-04-19 12:09:35 +02:00
Alex Richardson 83532eb68c tests/sys/net/routing: XFAIL the two failing tests
They have been failing for 1.5 months and the patch to fix them is stuck
in review so mark them as XFAIL for now to get Jenkins back to green.

To be reverted when https://reviews.freebsd.org/D28886 (or similar) is
commited.

Reviewed By:	kp
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D29528
2021-04-07 10:34:22 +01:00
Alex Richardson aa05775ef0 tests/sys/net/if_lagg_test: Fix syntax error
Fixes:	ee231b27ff ("Also skip sys/net/if_lagg_test:witness on non-i386")
2021-03-22 11:55:06 +00:00
Alex Richardson ee231b27ff Also skip sys/net/if_lagg_test:witness on non-i386
The LOR also happens on amd64 and other architectures. Ideally we would
fix this. However, in order to get Jenkins green again to catch real
regressions, we should skip this test for now.

PR:		251726
Reviewed By:	lwhsu
Differential Revision: https://reviews.freebsd.org/D29341
2021-03-19 18:35:06 +00:00
Kristof Provost 7a4dbffa42 bridge tests: Test that we also forward on some interfaces
Ensure that we not only block on some interfaces, but also forward on
some. Without the previous commit we wound up discarding on all ports,
rather than only on the ports needed to break the loop.

MFC after:	1 week
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D28917
2021-02-25 10:17:03 +01:00
Kristof Provost 26492ba271 bridge tests: Test STP on top of VLAN devices
This is basically the same test as the existing STP test, but now on top
of VLAN interfaces instead of directly using the epair devices.

MFC after:	1 week
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D28861
2021-02-23 13:54:07 +01:00
Alexander V. Chernikov 2fe5a79425 Fix dst/netmask handling in routing socket code.
Traditionally routing socket code did almost zero checks on
 the input message except for the most basic size checks.

This resulted in the unclear KPI boundary for the routing system code
 (`rtrequest*` and now `rib_action()`) w.r.t message validness.

Multiple potential problems and nuances exists:
* Host bits in RTAX_DST sockaddr. Existing applications do send prefixes
 with hostbits uncleared. Even `route(8)` does this, as they hope the kernel
 would do the job of fixing it. Code inside `rib_action()` needs to handle
 it on its own (see `rt_maskedcopy()` ugly hack).
* There are multiple way of adding the host route: it can be DST without
 netmask or DST with /32(/128) netmask. Also, RTF_HOST has to be set correspondingly.
 Currently, these 2 options create 2 DIFFERENT routes in the kernel.
* no sockaddr length/content checking for the "secondary" fields exists: nothing
 stops rtsock application to send sockaddr_in with length of 25 (instead of 16).
 Kernel will accept it, install to RIB as is and propagate to all rtsock consumers,
 potentially triggering bugs in their code. Same goes for sin_port, sin_zero, etc.

The goal of this change is to make rtsock verify all sockaddr and prefix consistency.
Said differently, `rib_action()` or internals should NOT require to change any of the
 sockaddrs supplied by `rt_addrinfo` structure due to incorrectness.

To be more specific, this change implements the following:
* sockaddr cleanup/validation check is added immediately after getting sockaddrs from rtm.
* Per-family dst/netmask checks clears host bits in dst and zeros all dst/netmask "secondary" fields.
* The same netmask checking code converts /32(/128) netmasks to "host" route case
 (NULL netmask, RTF_HOST), removing the dualism.
* Instead of allowing ANY "known" sockaddr families (0<..<AF_MAX), allow only actually
 supported ones (inet, inet6, link).
* Automatically convert `sockaddr_sdl` (AF_LINK) gateways to
  `sockaddr_sdl_short`.

Reported by:	Guy Yur <guyyur at gmail.com>
Reviewed By:	donner
Differential Revision: https://reviews.freebsd.org/D28668
MFC after:	3 days
2021-02-16 20:30:04 +00:00
Alexander V. Chernikov 81728a538d Split rtinit() into multiple functions.
rtinit[1]() is a function used to add or remove interface address prefix routes,
  similar to ifa_maintain_loopback_route().
It was intended to be family-agnostic. There is a problem with this approach
 in reality.

1) IPv6 code does not use it for the ifa routes. There is a separate layer,
  nd6_prelist_(), providing interface for maintaining interface routes. Its part,
  responsible for the actual route table interaction, mimics rtenty() code.

2) rtinit tries to combine multiple actions in the same function: constructing
  proper route attributes and handling iterations over multiple fibs, for the
  non-zero net.add_addr_allfibs use case. It notably increases the code complexity.

3) dstaddr handling. flags parameter re-uses RTF_ flags. As there is no special flag
 for p2p connections, host routes and p2p routes are handled in the same way.
 Additionally, mapping IFA flags to RTF flags makes the interface pretty messy.
 It make rtinit() to clash with ifa_mainain_loopback_route() for IPV4 interface
 aliases.

4) rtinit() is the last customer passing non-masked prefixes to rib_action(),
 complicating rib_action() implementation.

5) rtinit() coupled ifa announce/withdrawal notifications, producing "false positive"
 ifa messages in certain corner cases.

To address all these points, the following has been done:

* rtinit() has been split into multiple functions:
- Route attribute construction were moved to the per-address-family functions,
 dealing with (2), (3) and (4).
- funnction providing net.add_addr_allfibs handling and route rtsock notificaions
 is the new routing table inteface.
- rtsock ifa notificaion has been moved out as well. resulting set of funcion are only
 responsible for the actual route notifications.

Side effects:
* /32 alias does not result in interface routes (/32 route and "host" route)
* RTF_PINNED is now set for IPv6 prefixes corresponding to the interface addresses

Differential revision:	https://reviews.freebsd.org/D28186
2021-01-16 22:42:41 +00:00
Kristof Provost 03ffa25695 net tests: Re-enable most if_clone tests
All but one of these (tap_ipv6_up_stress) currently pass, so we should enable
them so we don't regress.
2020-12-17 21:54:25 +00:00
Alexander V. Chernikov c7cffd65c5 Add support for stacked VLANs (IEEE 802.1ad, AKA Q-in-Q).
802.1ad interfaces are created with ifconfig using the "vlanproto" parameter.
Eg., the following creates a 802.1Q VLAN (id #42) over a 802.1ad S-VLAN
(id #5) over a physical Ethernet interface (em0).

ifconfig vlan5 create vlandev em0 vlan 5 vlanproto 802.1ad up
ifconfig vlan42 create vlandev vlan5 vlan 42 inet 10.5.42.1/24

VLAN_MTU, VLAN_HWCSUM and VLAN_TSO capabilities should be properly
supported. VLAN_HWTAGGING is only partially supported, as there is
currently no IFCAP_VLAN_* denoting the possibility to set the VLAN
EtherType to anything else than 0x8100 (802.1ad uses 0x88A8).

Submitted by:	Olivier Piras
Sponsored by:	RG Nets
Differential Revision:	https://reviews.freebsd.org/D26436
2020-10-21 21:28:20 +00:00
Alexander V. Chernikov 1b95005e95 Fix route flags update during RTM_CHANGE.
Nexthop lookup was not consireding rt_flags when doing
 structure comparison, which lead to an original nexthop
 selection when changing flags. Fix the case by adding
 rt_flags field into comparison and rearranging nhop_priv
 fields to allow for efficient matching.
Fix `route change X/Y flags` case - recent changes
 disallowed specifying RTF_GATEWAY flag without actual gateway.
 It turns out, route(8) fills in RTF_GATEWAY by default, unless
 -interface flag is specified. Fix regression by clearing
 RTF_GATEWAY flag instead of failing.
Fix route flag reporting in RTM_CHANGE messages by explicitly
 updating rtm_flags after operation competion.
Add IPv4/IPv6 tests for flag-only route changes.
2020-10-04 13:24:58 +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
Kyle Evans fe815331bb build: provide a default WARNS for all in-tree builds
The current default is provided in various Makefile.inc in some top-level
directories and covers a good portion of the tree, but doesn't cover parts
of the build a little deeper (e.g. libcasper).

Provide a default in src.sys.mk and set WARNS to it in bsd.sys.mk if that
variable is defined. This lets us relatively cleanly provide a default WARNS
no matter where you're building in the src tree without breaking things
outside of the tree.

Crunchgen has been updated as a bootstrap tool to work on this change
because it needs r365605 at a minimum to succeed. The cleanup necessary to
successfully walk over this change on WITHOUT_CLEAN builds has been added.

There is a supplemental project to this to list all of the warnings that are
encountered when the environment has WARNS=6 NO_WERROR=yes:
https://warns.kevans.dev -- this project will hopefully eventually go away
in favor of CI doing a much better job than it.

Reviewed by:	emaste, brooks, ngie (all earlier version)
Reviewed by:	emaste, arichardson (depend-cleanup.sh change)
Differential Revision:	https://reviews.freebsd.org/D26455
2020-09-18 17:17:46 +00:00
Alexander V. Chernikov 5676d488c2 Add test for checking RTF_HOST and RTAX_NETMASK inconsistency.
RTF_HOST indicates whether route is a host route
 (netmask is empty or /{32,128}).
Check that if netmask is empty and host route is not specified, kernel
 returns an error.

Differential Revision:	https://reviews.freebsd.org/D26155
2020-08-22 18:14:05 +00:00
Dimitry Andric 967348a966 Use static inline for iface_{setup,delete}_addr in tests/sys/net/routing.
This fixes possible link errors, similar to:

ld: error: undefined symbol: iface_setup_addr
>>> referenced by test_rtsock_l3.c:111 (tests/sys/net/routing/test_rtsock_l3.c:111)
>>>               test_rtsock_l3.o:(presetup_ipv4)
>>> referenced by test_rtsock_l3.c:79 (tests/sys/net/routing/test_rtsock_l3.c:79)
>>>               test_rtsock_l3.o:(presetup_ipv6)
>>> referenced by test_rtsock_l3.c:512 (tests/sys/net/routing/test_rtsock_l3.c:512)
>>>               test_rtsock_l3.o:(atfu_rtm_change_v4_gw_success_body)
>>> referenced 10 more times

In C (not C++), 'naked' inline is almost always a mistake. Either use
static inline (this is appropriate for most cases), or extern inline.

MFC after:	3 days
2020-08-08 11:06:27 +00:00
Li-Wen Hsu 435166f877 Skip sys.net.if_lagg_test.lacp_linkstate_destroy_stress in CI because of panic
PR:		244168
Sponsored by:	The FreeBSD Foundation
2020-06-11 18:59:57 +00:00
Kristof Provost 048c96e3e6 bridge tests: Re-enable STP test
This test should no longer provoke large amounts of traffic, which can
overwhelm single-core systems, preventing them from making progress in the
tests.

The test can now be re-enabled.

PR:		246448
2020-06-07 13:53:02 +00:00
Kristof Provost e07e002e95 bridge tests: Avoid building a switching loop
Enable STP before bringing the bridges up. This avoids a switching loop,
which has a tendency to drown out progress in userspace processes,
especially on single-core systems.

Only check that we have indeed shut down one of the looped interfaces

PR:		246448
Reviewed by:	melifaro
Differential Revision:	https://reviews.freebsd.org/D25084
2020-06-01 19:26:16 +00:00
Edward Tomasz Napierala f464bd04ce Make sys.net.if_bridge_test depend on python; sys.net.if_bridge_test.span
requires it.

MFC after:	2 weeks
Sponsored by:	DARPA
2020-05-19 21:55:29 +00:00
Li-Wen Hsu b18e0a534f Only skip sys.net.if_clone_test.epair_stress in CI env
PR:		246443
Sponsored by:	The FreeBSD Foundation
2020-05-13 20:37:46 +00:00