[neighbour] Treat delayed transmissions as pending operations

Treat each delayed transmission as a pending operation, so that the
"sync" command can be used to ensure that all delayed packets have
been transmitted.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2026-01-09 18:29:53 +00:00
parent 2110afb351
commit 9c01c5a5da

View File

@@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/retry.h> #include <ipxe/retry.h>
#include <ipxe/timer.h> #include <ipxe/timer.h>
#include <ipxe/malloc.h> #include <ipxe/malloc.h>
#include <ipxe/pending.h>
#include <ipxe/neighbour.h> #include <ipxe/neighbour.h>
#include <config/fault.h> #include <config/fault.h>
@@ -64,6 +65,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** The neighbour cache */ /** The neighbour cache */
struct list_head neighbours = LIST_HEAD_INIT ( neighbours ); struct list_head neighbours = LIST_HEAD_INIT ( neighbours );
/** Pending operation for delayed transmissions */
static struct pending_operation neighbour_delayed;
static void neighbour_expired ( struct retry_timer *timer, int over ); static void neighbour_expired ( struct retry_timer *timer, int over );
/** /**
@@ -226,6 +230,9 @@ static void neighbour_tx_queue ( struct neighbour *neighbour ) {
/* Strip pseudo-header */ /* Strip pseudo-header */
iob_pull ( iobuf, sizeof ( *delay ) ); iob_pull ( iobuf, sizeof ( *delay ) );
/* Remove pending operation */
pending_put ( &neighbour_delayed );
} }
/* Transmit deferred packet */ /* Transmit deferred packet */
@@ -296,6 +303,8 @@ static void neighbour_destroy ( struct neighbour *neighbour, int rc ) {
net_protocol->ntoa ( neighbour->net_dest ), net_protocol->ntoa ( neighbour->net_dest ),
strerror ( rc ) ); strerror ( rc ) );
list_del ( &iobuf->list ); list_del ( &iobuf->list );
if ( NEIGHBOUR_DELAY_MS )
pending_put ( &neighbour_delayed );
netdev_tx_err ( neighbour->netdev, iobuf, rc ); netdev_tx_err ( neighbour->netdev, iobuf, rc );
} }
@@ -399,6 +408,9 @@ int neighbour_tx ( struct io_buffer *iobuf, struct net_device *netdev,
delay = iob_push ( iobuf, sizeof ( *delay ) ); delay = iob_push ( iobuf, sizeof ( *delay ) );
delay->start = currticks(); delay->start = currticks();
/* Add pending operation */
pending_get ( &neighbour_delayed );
/* Process deferred packet queue, if possible */ /* Process deferred packet queue, if possible */
if ( ! neighbour->discovery ) if ( ! neighbour->discovery )
neighbour_tx_queue ( neighbour ); neighbour_tx_queue ( neighbour );