Commit graph

25 commits

Author SHA1 Message Date
Gleb Smirnoff a8edc9f1e3 tests/netgraph: start ng_ksocket(4) tests
The ng_ksocket(4) functionality is very fragile as it interfaces with
kernel socket code in unusual way.  It definitely needs a test suite.
Start one with a test that tests UDP over IPv4.
2024-03-22 22:44:16 -07:00
Gleb Smirnoff fbbb50f570 tests/netgraph: mark all tests as required_user="root"
Any netgraph operation requires root priveleges.  Some tests in the
directory already mark themselves with 'atf_tc_set_md_var(conf,
"require.user", "root");' which creates a lot of pasted code.  Some tests
don't mark self.  For this particular directory a blanket metadata setting
in the Makefile is acceptable, imho.
2024-03-22 19:50:33 -07: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
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
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06: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
Mitchell Horne d99a40e5ba Remove riscv workaround in sys.netgraph.hub.loop test
The test case now passes on this architecture. This reverts commits
d5fd5cdc06 and 168b579a48.

Reviewed by:	lwhsu, imp
Differential Revision:	https://reviews.freebsd.org/D33252
2021-12-05 11:12:40 -04:00
Li-Wen Hsu 168b579a48
Fix RISC-V build
Fixes:	d5fd5cdc06
2021-10-14 23:20:12 +08:00
Li-Wen Hsu d5fd5cdc06
Temporarily skip sys.netgraph.hub.loop on RISC-V in CI
This case panics kernel.

PR:		259157
Sponsored by:	The FreeBSD Foundation
2021-10-14 05:31:22 +08:00
Lutz Donnerhacke 43e4821315 tests/netgraph: Check for PR241954
Add tests to check for renaming issues reported in PR241954 and solved
in D30110.

MFC:	Together with D30629
Differential Revision: https://reviews.freebsd.org/D30713
2021-06-13 22:29:56 +02:00
Lutz Donnerhacke 0afa9be039 tests/netgraph: Missed fixup after D30699
During D30699 the existing basic tests were missed.  Furthermore
debugging output was still in the code, which is removed now.

MFC:	together with D30699
Differential Revision: https://reviews.freebsd.org/D30714
2021-06-13 22:16:52 +02:00
Lutz Donnerhacke 6b08e68be1 tests/netgraph: Tests for ng_vlan_rotate
Test functionality of ng_vlan_rotate(4):
 - Rotate 1 to 9 stagged vlans in any possible direction and length
 - Rotate random combinations of ethertypes (8100, 88a8, 9100)
 - Automatic reverse rotating for backward data flow
 - Test too many and to few vlans

Reviewed by:	kp (earlier version)
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30670
2021-06-09 13:45:37 +02:00
Lutz Donnerhacke 7863faa78a tests/netgraph: Tests for ng_hub
Test functionality of ng_hub(4):
 - replicting traffic to anything but the sending hook
 - persistence
 - an unrestricted loop
 - implementation limits with many hooks.

Reviewed by:	kp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30633
2021-06-09 13:36:23 +02:00
Lutz Donnerhacke 5554abd9cc tests/netgraph: Factor out univeral data counter functions
Factor out the data counter helpers for other tests to use.

Reviewed by:	kp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30699
2021-06-09 13:32:22 +02:00
Lutz Donnerhacke a664ade939 tests/netgraph: Fix style
Indent all files correctly

MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30692
2021-06-09 13:31:16 +02:00
Lutz Donnerhacke 9021c46603 tests/netgraph: Attribute errors to the caller
Errors raised in the common util functions should raise the location
of their caller to be useful and include the errno description.

Reviewed by:	kp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30671
2021-06-08 19:23:50 +02:00
Lutz Donnerhacke 6181470239 tests/netgraph: Tests for ng_bridge
Test functionality of ng_bridge(4):
 - replicating traffic to anything but the sending hook
 - persistence
 - detect loops
 - unicast to only one link of many
 - stretch to implementation limits on broadcast

Reviewed by:	kp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30647
2021-06-08 13:27:23 +02:00
Lutz Donnerhacke 09307dbfb8 tests/netgraph: Allow receiving answers to messages
Add msg_handler in order to receive messages from netgraph nodes to be
tested.

Reviewed by:	kp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30657
2021-06-08 12:49:04 +02:00
Lutz Donnerhacke 24ea1dbf25 tests/netgraph: Inital framework for testing libnetgraph
Provide a framework of functions to test various netgraph modules.
Tests contain:
 - creating, renaming, and destroying nodes
 - connecting and removing hooks
 - sending and receiving data
 - sending ASCII messages
 - errors can be passed for indiviual inspection or fail the test

Reviewed by:	kp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30629
2021-06-04 15:17:54 +02:00
Alex Richardson 6f30d1c851 ng_macfilter_test: Skip rather than fail if there is no network
This should bring the number of Jenkins failures from 4 down to 3.
Locally kyua now prints `skipped: could not find a valid interface  [0.115s]`
when I run it in QEMU without a network device.

Reviewed By:	lwhsu
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D29414
2021-03-25 11:16:12 +00:00
Alex Richardson 7dd1f932c1 tests/sys/netgraph: Further CI fixes
I was trying to debug why this test is working locally but failing in CI.
While doing so I made some small changes to allow running it with set -e.

It turns out the problem is that find_iface does not return anything in
Jenkins, so all following tests fail with obscure error messages.
To handle this case exit early if $eth is empty.

Reviewed By:	lwhsu
Differential Revision: https://reviews.freebsd.org/D29340
2021-03-19 18:34:30 +00:00
Alex Richardson 65f4ff4e68 tests/sys/netgraph/ng_macfilter_test: Fix invalid TAP output
This should allow the test to pass in Jenkins. Testing it locally now
reports "passed" instead of "invalid TAP data".

While touching this file also fix some shellcheck warnings that were
pointed out by my IDE.

Reviewed By:	lwhsu, afedorov
Differential Revision: https://reviews.freebsd.org/D29054
2021-03-12 17:35:26 +00:00
Alex Richardson 3775ddcf5a tests/sys/netgraph: Tell kyua that perl is required
Otherwise these tests fail with incomprehensible error messages.

Reviewed By:	kp
Differential Revision: https://reviews.freebsd.org/D28894
2021-02-23 17:43:31 +00:00
Nick Hibma e8db04c389 New Netgraph module ng_macfilter:
Macfilter to route packets through different hooks based on sender MAC address.

Based on ng_macfilter written by Pekka Nikander

Sponsered by Retina b.v.

Reviewed by:	afedorov
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D27268
2020-12-08 15:09:42 +00:00