Tests for the FD bio.
More...
#include <freeradius-devel/util/test/acutest_common_init.h>
#include <freeradius-devel/util/test/acutest_helpers.h>
#include <freeradius-devel/bio/bio_priv.h>
#include <freeradius-devel/bio/fd.h>
#include <freeradius-devel/util/syserror.h>
Go to the source code of this file.
Tests for the FD bio.
- Copyright
- 2026 Network RADIUS SAS (legal.nosp@m.@net.nosp@m.workr.nosp@m.adiu.nosp@m.s.com)
Definition in file bio_fd_tests.c.
◆ _BIO_PRIVATE
◆ cb_connected()
| static void cb_connected |
( |
fr_bio_t * |
bio | ) |
|
|
static |
◆ cb_error()
◆ cb_timeout()
| static void cb_timeout |
( |
fr_bio_t * |
bio | ) |
|
|
static |
◆ ipv6_loopback_usable()
| static bool ipv6_loopback_usable |
( |
void |
| ) |
|
|
static |
Read one packet through an unconnected UDP bio bound to the wildcard address.
The local address of a bio bound to the wildcard address does not identify the address that a packet was sent to. fr_bio_fd_init_common() therefore installs fr_bio_fd_recvfromto4() or fr_bio_fd_recvfromto6(). Those two functions read the destination address from a control message (data which recvmsg() returns beside the packet), and copy the destination port from the port of the bio.
fr_bio_fd_common_datagram() also enables receive timestamps, so each packet carries two control messages. If cbuf in fr_bio_fd_t is too small for both control messages, then the bio drops every packet. See if the IPv6 loopback address can be used
Some hosts and containers turn IPv6 off. The bind() fails there, and errno says why.
Definition at line 179 of file bio_fd_tests.c.
◆ loopback_listen()
| static int loopback_listen |
( |
uint16_t * |
port | ) |
|
|
static |
Open a TCP socket listening on loopback.
The kernel completes the TCP handshake for any listening socket, and the test needs only the handshake. The test never calls accept(), so the kernel holds the new connection in the backlog of the listening socket.
- Parameters
-
| [out] | port | the port which the kernel picked. |
- Returns
- >=0 the listening socket.
- <0 on error.
Definition at line 50 of file bio_fd_tests.c.
◆ recvfromto_test()
| static void recvfromto_test |
( |
int |
af | ) |
|
|
static |
◆ test_deferred_connect_success_calls_connected_cb()
| static void test_deferred_connect_success_calls_connected_cb |
( |
void |
| ) |
|
|
static |
A deferred connect which succeeds has to call the connected callback.
A non-blocking connect() to a listening loopback port can return EINPROGRESS. On EINPROGRESS, fr_bio_fd_connect_full() defers the connect, and the event loop calls fr_bio_fd_el_connect() once the socket is writable. fr_bio_fd_el_connect() then calls connect() a second time. If the handshake has finished, the second connect() can fail with EISCONN, so fr_bio_fd_try_connect() has to treat EISCONN as success.
The test needs a connect which succeeds, because a connect which fails may not reach fr_bio_fd_el_connect(). kqueue can report a refused connect with EV_EOF, and event.c passes EV_EOF to the error callback, fr_bio_fd_el_error().
Definition at line 85 of file bio_fd_tests.c.
◆ test_recvfromto4()
| static void test_recvfromto4 |
( |
void |
| ) |
|
|
static |
◆ test_recvfromto6()
| static void test_recvfromto6 |
( |
void |
| ) |
|
|
static |
◆ connected_count
◆ error_count
◆ TEST_LIST
Initial value:= {
}
static void test_deferred_connect_success_calls_connected_cb(void)
A deferred connect which succeeds has to call the connected callback.
static void test_recvfromto6(void)
static void test_recvfromto4(void)
Definition at line 290 of file bio_fd_tests.c.
◆ timeout_count